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(),
|
||||
),
|
||||
);
|
||||
|
||||
@ -336,11 +336,14 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
|
||||
body:
|
||||
|
||||
Column(
|
||||
return PopScope(
|
||||
canPop: false, // Allow back navigation only if not login screen
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
context.go('/login'); // Show exit confirmation dialog
|
||||
},
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
@ -371,9 +374,7 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height / 1.2,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children : [
|
||||
|
||||
child: Column(children: [
|
||||
registrationSuccess
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
@ -381,7 +382,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: screenheight / 8),
|
||||
buildIconContainer(Icons.report, Color(0xFF7DAFBC)),
|
||||
buildIconContainer(
|
||||
Icons.report, Color(0xFF7DAFBC)),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
context.translate(
|
||||
@ -408,7 +410,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
ElevatedButton(
|
||||
onPressed: () => {context.go('/')},
|
||||
child: Text(
|
||||
context.translate('Go to Login', 'اذهب إلى تسجيل الدخول'),
|
||||
context.translate(
|
||||
'Go to Login', 'اذهب إلى تسجيل الدخول'),
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenheight / 5),
|
||||
@ -437,7 +440,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
buildIconContainer(Icons.report, Colors.red),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
context.translate('Sorry ${_usernameController.text}!',
|
||||
context.translate(
|
||||
'Sorry ${_usernameController.text}!',
|
||||
'آسف ${_usernameController.text}!'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
@ -470,7 +474,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
})
|
||||
},
|
||||
child: Text(
|
||||
context.translate('Retry', 'أعد المحاولة'),
|
||||
context.translate(
|
||||
'Retry', 'أعد المحاولة'),
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenheight / 5),
|
||||
@ -489,7 +494,6 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
@ -499,32 +503,41 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
SizedBox(height: screenheight / 60),
|
||||
Text(
|
||||
// 'Register',
|
||||
AppLocalizations.of(context)!.register_title,
|
||||
AppLocalizations.of(context)!
|
||||
.register_title,
|
||||
style: TextStyle(
|
||||
fontSize: 32, fontWeight: FontWeight.w400),
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(AppLocalizations.of(context)!.register_details),
|
||||
Text(AppLocalizations.of(context)!
|
||||
.register_details),
|
||||
|
||||
SizedBox(height: 20),
|
||||
// Display this if registration is pending approval
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5.0, bottom: 10, left: 30, right: 30),
|
||||
top: 5.0,
|
||||
bottom: 10,
|
||||
left: 30,
|
||||
right: 30),
|
||||
child: TextFormField(
|
||||
controller: _usernameController,
|
||||
// focusNode: _focusNodes[0],
|
||||
decoration: InputDecoration(
|
||||
// hintText: _showHints[0] ? 'Username' : null,
|
||||
hintText: _showHints[0]
|
||||
? AppLocalizations.of(context)!.register_name
|
||||
? AppLocalizations.of(context)!
|
||||
.register_name
|
||||
: null,
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
prefixIconConstraints:
|
||||
const BoxConstraints(
|
||||
maxWidth: 25 + 16 + 10,
|
||||
maxHeight: 25 + (8 * 2),
|
||||
),
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
padding: const EdgeInsetsDirectional
|
||||
.only(
|
||||
start: 16,
|
||||
end: 10,
|
||||
),
|
||||
@ -533,8 +546,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
fit: BoxFit.fitHeight,
|
||||
height: 25,
|
||||
width: 25,
|
||||
color:
|
||||
MyTheme.topicColor(IndicatorTopic.economy)
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
.shade300,
|
||||
),
|
||||
),
|
||||
@ -546,7 +559,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
// ),
|
||||
// border: OutlineInputBorder(),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
@ -554,38 +568,52 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
width: 1), // Enabled border
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.deepPurple,
|
||||
width: 2), // Focused border
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Error border
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
focusedErrorBorder:
|
||||
OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Match the error color
|
||||
width:
|
||||
1), // Match the error color
|
||||
),
|
||||
counterText: '',
|
||||
hintStyle: TextStyle(color: Color(0xFFC3C6CB),
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 14 : 16,
|
||||
hintStyle: TextStyle(
|
||||
color: Color(0xFFC3C6CB),
|
||||
fontSize:
|
||||
registerLocale?.languageCode ==
|
||||
'ar'
|
||||
? 14
|
||||
: 16,
|
||||
),
|
||||
),
|
||||
validator: _validateUsername,
|
||||
maxLength:
|
||||
40, // Set the maximum length to 20 characters
|
||||
maxLengthEnforcement: MaxLengthEnforcement.enforced,
|
||||
maxLengthEnforcement:
|
||||
MaxLengthEnforcement.enforced,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5.0, bottom: 10, left: 30, right: 30),
|
||||
top: 5.0,
|
||||
bottom: 10,
|
||||
left: 30,
|
||||
right: 30),
|
||||
child: TextFormField(
|
||||
controller: _emailController,
|
||||
// focusNode: _focusNodes[1],
|
||||
@ -596,12 +624,14 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
.enter_your_email
|
||||
: null,
|
||||
// _showHints[1] ? 'Enter your email' : null,
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
prefixIconConstraints:
|
||||
const BoxConstraints(
|
||||
maxWidth: 25 + 16 + 10,
|
||||
maxHeight: 25 + (8 * 2),
|
||||
),
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
padding: const EdgeInsetsDirectional
|
||||
.only(
|
||||
start: 16,
|
||||
end: 10,
|
||||
),
|
||||
@ -610,15 +640,16 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
fit: BoxFit.fitHeight,
|
||||
height: 20,
|
||||
width: 25,
|
||||
color:
|
||||
MyTheme.topicColor(IndicatorTopic.economy)
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
.shade100,
|
||||
),
|
||||
),
|
||||
|
||||
// border: OutlineInputBorder(),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
@ -626,31 +657,42 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
width: 1),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.deepPurple,
|
||||
width: 2), // Focused border
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Error border
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
focusedErrorBorder:
|
||||
OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Match the error color
|
||||
width:
|
||||
1), // Match the error color
|
||||
),
|
||||
counterText: '',
|
||||
hintStyle: TextStyle(color: Color(0xFFC3C6CB),
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 14 : 16,
|
||||
hintStyle: TextStyle(
|
||||
color: Color(0xFFC3C6CB),
|
||||
fontSize:
|
||||
registerLocale?.languageCode ==
|
||||
'ar'
|
||||
? 14
|
||||
: 16,
|
||||
),
|
||||
),
|
||||
validator: _validateEmail,
|
||||
maxLength: 320,
|
||||
maxLengthEnforcement: MaxLengthEnforcement.enforced,
|
||||
maxLengthEnforcement:
|
||||
MaxLengthEnforcement.enforced,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(
|
||||
320), // Limit to 320 characters
|
||||
@ -660,7 +702,10 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
SizedBox(height: 15),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5.0, bottom: 10, left: 30, right: 30),
|
||||
top: 5.0,
|
||||
bottom: 10,
|
||||
left: 30,
|
||||
right: 30),
|
||||
child: TextFormField(
|
||||
controller: _passwordController,
|
||||
// focusNode: _focusNodes[2],
|
||||
@ -671,12 +716,14 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
.enter_your_password
|
||||
: null,
|
||||
// _showHints[2] ? 'Enter your password' : null,
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
prefixIconConstraints:
|
||||
const BoxConstraints(
|
||||
maxWidth: 25 + 16 + 10,
|
||||
maxHeight: 25 + (8 * 2),
|
||||
),
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
padding: const EdgeInsetsDirectional
|
||||
.only(
|
||||
start: 16,
|
||||
end: 10,
|
||||
),
|
||||
@ -685,8 +732,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
fit: BoxFit.fitHeight,
|
||||
height: 25,
|
||||
width: 25,
|
||||
color:
|
||||
MyTheme.topicColor(IndicatorTopic.economy)
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
.shade300,
|
||||
),
|
||||
),
|
||||
@ -705,7 +752,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
|
||||
icon: Image.asset(
|
||||
_obscurePassword
|
||||
? MiscIconAssetPath.visibilityOff
|
||||
? MiscIconAssetPath
|
||||
.visibilityOff
|
||||
: MiscIconAssetPath.visibleOn,
|
||||
|
||||
color: Color(
|
||||
@ -716,13 +764,15 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
_obscurePassword =
|
||||
!_obscurePassword;
|
||||
});
|
||||
},
|
||||
),
|
||||
// border: OutlineInputBorder(),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
@ -730,38 +780,52 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
width: 1),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.deepPurple,
|
||||
width: 2), // Focused border
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Error border
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
focusedErrorBorder:
|
||||
OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Match the error color
|
||||
width:
|
||||
1), // Match the error color
|
||||
),
|
||||
|
||||
counterText: '',
|
||||
hintStyle: TextStyle(color: Color(0xFFC3C6CB),
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 14 : 16,
|
||||
hintStyle: TextStyle(
|
||||
color: Color(0xFFC3C6CB),
|
||||
fontSize:
|
||||
registerLocale?.languageCode ==
|
||||
'ar'
|
||||
? 14
|
||||
: 16,
|
||||
),
|
||||
),
|
||||
validator: _validatePassword,
|
||||
maxLength: 40,
|
||||
maxLengthEnforcement: MaxLengthEnforcement.enforced,
|
||||
maxLengthEnforcement:
|
||||
MaxLengthEnforcement.enforced,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5.0, bottom: 10, left: 30, right: 30),
|
||||
top: 5.0,
|
||||
bottom: 10,
|
||||
left: 30,
|
||||
right: 30),
|
||||
child: TextFormField(
|
||||
controller: _confirmpasswordController,
|
||||
// focusNode: _focusNodes[3],
|
||||
@ -772,12 +836,14 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
.register_Confirm_password
|
||||
: null,
|
||||
// _showHints[3] ? 'Confirm password' : null,
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
prefixIconConstraints:
|
||||
const BoxConstraints(
|
||||
maxWidth: 25 + 16 + 10,
|
||||
maxHeight: 25 + (8 * 2),
|
||||
),
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
padding: const EdgeInsetsDirectional
|
||||
.only(
|
||||
start: 16,
|
||||
end: 10,
|
||||
),
|
||||
@ -786,8 +852,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
fit: BoxFit.fitHeight,
|
||||
height: 25,
|
||||
width: 25,
|
||||
color:
|
||||
MyTheme.topicColor(IndicatorTopic.economy)
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
.shade300,
|
||||
),
|
||||
),
|
||||
@ -795,7 +861,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
suffixIcon: IconButton(
|
||||
icon: Image.asset(
|
||||
_obscureConfirmPassword
|
||||
? MiscIconAssetPath.visibilityOff
|
||||
? MiscIconAssetPath
|
||||
.visibilityOff
|
||||
: MiscIconAssetPath.visibleOn,
|
||||
|
||||
color: Color(
|
||||
@ -814,7 +881,8 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
// borderSide: BorderSide(color: Colors.blue, width: 2), // Default border color
|
||||
// ),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: MyTheme.topicColor(
|
||||
IndicatorTopic.economy)
|
||||
@ -822,31 +890,42 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
width: 1),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.deepPurple,
|
||||
width: 2), // Focused border
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Error border
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
focusedErrorBorder:
|
||||
OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFb22222),
|
||||
width: 1), // Match the error color
|
||||
width:
|
||||
1), // Match the error color
|
||||
),
|
||||
counterText: '',
|
||||
hintStyle: TextStyle(color: Color(0xFFC3C6CB),
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 14 : 16,
|
||||
hintStyle: TextStyle(
|
||||
color: Color(0xFFC3C6CB),
|
||||
fontSize:
|
||||
registerLocale?.languageCode ==
|
||||
'ar'
|
||||
? 14
|
||||
: 16,
|
||||
),
|
||||
),
|
||||
validator: _validateConfirmPassword,
|
||||
maxLength: 40,
|
||||
maxLengthEnforcement: MaxLengthEnforcement.enforced,
|
||||
maxLengthEnforcement:
|
||||
MaxLengthEnforcement.enforced,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(
|
||||
64), // Limit to 40 characters
|
||||
@ -856,9 +935,13 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
SizedBox(height: 10),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0, bottom: 10, left: 25, right: 30),
|
||||
top: 0,
|
||||
bottom: 10,
|
||||
left: 25,
|
||||
right: 30),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: isChecked,
|
||||
@ -877,54 +960,82 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top:11.0),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 11.0),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(context)!.agree,
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.agree,
|
||||
// text: 'I agree to ',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF898C81), // Change to your desired color
|
||||
color: Color(
|
||||
0xFF898C81), // Change to your desired color
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(context)!
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.terms_conditions,
|
||||
// text: 'Terms & Conditions',
|
||||
style: TextStyle(
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 12 : 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF985400),
|
||||
fontSize: registerLocale
|
||||
?.languageCode ==
|
||||
'ar'
|
||||
? 12
|
||||
: 14,
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
color:
|
||||
Color(0xFF985400),
|
||||
// Makes the text bold
|
||||
// decoration:
|
||||
// TextDecoration.underline,
|
||||
decorationColor: Color(0xFF985400),
|
||||
decorationThickness: 1),
|
||||
decorationColor:
|
||||
Color(0xFF985400),
|
||||
decorationThickness:
|
||||
1),
|
||||
),
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(context)!
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.t_and,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF898C81), // Change to your desired color
|
||||
),),
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(context)!
|
||||
.privacy_policy,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 12 : 14,
|
||||
fontFamily: 'Roboto',
|
||||
color: Color(0xFF985400),
|
||||
// decoration:
|
||||
// TextDecoration.underline,
|
||||
decorationColor: Color(0xFF648CBA),
|
||||
decorationThickness: 1),
|
||||
color: Color(
|
||||
0xFF898C81), // Change to your desired color
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(context)!
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.privacy_policy,
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: registerLocale
|
||||
?.languageCode ==
|
||||
'ar'
|
||||
? 12
|
||||
: 14,
|
||||
fontFamily: 'Roboto',
|
||||
color:
|
||||
Color(0xFF985400),
|
||||
// decoration:
|
||||
// TextDecoration.underline,
|
||||
decorationColor:
|
||||
Color(0xFF648CBA),
|
||||
decorationThickness:
|
||||
1),
|
||||
),
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.conditions,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF898C81), // Change to your desired color
|
||||
),),
|
||||
color: Color(
|
||||
0xFF898C81), // Change to your desired color
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -935,15 +1046,21 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
),
|
||||
if (showError)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 30.0),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 30.0),
|
||||
child: Text(
|
||||
'Required',
|
||||
style: TextStyle(
|
||||
color: Color(0xFFb22222),
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 12 : 14,
|
||||
fontSize: registerLocale
|
||||
?.languageCode ==
|
||||
'ar'
|
||||
? 12
|
||||
: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -952,16 +1069,22 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5.0, bottom: 10, left: 30, right: 30),
|
||||
top: 5.0,
|
||||
bottom: 10,
|
||||
left: 30,
|
||||
right: 30),
|
||||
child: SizedBox(
|
||||
width: screenwidth / 1,
|
||||
child: ElevatedButton(
|
||||
onPressed: isRegistering ? null : _registerUser,
|
||||
onPressed: isRegistering
|
||||
? null
|
||||
: _registerUser,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Color(
|
||||
0xFFA7887A), // Brownish color for Register
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@ -972,7 +1095,11 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
AppLocalizations.of(context)!
|
||||
.register_title,
|
||||
style: TextStyle(
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 14 : 16,
|
||||
fontSize: registerLocale
|
||||
?.languageCode ==
|
||||
'ar'
|
||||
? 14
|
||||
: 16,
|
||||
color: Colors.white),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
@ -988,15 +1115,23 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.account_confirmation,
|
||||
AppLocalizations.of(context)!
|
||||
.account_confirmation,
|
||||
style: TextStyle(
|
||||
fontSize: registerLocale?.languageCode == 'ar' ? 12 : 14,
|
||||
fontSize:
|
||||
registerLocale?.languageCode ==
|
||||
'ar'
|
||||
? 12
|
||||
: 14,
|
||||
color: Colors.grey[600]),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5.0, bottom: 10, left: 30, right: 30),
|
||||
top: 5.0,
|
||||
bottom: 10,
|
||||
left: 30,
|
||||
right: 30),
|
||||
child: SizedBox(
|
||||
width: screenwidth / 1,
|
||||
child: ElevatedButton(
|
||||
@ -1007,16 +1142,19 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
backgroundColor: Color(
|
||||
0xFF82AFCB), // Blueish color for Login
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.login_title,
|
||||
AppLocalizations.of(context)!
|
||||
.login_title,
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: Colors.white),
|
||||
fontSize: 16,
|
||||
color: Colors.white),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
const Icon(
|
||||
@ -1026,28 +1164,6 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
// child: GestureDetector(
|
||||
// onTap: () {
|
||||
// // Navigate to LoginRoute
|
||||
// context.go('/');
|
||||
// },
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Login",
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(width: 8),
|
||||
// Icon(Icons.arrow_forward,
|
||||
// color: Colors.white),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -1078,6 +1194,7 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(
|
||||
@ -646,16 +698,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: AppLocalizations.of(
|
||||
context)!
|
||||
.agree,
|
||||
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,
|
||||
)!
|
||||
.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,16 +698,28 @@ 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(
|
||||
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"),
|
||||
@ -755,8 +756,7 @@ AppLocalizations.of(context)!.feedback_message,
|
||||
content: Text(
|
||||
AppLocalizations.of(context)!.formError,
|
||||
// "Please correct the errors before submitting."
|
||||
)
|
||||
),
|
||||
)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -798,12 +798,11 @@ AppLocalizations.of(context)!.feedback_message,
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(
|
||||
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,8 +176,7 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 100, // Set the desired width
|
||||
child:
|
||||
TextButton(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(); // Close dialog without changing status
|
||||
@ -191,16 +191,18 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
width: 1, // Set the border width
|
||||
),
|
||||
),
|
||||
child: Text(AppLocalizations.of(context)!.no,
|
||||
style: TextStyle(color: Color(0xFFAA8E83),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.no,
|
||||
style: TextStyle(
|
||||
color: Color(0xFFAA8E83),
|
||||
fontSize: 16,
|
||||
),),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 100, // Set the desired width
|
||||
child:
|
||||
TextButton(
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
// Update status in PocketBase
|
||||
@ -219,7 +221,8 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
// });
|
||||
fetchUnverifiedUsers();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Status updated successfully!')),
|
||||
SnackBar(
|
||||
content: Text('Status updated successfully!')),
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
@ -229,7 +232,8 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Color(0xFFAA8E83), // Set background color
|
||||
backgroundColor:
|
||||
Color(0xFFAA8E83), // Set background color
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
@ -239,10 +243,10 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
child: Text(
|
||||
// 'Yes',
|
||||
AppLocalizations.of(context)!.yes,
|
||||
style: TextStyle(color: Colors.white,
|
||||
fontSize: 16),
|
||||
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"),
|
||||
@ -305,8 +310,8 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
// color: Color(0xFFAA8E83),
|
||||
// ),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 15.0, horizontal: 20.0),
|
||||
),
|
||||
onChanged: filterUsers,
|
||||
),
|
||||
@ -347,7 +352,8 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
style: TextStyle(
|
||||
fontSize: 18, color: Color(0xFF898C81)),
|
||||
textAlign: TextAlign.center,
|
||||
),),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -602,18 +603,26 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
// setState(() {
|
||||
// isLoggedOut = true;
|
||||
// });
|
||||
// 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();
|
||||
await _repo.logout();
|
||||
// state = const AsyncData(null);
|
||||
// _pb.authStore.clear();
|
||||
// await _secureStorage.delete(key: "FlutterSecureStorage.session");
|
||||
// context.go('/login');
|
||||
// }
|
||||
final PAuthRepo _authRepo = PAuthRepo();
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await _authRepo.logout();
|
||||
prefs.clear();
|
||||
context.go('/login');
|
||||
context.go('/login'); // Redirect to login after logout
|
||||
}
|
||||
|
||||
@override
|
||||
@ -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) {
|
||||
@ -698,7 +708,6 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
child: Column(children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
|
||||
children: [
|
||||
DrawerHeader(
|
||||
child: Column(
|
||||
@ -818,7 +827,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
leading: Icon(Icons.logout),
|
||||
// title: const Text('Logout'),
|
||||
title: Text(AppLocalizations.of(context)!.logout),
|
||||
onTap: () => logout(),
|
||||
onTap: () => logout(context),
|
||||
),
|
||||
if (userId == 'guest')
|
||||
ListTile(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user