2022-12-05 08:06:45 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-01-23 03:02:59 +00:00
|
|
|
import 'package:unit2/model/login_data/user_info/user_data.dart';
|
2022-12-13 06:56:09 +00:00
|
|
|
import 'package:unit2/utils/alerts.dart';
|
2023-06-21 00:22:43 +00:00
|
|
|
import 'package:unit2/utils/global_context.dart';
|
2022-12-05 08:06:45 +00:00
|
|
|
import '../../../../theme-data.dart/colors.dart';
|
2023-04-05 00:54:24 +00:00
|
|
|
import '../../../../utils/global.dart';
|
2022-12-05 08:06:45 +00:00
|
|
|
|
2023-10-08 12:12:49 +00:00
|
|
|
Widget getTile(IconData icondata, String title, String route,
|
|
|
|
BuildContext context, UserData userData) {
|
2022-12-05 08:06:45 +00:00
|
|
|
return ListTile(
|
|
|
|
dense: true,
|
|
|
|
leading: Icon(
|
|
|
|
icondata,
|
|
|
|
color: primary,
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
title,
|
|
|
|
style: const TextStyle(color: Colors.black),
|
|
|
|
),
|
|
|
|
onTap: () async {
|
2022-12-13 06:56:09 +00:00
|
|
|
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-02-01 08:03:05 +00:00
|
|
|
}
|
2023-10-08 12:12:49 +00:00
|
|
|
if (title.toLowerCase() == 'request sos') {
|
|
|
|
Navigator.pushNamed(context, '/sos');
|
|
|
|
}
|
2022-12-05 08:06:45 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2023-02-01 08:03:05 +00:00
|
|
|
|
2023-10-08 12:12:49 +00:00
|
|
|
class ProfileArguments {
|
2023-02-01 08:03:05 +00:00
|
|
|
final int userID;
|
|
|
|
final String token;
|
|
|
|
const ProfileArguments({required this.token, required this.userID});
|
|
|
|
}
|