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

51 lines
1.6 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2023-01-23 03:02:59 +00:00
import 'package:unit2/model/login_data/user_info/user_data.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/global_context.dart';
import '../../../../theme-data.dart/colors.dart';
2023-04-05 00:54:24 +00:00
import '../../../../utils/global.dart';
2023-10-08 12:12:49 +00:00
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") {
2023-10-08 12:12:49 +00:00
confirmAlert(context, () async {
2023-04-05 00:54:24 +00:00
await CREDENTIALS!.clear();
2023-10-08 12:12:49 +00:00
await OFFLINE!.clear();
await CREDENTIALS!.deleteAll(['username', 'password', 'saved']);
Navigator.pushReplacementNamed(
NavigationService.navigatorKey.currentContext!, "/");
}, "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);
}
if (title.toLowerCase() == 'basic info') {
2023-04-11 01:27:53 +00:00
Navigator.pushNamed(context, '/basic-info');
}
2023-10-08 12:12:49 +00:00
if (title.toLowerCase() == 'request sos') {
Navigator.pushNamed(context, '/sos');
}
},
);
}
2023-10-08 12:12:49 +00:00
class ProfileArguments {
final int userID;
final String token;
const ProfileArguments({required this.token, required this.userID});
}