bug fix and forgot password

This commit is contained in:
venbaittech 2025-03-27 18:43:32 +05:30
parent a0d7a733a4
commit efb0d38664
11 changed files with 636 additions and 502 deletions

View File

@ -20,12 +20,12 @@ if (project.hasProperty('google-services.json')) {
def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
flutterVersionCode = "43"
flutterVersionCode = "44"
}
def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
flutterVersionName = "1.0.42"
flutterVersionName = "1.0.43"
}
def keystorePropertiesFile = rootProject.file("key.properties")

View File

@ -30,13 +30,27 @@
<meta-data android:name="flutter_deeplinking_enabled"
android:value="true"/>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="www.fcsc.com"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="fcsc-a161c.web.app"
android:scheme="flutterdeeplink"
android:host="fcsc"
android:pathPrefix="/login" />
<data
android:scheme="flutterdeeplink"
android:host="fcsc"
android:pathPrefix="/chartScreen"/>
<data
android:scheme="flutterdeeplink"
android:host="fcsc"
android:pathPrefix="/forgot-password"/>
</intent-filter>
<!-- <intent-filter >-->
<!-- <action android:name="android.intent.action.VIEW" />-->

View File

@ -667,7 +667,8 @@ final GoRouter router = GoRouter(
redirect: (context, state) async {
if (state.uri.path == '/SessionCheckScreen' ||
state.uri.path == '/login' ||
state.uri.path == '/register') {
state.uri.path == '/register' ||
state.uri.path == '/forgot-password/:email') {
return null;
}

View File

@ -240,7 +240,8 @@ class _UaenumberWidgetState extends ConsumerState<uaenumberWidget> {
onChanged: (value) {
filterData(
value); // Call filter function directly on input change
},
}, // Ensures vertical alignment
// Centers text horizontally
decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.search,
hintStyle: TextStyle(color: Color(0xFFAA8E83)),
@ -261,8 +262,9 @@ class _UaenumberWidgetState extends ConsumerState<uaenumberWidget> {
// // fit: BoxFit.contain,
// ),
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(vertical: 9, horizontal: 18.0),
// contentPadding:
// EdgeInsets.symmetric(vertical: 9, horizontal: 18.0),
contentPadding: EdgeInsets.zero,
),
),
),

View File

