passo_mobile_app/lib/screens/unit2/homepage.dart/components/menu.dart

41 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:unit2/model/login_data/employee_info/employee_info.dart';
import 'package:unit2/model/login_data/user_info/user_data.dart';
import 'package:unit2/utils/alerts.dart';
import '../../../../theme-data.dart/colors.dart';
Widget getTile(
IconData icondata, String title, String route, BuildContext context,UserData userData) {
return ListTile(
dense: true,
leading: Icon(
icondata,
color: primary,
),
title: Text(
title,
style: const TextStyle(color: Colors.black),
),
onTap: () async {
if (title.toLowerCase() == "logout") {
confirmAlert(context, () {
Navigator.pushReplacementNamed (context,"/");
},"Logout","Are You sure you want to logout?");
}if(title.toLowerCase() == 'profile'){
ProfileArguments profileArguments = ProfileArguments(token: userData.user!.login!.token!, userID:userData.user!.login!.user!.profileId!);
Navigator.pushNamed(context, route,arguments: profileArguments);
}
else {
Navigator.pushNamed(context, route);
}
},
);
}
class ProfileArguments{
final int userID;
final String token;
const ProfileArguments({required this.token, required this.userID});
}