back button handle added and session
This commit is contained in:
parent
0d4c3cf02e
commit
e0fd4267f2
@ -295,6 +295,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:uae_stat/config/sessionCheckScreen.dart';
|
||||
import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/UAE_Numbers/Social/marriages.dart';
|
||||
import 'package:uae_stat/presentation/Screens/auth_verification/registration.dart';
|
||||
import 'package:uae_stat/presentation/Screens/charts/chart.dart';
|
||||
@ -336,34 +337,35 @@ import '../presentation/routes/drawer_routes/Drawer Items/manage_users.dart';
|
||||
|
||||
final FlutterSecureStorage _secureStorage = const FlutterSecureStorage();
|
||||
|
||||
Future<String?> _checkSession() async {
|
||||
print('_checkSession');
|
||||
await Future.delayed(Duration(seconds: 2)); // Optional splash effect
|
||||
|
||||
String? sessionToken =
|
||||
await _secureStorage.read(key: "FlutterSecureStorage.session");
|
||||
print('sessionToken $sessionToken');
|
||||
|
||||
if (sessionToken != null && sessionToken.isNotEmpty) {
|
||||
print('_checkSession home');
|
||||
return "/myhomepage"; // Redirect to home page if session is valid
|
||||
} else {
|
||||
print('_checkSession login');
|
||||
return "/login"; // Redirect to login page if session is invalid
|
||||
}
|
||||
}
|
||||
// Future<String?> _checkSession() async {
|
||||
// print('_checkSession');
|
||||
// await Future.delayed(Duration(seconds: 2)); // Optional splash effect
|
||||
//
|
||||
// String? sessionToken =
|
||||
// await _secureStorage.read(key: "FlutterSecureStorage.session");
|
||||
// print('sessionToken $sessionToken');
|
||||
//
|
||||
// if (sessionToken != null && sessionToken.isNotEmpty) {
|
||||
// print('_checkSession home');
|
||||
// return "/myhomepage"; // Redirect to home page if session is valid
|
||||
// } else {
|
||||
// print('_checkSession login');
|
||||
// return "/login"; // Redirect to login page if session is invalid
|
||||
// }
|
||||
// }
|
||||
|
||||
final GoRouter router = GoRouter(
|
||||
initialLocation: '/',
|
||||
routes: [
|
||||
// GoRoute(
|
||||
// path: '/',
|
||||
// //builder: (context, state) => LoginRoute(),
|
||||
// builder: (context, state) => LoginRoute(),
|
||||
// ),
|
||||
GoRoute(
|
||||
path: '/',
|
||||
redirect: (context, state) async => await _checkSession(),
|
||||
//builder: (context, state) => LoginRoute(),
|
||||
builder: (context, state) => SessionCheckScreen(),
|
||||
),
|
||||
// GoRoute(
|
||||
// path: '/',
|
||||
// redirect: (context, state) async => await _checkSession(),
|
||||
// ),
|
||||
GoRoute(
|
||||
path: '/internetcheck',
|
||||
builder: (context, state) => InternetCheck(),
|
||||
|
||||
37
lib/config/sessionCheckScreen.dart
Normal file
37
lib/config/sessionCheckScreen.dart
Normal file
@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
|
||||
class SessionCheckScreen extends StatefulWidget {
|
||||
@override
|
||||
_SessionCheckScreenState createState() => _SessionCheckScreenState();
|
||||
}
|
||||
|
||||
class _SessionCheckScreenState extends State<SessionCheckScreen> {
|
||||
final PAuthRepo _authRepo = PAuthRepo();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkSession();
|
||||
}
|
||||
|
||||
Future<void> _checkSession() async {
|
||||
await Future.delayed(Duration(seconds: 2)); // Optional splash delay
|
||||
print('fetchLocallyStored');
|
||||
final session = await _authRepo.fetchLocallyStored();
|
||||
print('fetchLocallyStored $session');
|
||||
if (session != null) {
|
||||
print('myhomepage');
|
||||
if (mounted) context.go('/myhomepage'); // Redirect to home
|
||||
} else {
|
||||
print('login');
|
||||
if (mounted) context.go('/login'); // Redirect to login
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
@ -69,7 +69,7 @@
|
||||
"password_match": "كلمات المرور غير متطابقة",
|
||||
"only8charac": "يجب أن تتكون كلمة المرور من 8 أحرف على الأقل",
|
||||
|
||||
"manage_user": "إدارة المستخدمين",
|
||||
"manage_user": "إدارة المستخدم",
|
||||
"user_name": "اسم المستخدم",
|
||||
"reg_date": "تاريخ التسجيل",
|
||||
"status": "الحالة",
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
"password_match": "Passwords do not match",
|
||||
"only8charac": "Password must be at least 8characters",
|
||||
|
||||
"manage_user": "Manage user",
|
||||
"manage_user": "Manage User",
|
||||
"user_name": "User Name",
|
||||
"reg_date": "Registration Date",
|
||||
"status": "Status",
|
||||
|
||||
@ -10,9 +10,10 @@ class Competitiveness extends StatelessWidget {
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
title: Center(
|
||||
|
||||
@ -11,9 +11,10 @@ class CountryProfile extends StatelessWidget {
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
title: Center(
|
||||
|
||||
@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
@ -31,12 +32,16 @@ class UaeNumbers extends StatelessWidget {
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
title: Text("UAE Numbers"),
|
||||
title: Text(context.translate(
|
||||
'UAE Numbers',
|
||||
'أرقام الإمارات',
|
||||
)),
|
||||
body: uaenumberWidget(),
|
||||
),
|
||||
);
|
||||
@ -107,9 +112,9 @@ class _UaenumberWidgetState extends ConsumerState<uaenumberWidget> {
|
||||
decoration: InputDecoration(
|
||||
hintText: "Search",
|
||||
prefixIcon: Image.asset(
|
||||
MiscIconAssetPath.search,
|
||||
width: 20,
|
||||
height: 20,
|
||||
MiscIconAssetPath.search,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
@ -389,9 +394,9 @@ class _CustomExpandableTileState extends State<CustomExpandableTile> {
|
||||
? SingleChildScrollView(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
// borderRadius: BorderRadius.all(Radius.circular(20))
|
||||
),
|
||||
color: Colors.white,
|
||||
// borderRadius: BorderRadius.all(Radius.circular(20))
|
||||
),
|
||||
padding: const EdgeInsets.all(1),
|
||||
child: Column(
|
||||
children: widget.children,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,9 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
@ -336,12 +338,62 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
final PAuthRepo _authRepo = PAuthRepo();
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await _authRepo.logout();
|
||||
prefs.clear();
|
||||
context.go('/login'); // Redirect to login after logout
|
||||
}
|
||||
|
||||
void _showExitConfirmation(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(
|
||||
context.translate(
|
||||
'Logout',
|
||||
'تسجيل الخروج',
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
context.translate(
|
||||
'Are you sure you want to logout?',
|
||||
'هل أنت متأكد أنك تريد تسجيل الخروج؟',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(), // Close dialog
|
||||
child: Text(
|
||||
context.translate(
|
||||
'Cancel',
|
||||
'إلغاء',
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => logout(context), // Exit the app
|
||||
child: Text(
|
||||
context.translate(
|
||||
'Logout',
|
||||
'تسجيل الخروج',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/');
|
||||
_showExitConfirmation(context); // Show exit confirmation dialog
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
@ -632,7 +684,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
},
|
||||
side: BorderSide(
|
||||
color:
|
||||
showError ? Color(0xFFb22222) : Color(0xFF7296BE),
|
||||
showError ? Color(0xFFb22222) : Color(0xFF7296BE),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
@ -646,16 +698,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.agree,
|
||||
style: TextStyle(color: Color(0xFF898C81)),
|
||||
text: AppLocalizations.of(context)!.agree,
|
||||
style: TextStyle(color: Color(0xFF898C81)),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(
|
||||
context,
|
||||
)!
|
||||
.terms_conditions, style: TextStyle(
|
||||
.terms_conditions,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF985400),
|
||||
// decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight
|
||||
@ -671,16 +722,20 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(
|
||||
context,
|
||||
)!.t_and,
|
||||
style: TextStyle(color: Color(0xFF898C81)),
|
||||
)!
|
||||
.t_and,
|
||||
style: TextStyle(color: Color(0xFF898C81)),
|
||||
),
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(
|
||||
context,
|
||||
)!.privacy_policy, style: TextStyle(
|
||||
)!
|
||||
.privacy_policy,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF985400),
|
||||
// decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.w600, // Makes the text bold
|
||||
fontWeight: FontWeight
|
||||
.w600, // Makes the text bold
|
||||
decorationColor: Color(0xFF985400),
|
||||
decorationThickness: 1,
|
||||
),
|
||||
@ -734,8 +789,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
context.go('/createNewPw/$userId/$email');
|
||||
},
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!
|
||||
.change_password,
|
||||
AppLocalizations.of(context)!.change_password,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF648CBA),
|
||||
fontSize: 14,
|
||||
|
||||
@ -11,7 +11,7 @@ extension Dialogs on BuildContext {
|
||||
context: this,
|
||||
builder: (loaderContext) {
|
||||
if (!ctxWaiter.isCompleted) ctxWaiter.complete(loaderContext);
|
||||
return const Dialog(
|
||||
return Dialog(
|
||||
child: LinearProgressIndicator(),
|
||||
);
|
||||
},
|
||||
@ -111,6 +111,18 @@ extension Dialogs on BuildContext {
|
||||
this,
|
||||
rootNavigator: true,
|
||||
).pop,
|
||||
style: TextButton.styleFrom(
|
||||
// backgroundColor: Colors.white, // Background color
|
||||
foregroundColor: Color(0xFF92722A), // Font (text) color
|
||||
side: BorderSide(
|
||||
color: Color(0xFF92722A)), // Border outline color
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(8), // Optional: Rounded corners
|
||||
),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 12), // Optional: Padding
|
||||
),
|
||||
child: const Text('Return'),
|
||||
),
|
||||
if (extraAction != null) extraAction,
|
||||
|
||||
@ -698,19 +698,31 @@ class LoginRoute extends HookConsumerWidget {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text("Exit App"),
|
||||
content: Text("Are you sure you want to exit?"),
|
||||
title: Text( context.translate(
|
||||
'Exit App',
|
||||
'الخروج من التطبيق',
|
||||
),),
|
||||
content: Text( context.translate(
|
||||
'Are you sure you want to exit?',
|
||||
'هل أنت متأكد أنك تريد الخروج؟',
|
||||
),),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(), // Close dialog
|
||||
child: Text("Cancel"),
|
||||
child: Text( context.translate(
|
||||
'Cancel',
|
||||
'إلغاء',
|
||||
),),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => SystemNavigator.pop(), // Exit the app
|
||||
child: Text("Exit"),
|
||||
child: Text( context.translate(
|
||||
'Exit',
|
||||
'خروج',
|
||||
),),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,6 +167,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
|
||||
import 'package:uae_stat/presentation/Screens/app_tour/Target_content.dart';
|
||||
@ -183,17 +185,73 @@ class MyHomePage extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _MyHomePageState extends ConsumerState<MyHomePage> {
|
||||
final PAuthRepo _authRepo = PAuthRepo();
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await _authRepo.logout();
|
||||
prefs.clear();
|
||||
context.go('/login'); // Redirect to login after logout
|
||||
}
|
||||
|
||||
void _showExitConfirmation(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(
|
||||
context.translate(
|
||||
'Logout',
|
||||
'تسجيل الخروج',
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
context.translate(
|
||||
'Are you sure you want to logout?',
|
||||
'هل أنت متأكد أنك تريد تسجيل الخروج؟',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(), // Close dialog
|
||||
child: Text(
|
||||
context.translate(
|
||||
'Cancel',
|
||||
'إلغاء',
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => logout(context), // Exit the app
|
||||
child: Text(
|
||||
context.translate(
|
||||
'Logout',
|
||||
'تسجيل الخروج',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
return BaseScaffold(
|
||||
title: Center(
|
||||
child: SizedBox(
|
||||
height: myheight / 5,
|
||||
width: mywidth / 3,
|
||||
child: Image(image: AssetImage('assets/logos/uae_stat.png')))),
|
||||
body: EconomyStatsWidget(),
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
_showExitConfirmation(context); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
title: Center(
|
||||
child: SizedBox(
|
||||
height: myheight / 5,
|
||||
width: mywidth / 3,
|
||||
child: Image(image: AssetImage('assets/logos/uae_stat.png')))),
|
||||
body: EconomyStatsWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,9 +62,10 @@ class _BookMarkState extends ConsumerState<BookMark> {
|
||||
final filteredList =
|
||||
dataList.where((item) => item['isBookmark'] == true).toList();
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
title: Text('Bookmark'),
|
||||
|
||||
@ -425,9 +425,10 @@ class _EditProfileState extends State<EditProfile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
title: Text(
|
||||
|
||||
@ -238,9 +238,10 @@ class _FeedbackFormState extends State<FeedbackForm>
|
||||
|
||||
final userName = GoRouterState.of(context).extra as String? ?? 'Guest User';
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
// title: Text("Feedback"),
|
||||
@ -550,8 +551,8 @@ class _FeedbackFormState extends State<FeedbackForm>
|
||||
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.feedback_message,
|
||||
Text(
|
||||
AppLocalizations.of(context)!.feedback_message,
|
||||
style: TextStyle(fontSize: 16, color: Color(0xFF898C81)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@ -602,9 +603,9 @@ AppLocalizations.of(context)!.feedback_message,
|
||||
|
||||
// Icon(Icons.error, size: 80, color: Colors.red),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.failed_to_sharefeedback,
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context)!.failed_to_sharefeedback,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF414042)),
|
||||
@ -753,10 +754,9 @@ AppLocalizations.of(context)!.feedback_message,
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context)!.formError,
|
||||
// "Please correct the errors before submitting."
|
||||
)
|
||||
),
|
||||
AppLocalizations.of(context)!.formError,
|
||||
// "Please correct the errors before submitting."
|
||||
)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -786,10 +786,10 @@ AppLocalizations.of(context)!.feedback_message,
|
||||
// await sendFeedbackEmail(feedbackData, createdTime);
|
||||
await _removeFeedbackText();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.feedback_submitted),
|
||||
),
|
||||
);
|
||||
);
|
||||
setState(() {
|
||||
_isFeedbackSubmitted = true;
|
||||
_isFeedbackFailed = false;
|
||||
@ -798,12 +798,11 @@ AppLocalizations.of(context)!.feedback_message,
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(
|
||||
// "Failed to submit feedback: $e"
|
||||
SnackBar(
|
||||
content: Text(
|
||||
// "Failed to submit feedback: $e"
|
||||
AppLocalizations.of(context)!.feedback_failed(e.toString()),
|
||||
)
|
||||
|
||||
),
|
||||
)),
|
||||
);
|
||||
setState(() {
|
||||
_isFeedbackFailed = true; // Update state to show failure message
|
||||
|
||||
@ -144,7 +144,8 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
TextSpan(
|
||||
text: newStatus,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold, // Makes newStatus bold
|
||||
fontWeight:
|
||||
FontWeight.bold, // Makes newStatus bold
|
||||
fontSize: 18,
|
||||
color: Color(0xFF898C81),
|
||||
),
|
||||
@ -175,74 +176,77 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 100, // Set the desired width
|
||||
child:
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(); // Close dialog without changing status
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
10.0), // Adjust the radius as needed
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(); // Close dialog without changing status
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
10.0), // Adjust the radius as needed
|
||||
),
|
||||
side: BorderSide(
|
||||
color: Color(0xFFAA8E83), // Set the outline color
|
||||
width: 1, // Set the border width
|
||||
),
|
||||
),
|
||||
side: BorderSide(
|
||||
color: Color(0xFFAA8E83), // Set the outline color
|
||||
width: 1, // Set the border width
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.no,
|
||||
style: TextStyle(
|
||||
color: Color(0xFFAA8E83),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(AppLocalizations.of(context)!.no,
|
||||
style: TextStyle(color: Color(0xFFAA8E83),
|
||||
fontSize: 16,
|
||||
),),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 100, // Set the desired width
|
||||
child:
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
// Update status in PocketBase
|
||||
await _pb.collection('users').update(
|
||||
user.id, // User's unique ID
|
||||
body: {
|
||||
'status': newStatus, // Update status
|
||||
'verified': newStatus == 'Approved' ? true : false,
|
||||
'reviewed': true,
|
||||
},
|
||||
);
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
// Update status in PocketBase
|
||||
await _pb.collection('users').update(
|
||||
user.id, // User's unique ID
|
||||
body: {
|
||||
'status': newStatus, // Update status
|
||||
'verified': newStatus == 'Approved' ? true : false,
|
||||
'reviewed': true,
|
||||
},
|
||||
);
|
||||
|
||||
// Update local state
|
||||
// setState(() {
|
||||
// user.status = newStatus;
|
||||
// });
|
||||
fetchUnverifiedUsers();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Status updated successfully!')),
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error updating status: $e')),
|
||||
);
|
||||
}
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Color(0xFFAA8E83), // Set background color
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10.0), // Set text color
|
||||
// Update local state
|
||||
// setState(() {
|
||||
// user.status = newStatus;
|
||||
// });
|
||||
fetchUnverifiedUsers();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Status updated successfully!')),
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error updating status: $e')),
|
||||
);
|
||||
}
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor:
|
||||
Color(0xFFAA8E83), // Set background color
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10.0), // Set text color
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
// 'Yes',
|
||||
AppLocalizations.of(context)!.yes,
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
// 'Yes',
|
||||
AppLocalizations.of(context)!.yes,
|
||||
style: TextStyle(color: Colors.white,
|
||||
fontSize: 16),
|
||||
),
|
||||
),),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
@ -262,9 +266,10 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/myhomepage');
|
||||
context.go('/myhomepage'); // Show exit confirmation dialog
|
||||
},
|
||||
child: BaseScaffold(
|
||||
// title: Text("Manage User"),
|
||||
@ -285,185 +290,186 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
// ),
|
||||
// ),
|
||||
// onChanged: filterUsers,
|
||||
// ),
|
||||
// ),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
border: Border.all(width: 2, color: Color(0xFFAA8E83)),
|
||||
),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: AppLocalizations.of(context)!.search,
|
||||
prefixIcon: Image.asset(
|
||||
MiscIconAssetPath.search,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
// ,prefixIcon: Icon(
|
||||
// Icons.search,
|
||||
// color: Color(0xFFAA8E83),
|
||||
// ),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
border: Border.all(width: 2, color: Color(0xFFAA8E83)),
|
||||
),
|
||||
onChanged: filterUsers,
|
||||
),
|
||||
),
|
||||
SizedBox(height: myheight / 40),
|
||||
filteredUserData.isEmpty
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: myheight/5),
|
||||
|
||||
// Icon(Icons.search,
|
||||
// size: 60, color: Colors.grey),
|
||||
Image.asset(
|
||||
MiscIconAssetPath.group,
|
||||
width: 60,
|
||||
height: 60,
|
||||
),
|
||||
|
||||
SizedBox(height: 15),
|
||||
// Space between icon and text
|
||||
Text(
|
||||
"No results found",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 12), // Space between texts
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"We couldn't find anything matching your search.",
|
||||
style: TextStyle(
|
||||
fontSize: 18, color: Color(0xFF898C81)),
|
||||
textAlign: TextAlign.center,
|
||||
),),
|
||||
],
|
||||
),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: AppLocalizations.of(context)!.search,
|
||||
prefixIcon: Image.asset(
|
||||
MiscIconAssetPath.search,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: MediaQuery.of(context).size.width,
|
||||
// ,prefixIcon: Icon(
|
||||
// Icons.search,
|
||||
// color: Color(0xFFAA8E83),
|
||||
// ),
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 15.0, horizontal: 20.0),
|
||||
),
|
||||
child: DataTable(
|
||||
sortColumnIndex: _sortColumnIndex,
|
||||
sortAscending: _isAscending,
|
||||
columns: [
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.user_name,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort((user) => user.userName.toLowerCase(),
|
||||
columnIndex, ascending);
|
||||
},
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.email_id,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort((user) => user.emailId.toLowerCase(),
|
||||
columnIndex, ascending);
|
||||
},
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.reg_date,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort(
|
||||
(user) => DateFormat('dd/MM/yyyy')
|
||||
.parse(user.registrationDate),
|
||||
columnIndex,
|
||||
ascending,
|
||||
);
|
||||
},
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.status,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort((user) => user.status.toLowerCase(),
|
||||
columnIndex, ascending);
|
||||
},
|
||||
),
|
||||
],
|
||||
rows: filteredUserData.isEmpty
|
||||
? [
|
||||
DataRow(
|
||||
cells: List<DataCell>.generate(
|
||||
4, // Ensure it matches the number of DataColumns
|
||||
(index) => DataCell(
|
||||
index == 0
|
||||
? Text(
|
||||
'No results found',
|
||||
style: TextStyle(
|
||||
fontStyle:
|
||||
FontStyle.italic),
|
||||
)
|
||||
: const Text(
|
||||
''), // Empty cells for other columns
|
||||
placeholder: true,
|
||||
),
|
||||
onChanged: filterUsers,
|
||||
),
|
||||
),
|
||||
SizedBox(height: myheight / 40),
|
||||
filteredUserData.isEmpty
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: myheight / 5),
|
||||
|
||||
// Icon(Icons.search,
|
||||
// size: 60, color: Colors.grey),
|
||||
Image.asset(
|
||||
MiscIconAssetPath.group,
|
||||
width: 60,
|
||||
height: 60,
|
||||
),
|
||||
|
||||
SizedBox(height: 15),
|
||||
// Space between icon and text
|
||||
Text(
|
||||
"No results found",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
]
|
||||
: filteredUserData.map((user) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text(user.userName)),
|
||||
DataCell(Text(user.emailId)),
|
||||
DataCell(Text(user.registrationDate)),
|
||||
DataCell(
|
||||
DropdownButton<String>(
|
||||
value: user.status,
|
||||
items: statusOptions.entries
|
||||
.map((status) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: status.key,
|
||||
child: Text(
|
||||
status.value,
|
||||
style: TextStyle(
|
||||
color: getStatusColor(
|
||||
status.key),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newStatus) {
|
||||
print(user);
|
||||
if (newStatus != null) {
|
||||
_showConfirmationDialog(
|
||||
user, newStatus);
|
||||
}
|
||||
},
|
||||
|
||||
SizedBox(height: 12), // Space between texts
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"We couldn't find anything matching your search.",
|
||||
style: TextStyle(
|
||||
fontSize: 18, color: Color(0xFF898C81)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: MediaQuery.of(context).size.width,
|
||||
),
|
||||
child: DataTable(
|
||||
sortColumnIndex: _sortColumnIndex,
|
||||
sortAscending: _isAscending,
|
||||
columns: [
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.user_name,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort((user) => user.userName.toLowerCase(),
|
||||
columnIndex, ascending);
|
||||
},
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.email_id,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort((user) => user.emailId.toLowerCase(),
|
||||
columnIndex, ascending);
|
||||
},
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.reg_date,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort(
|
||||
(user) => DateFormat('dd/MM/yyyy')
|
||||
.parse(user.registrationDate),
|
||||
columnIndex,
|
||||
ascending,
|
||||
);
|
||||
},
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!.status,
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
_sort((user) => user.status.toLowerCase(),
|
||||
columnIndex, ascending);
|
||||
},
|
||||
),
|
||||
],
|
||||
rows: filteredUserData.isEmpty
|
||||
? [
|
||||
DataRow(
|
||||
cells: List<DataCell>.generate(
|
||||
4, // Ensure it matches the number of DataColumns
|
||||
(index) => DataCell(
|
||||
index == 0
|
||||
? Text(
|
||||
'No results found',
|
||||
style: TextStyle(
|
||||
fontStyle:
|
||||
FontStyle.italic),
|
||||
)
|
||||
: const Text(
|
||||
''), // Empty cells for other columns
|
||||
placeholder: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
: filteredUserData.map((user) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text(user.userName)),
|
||||
DataCell(Text(user.emailId)),
|
||||
DataCell(Text(user.registrationDate)),
|
||||
DataCell(
|
||||
DropdownButton<String>(
|
||||
value: user.status,
|
||||
items: statusOptions.entries
|
||||
.map((status) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: status.key,
|
||||
child: Text(
|
||||
status.value,
|
||||
style: TextStyle(
|
||||
color: getStatusColor(
|
||||
status.key),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newStatus) {
|
||||
print(user);
|
||||
if (newStatus != null) {
|
||||
_showConfirmationDialog(
|
||||
user, newStatus);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ class _UserguideState extends State<Userguide> {
|
||||
dividerColor: Colors.grey[300],
|
||||
appbarColor: Colors.white,
|
||||
title: Padding(
|
||||
padding:EdgeInsets.only(bottom:8.0),
|
||||
padding:EdgeInsets.only(bottom:0.0),
|
||||
child: Text('User Guide'),
|
||||
) ,
|
||||
body: Container(
|
||||
|
||||
@ -14,6 +14,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
|
||||
import 'package:uae_stat/config/injector.dart';
|
||||
import 'package:uae_stat/domain/repos/t_auth_repo.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/bottom_bar_asset_icon_path.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/drawer_asset_icon_path.dart';
|
||||
|
||||
@ -296,7 +297,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
child: Text(
|
||||
// 'Skip',
|
||||
AppLocalizations.of(context)!.skip,
|
||||
style: TextStyle(
|
||||
@ -431,7 +432,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
child: Text(
|
||||
// 'Skip',
|
||||
AppLocalizations.of(context)!.skip,
|
||||
style: TextStyle(
|
||||
@ -489,7 +490,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.got_it,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF7DAFBC),
|
||||
@ -602,18 +603,26 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
// Future<void> logout() async {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// // setState(() {
|
||||
// // isLoggedOut = true;
|
||||
// // });
|
||||
// // prefs.clear();
|
||||
// await _repo.logout();
|
||||
// // state = const AsyncData(null);
|
||||
// // _pb.authStore.clear();
|
||||
// // await _secureStorage.delete(key: "FlutterSecureStorage.session");
|
||||
// prefs.clear();
|
||||
// context.go('/login');
|
||||
// }
|
||||
final PAuthRepo _authRepo = PAuthRepo();
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
// setState(() {
|
||||
// isLoggedOut = true;
|
||||
// });
|
||||
// prefs.clear();
|
||||
await _repo.logout();
|
||||
// state = const AsyncData(null);
|
||||
// _pb.authStore.clear();
|
||||
// await _secureStorage.delete(key: "FlutterSecureStorage.session");
|
||||
await _authRepo.logout();
|
||||
prefs.clear();
|
||||
context.go('/login');
|
||||
context.go('/login'); // Redirect to login after logout
|
||||
}
|
||||
|
||||
@override
|
||||
@ -628,7 +637,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
// title: widget.title,
|
||||
title: Align(
|
||||
title: Align(
|
||||
alignment: Alignment.centerLeft, // Aligns the title to the left
|
||||
child: widget.title,
|
||||
),
|
||||
@ -642,7 +651,8 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
color: widget.dividerColor, // Line color
|
||||
height: 1, // Line thickness
|
||||
),
|
||||
): null,
|
||||
)
|
||||
: null,
|
||||
actions: widget.actions ??
|
||||
[
|
||||
// IconButton(
|
||||
@ -675,7 +685,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
top: 8,
|
||||
right: 10,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
@ -694,177 +704,176 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
),
|
||||
),
|
||||
drawer: Drawer(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
child: Column(children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
|
||||
children: [
|
||||
DrawerHeader(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
DrawerHeader(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: mywidth / 8,
|
||||
child: Image(
|
||||
image: AssetImage('assets/logos/fcsc.png'),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: mywidth / 8,
|
||||
child: Image(
|
||||
image: AssetImage('assets/logos/fcsc.png'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (userId != 'guest') context.go('/editProfile');
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: mywidth / 8,
|
||||
height: mywidth / 8,
|
||||
child: ClipOval(
|
||||
child: _avatarUrl.isNotEmpty
|
||||
? Image(
|
||||
image: NetworkImage(_avatarUrl),
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
)
|
||||
: Image(
|
||||
image: AssetImage(
|
||||
'assets/edit_profile/profile.png',
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
),
|
||||
//child: Image(image: AssetImage('assets/edit_profile/profile.png'))
|
||||
),
|
||||
SizedBox(
|
||||
width: mywidth / 20,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Text(userId ?? 'Loading user...'), // Display userId here
|
||||
// Text('Mohammad@fcsc.com')
|
||||
if (userId == "guest") ...[
|
||||
Text(userName ?? 'Guest User'),
|
||||
] else ...[
|
||||
Text(userName ?? 'Loading...'),
|
||||
Text(
|
||||
userEmail ?? 'Loading...',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (userId != 'guest') context.go('/editProfile');
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: mywidth / 8,
|
||||
height: mywidth / 8,
|
||||
child: ClipOval(
|
||||
child: _avatarUrl.isNotEmpty
|
||||
? Image(
|
||||
image: NetworkImage(_avatarUrl),
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
)
|
||||
: Image(
|
||||
image: AssetImage(
|
||||
'assets/edit_profile/profile.png',
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
),
|
||||
//child: Image(image: AssetImage('assets/edit_profile/profile.png'))
|
||||
),
|
||||
SizedBox(
|
||||
width: mywidth / 20,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Text(userId ?? 'Loading user...'), // Display userId here
|
||||
// Text('Mohammad@fcsc.com')
|
||||
if (userId == "guest") ...[
|
||||
Text(userName ?? 'Guest User'),
|
||||
] else ...[
|
||||
Text(userName ?? 'Loading...'),
|
||||
Text(
|
||||
userEmail ?? 'Loading...',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (userId != 'guest')
|
||||
ListTile(
|
||||
leading: Image.asset(
|
||||
DrawerAssetIconPath.feedback,
|
||||
color: Colors.black,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
// title: const Text('Feedback'),
|
||||
title: Text(AppLocalizations.of(context)!.feedback_title),
|
||||
onTap: () => context.go('/feedback', extra: userName),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (userId != 'guest')
|
||||
ListTile(
|
||||
leading: Image.asset(
|
||||
DrawerAssetIconPath.feedback,
|
||||
color: Colors.black,
|
||||
width: 20,
|
||||
height: 20,
|
||||
if (role == 'admin')
|
||||
ListTile(
|
||||
leading: Image.asset(
|
||||
DrawerAssetIconPath.manageUser,
|
||||
color: Colors.black,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
// title: Text('Manage User'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.manage_user,
|
||||
),
|
||||
onTap: () => context.go('/manageuser'),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.bookmarks_outlined),
|
||||
// title: const Text('Bookmark'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.bookmark_title,
|
||||
),
|
||||
onTap: () => context.go('/bookmark'),
|
||||
),
|
||||
// title: const Text('Feedback'),
|
||||
title: Text(AppLocalizations.of(context)!.feedback_title),
|
||||
onTap: () => context.go('/feedback', extra: userName),
|
||||
),
|
||||
if (role == 'admin')
|
||||
ListTile(
|
||||
leading: Image.asset(
|
||||
DrawerAssetIconPath.manageUser,
|
||||
color: Colors.black,
|
||||
width: 20,
|
||||
height: 20,
|
||||
ListTile(
|
||||
leading: Image.asset(
|
||||
DrawerAssetIconPath.guide,
|
||||
color: Colors.black,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
// title: const Text('User Guide'),
|
||||
title: Text(AppLocalizations.of(context)!.guide_title),
|
||||
onTap: () => context.go('/user-guide'),
|
||||
),
|
||||
// title: Text('Manage User'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.manage_user,
|
||||
),
|
||||
onTap: () => context.go('/manageuser'),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.bookmarks_outlined),
|
||||
// title: const Text('Bookmark'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.bookmark_title,
|
||||
),
|
||||
onTap: () => context.go('/bookmark'),
|
||||
if (userId != 'guest')
|
||||
ListTile(
|
||||
leading: Icon(Icons.logout),
|
||||
// title: const Text('Logout'),
|
||||
title: Text(AppLocalizations.of(context)!.logout),
|
||||
onTap: () => logout(context),
|
||||
),
|
||||
if (userId == 'guest')
|
||||
ListTile(
|
||||
leading: Icon(Icons.login),
|
||||
// title: const Text('Login'),
|
||||
title: Text(AppLocalizations.of(context)!.login_title),
|
||||
onTap: () => context.go('/login'),
|
||||
),
|
||||
if (userId == 'guest')
|
||||
ListTile(
|
||||
leading: Icon(Icons.app_registration),
|
||||
// title: const Text('Register'),
|
||||
title: Text(AppLocalizations.of(context)!.register_title),
|
||||
onTap: () => context.go('/register'),
|
||||
),
|
||||
],
|
||||
),
|
||||
ListTile(
|
||||
leading: Image.asset(
|
||||
DrawerAssetIconPath.guide,
|
||||
color: Colors.black,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
// title: const Text('User Guide'),
|
||||
title: Text(AppLocalizations.of(context)!.guide_title),
|
||||
onTap: () => context.go('/user-guide'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: FutureBuilder<String>(
|
||||
future: _getAppVersion(), // Function to get the app version
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Text(
|
||||
'Loading version...',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(
|
||||
'Error fetching version',
|
||||
style: TextStyle(fontSize: 12, color: Colors.red),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
'Version ${snapshot.data}',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (userId != 'guest')
|
||||
ListTile(
|
||||
leading: Icon(Icons.logout),
|
||||
// title: const Text('Logout'),
|
||||
title: Text(AppLocalizations.of(context)!.logout),
|
||||
onTap: () => logout(),
|
||||
),
|
||||
if (userId == 'guest')
|
||||
ListTile(
|
||||
leading: Icon(Icons.login),
|
||||
// title: const Text('Login'),
|
||||
title: Text(AppLocalizations.of(context)!.login_title),
|
||||
onTap: () => context.go('/login'),
|
||||
),
|
||||
if (userId == 'guest')
|
||||
ListTile(
|
||||
leading: Icon(Icons.app_registration),
|
||||
// title: const Text('Register'),
|
||||
title: Text(AppLocalizations.of(context)!.register_title),
|
||||
onTap: () => context.go('/register'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: FutureBuilder<String>(
|
||||
future: _getAppVersion(), // Function to get the app version
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Text(
|
||||
'Loading version...',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(
|
||||
'Error fetching version',
|
||||
style: TextStyle(fontSize: 12, color: Colors.red),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
'Version ${snapshot.data}',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
])),
|
||||
),
|
||||
])),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
backgroundColor: Colors.white,
|
||||
currentIndex: _getSelectedIndex(currentRoute),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user