@ -107,6 +107,66 @@ class _ForgotPasswordState extends ConsumerState<ForgotPassword> {
return null;
}
// Future<void> updatePassword(
// String email, String oldPassword, String newPassword) async {
// print(email);
// try {
// setState(() {
// isLoading = true;
// });
// // Authenticate as admin
// final adminAuth = await _pb.admins
// .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
// final token = adminAuth.token;
//
// final headers = {
// 'Authorization': 'Bearer $token',
// };
//
// // Update password
// await _pb.collection('users').update(
// email,
// body: {
// 'password': newPassword,
// 'passwordConfirm': newPassword,
// },
// headers: headers,
// );
//
// setState(() {
// isLoading = false;
// _isPasswordUpdated = true;
// });
//
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content:
// Text(AppLocalizations.of(context)!.password_update_successfully),
// backgroundColor: Colors.green,
// ),
// );
//
// print('_isPasswordUpdated $_isPasswordUpdated');
//
// // Navigator.push(
// // context,
// // MaterialPageRoute(
// // builder: (context) => ProfileScreen(userId: userId)),
// // );
// } catch (e) {
// setState(() {
// isLoading = false;
// });
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text(context.translate(
// 'Failed to update password: $e', 'فشل في تحديث كلمة المرور')),
// backgroundColor: Colors.red,
// ),
// );
// }
// }
Future<void> updatePassword(
String email, String oldPassword, String newPassword) async {
try {
@ -122,9 +182,27 @@ class _ForgotPasswordState extends ConsumerState<ForgotPassword> {
'Authorization': 'Bearer $token',
};
// Update password
// Step 1: Find User by Email
final result = await _pb.collection('users').getList(
filter: 'email = "$email"',
headers: headers,
);
if (result.items.isEmpty) {
// throw Exception("User not found");
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('User not found'),
backgroundColor: Colors.red,
),
);
}
final userId = result.items.first.id;
// Step 3: Update Password
await _pb.collection('users').update(
email,
userId,
body: {
'password': newPassword,
'passwordConfirm': newPassword,
@ -146,19 +224,14 @@ class _ForgotPasswordState extends ConsumerState<ForgotPassword> {
);
print('_isPasswordUpdated $_isPasswordUpdated');
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => ProfileScreen(userId: userId)),
// );
} catch (e) {
setState(() {
isLoading = false;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(context.translate('Failed to update password: $e','فشل في تحديث كلمة المرور')),
content: Text('Failed to update password: $e'),
backgroundColor: Colors.red,
),
);

View File

@ -2695,50 +2695,54 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
}
}
Future<void> shareCurrentPage(BuildContext context, bool _isSharing) async {
if (_isSharing) return; // Prevent multiple taps
Future<void> shareCurrentPage(BuildContext context, bool isSharing) async {
if (isSharing) return; // Prevent multiple taps
_isSharing = true;
isSharing = true;
try {
final String currentRoute = GoRouterState.of(context).uri.toString();
final String baseAppLink = 'https://fcsc-a161c.web.app';
final String baseAppLink = 'https://www.fcsc.com';
final String shareLink = '$baseAppLink$currentRoute';
final String shareText = 'Check this out!';
final String svgAssetPath = 'assets/backgrounds/share/fcsc.svg';
final String shareText = 'Check this out!\n\n$shareLink';
print('Generated Share Link: $shareLink');
// Optional: Capture SVG to image
final String svgAssetPath = 'assets/backgrounds/share/fcsc.svg';
final screenshotController = ScreenshotController();
final svgWidget = SvgPicture.asset(
svgAssetPath,
width: 200,
height: 200,
);
final Uint8List? capturedImage =
await screenshotController.captureFromWidget(
Material(child: svgWidget),
);
if (capturedImage == null) {
throw Exception('Failed to capture SVG as image');
print('SVG capture failed, proceeding without image.');
await Share.share(shareText, subject: 'App Link');
} else {
final directory = await getTemporaryDirectory();
final file = File('${directory.path}/share_image.png');
await file.writeAsBytes(capturedImage);
await Share.shareXFiles(
[XFile(file.path)],
text: shareText,
subject: 'Shared Content',
);
await file.delete();
}
final directory = await getTemporaryDirectory();
final file = File('${directory.path}/share.svg');
await file.writeAsBytes(capturedImage);
await Share.shareXFiles(
[XFile(file.path)],
text: '$shareText\n$shareLink',
subject: 'Shared Content',
);
await file.delete();
} catch (e) {
print("Error sharing file: $e");
print("Error sharing content: $e");
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Error sharing: $e')),
SnackBar(content: Text('Error sharing: ${e.toString()}')),
);
} finally {
_isSharing = false; // Reset flag after sharing completes
isSharing = false; // Reset flag
}
}

File diff suppressed because it is too large Load Diff

View File

@ -702,6 +702,8 @@ class LoginRoute extends HookConsumerWidget {
);
final dontHaveAnAccountRegisterBtn = TextButton(
onPressed: () => {context.push('/register')},
// onPressed: () =>
// {context.push('/forgot-password/surendar.m@venbainfotech.com')},
child: Text.rich(
textAlign: TextAlign.center,
TextSpan(

View File

@ -152,7 +152,9 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
isLoading = false;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(AppLocalizations.of(context)!.status_success),),
SnackBar(
content: Text(AppLocalizations.of(context)!.status_success),
),
);
} catch (e) {
setState(() {
@ -160,13 +162,16 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
});
Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.translate('Error updating status: $e','$e خطأ في تحديث الحالة: '))),
SnackBar(
content: Text(context.translate(
'Error updating status: $e', '$e خطأ في تحديث الحالة: '))),
);
}
}
//Method to show a confirmation dialog when status is changed
Future<void> _showConfirmationDialog(User user, String newStatus,String statusUpdate) async {
Future<void> _showConfirmationDialog(
User user, String newStatus, String statusUpdate) async {
print('user $user');
double myheight = MediaQuery.of(context).size.height;
@ -416,8 +421,9 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
// // fit: BoxFit.contain,
// ),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
vertical: 9, horizontal: 18.0),
// contentPadding: EdgeInsets.symmetric(
// vertical: 9, horizontal: 18.0),
contentPadding: EdgeInsets.zero,
),
onChanged: filterUsers,
),
@ -444,7 +450,8 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
SizedBox(height: 15),
// Space between icon and text
Text(
AppLocalizations.of(context)!.no_result_found,
AppLocalizations.of(context)!
.no_result_found,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
@ -455,7 +462,9 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
SizedBox(height: 12), // Space between texts
FittedBox(
child: Text(
context.translate("We couldn't find anything matching your search.",'لم نعثر على أي شيء يطابق بحثك.'),
context.translate(
"We couldn't find anything matching your search.",
'لم نعثر على أي شيء يطابق بحثك.'),
style: TextStyle(
fontSize: 18,
color: Color(0xFF898C81)),
@ -533,7 +542,9 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
(index) => DataCell(
index == 0
? Text(
AppLocalizations.of(context)!.no_result_found,
AppLocalizations.of(
context)!
.no_result_found,
style: TextStyle(
fontStyle: FontStyle
.italic),
@ -573,7 +584,11 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
print(user);
if (newStatus != null) {
_showConfirmationDialog(
user, newStatus, statusOptions[newStatus]!,);
user,
newStatus,
statusOptions[
newStatus]!,
);
}
},
),

View File

@ -298,7 +298,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
createTargetContent(
text: AppLocalizations.of(context)!.mainMenu,
alignment: ContentAlign.bottom,
space:55,
space: 55,
gap: 55,
),
TargetContent(
@ -989,7 +989,9 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
),
ListTile(
leading: Icon(Icons.mail_outlined),
title: Text(context.translate('Contact Us', 'اتصل بنا'),),
title: Text(
context.translate('Contact Us', 'اتصل بنا'),
),
onTap: () => context.push('/contact'),
),
if (userId != 'guest')

View File

@ -1,7 +1,7 @@
name: uae_stat
description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness."
publish_to: "none"
version: 1.0.42+43
version: 1.0.43+44
environment:
sdk: ">=3.2.3 <4.0.0"