diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 4e74a35d..a570820b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ + { ), ), SizedBox(width: 5), - Stack( - children: [ - // Image.asset( - // UaeNumbersAssetPath.shareUae, - // color: Colors.white, // Outline color - // width: 24, // Slightly larger - // height: 24, - // ), - // Image.asset( - // UaeNumbersAssetPath.shareUae, - // color: Colors.white, - // width: 24, - // height: 24, - // ), - GestureDetector( - onTap: () async { - try { - final svgAssetPath = 'assets/images/sample.svg'; // Update with your actual path - final directory = await getTemporaryDirectory(); - final file = File('${directory.path}/shared_image.svg'); + GestureDetector( + onTap: () async { + try { + // Define share content + final String shareLink = 'https://fcsc-da580.web.app'; // Your link + final String shareText = 'Check this out!'; + final String svgAssetPath = 'assets/logos/fcsc.png'; // Your SVG asset path - // Load the SVG asset and write to the temp file - final svgData = await DefaultAssetBundle.of(context).loadString(svgAssetPath); - await file.writeAsString(svgData); + // Create a controller to capture the SVG as an image + final screenshotController = ScreenshotController(); - // Share the file - await Share.shareXFiles([XFile(file.path)], text: "Check this out!"); - } catch (e) { - print("Error sharing file: $e"); - } - }, - child: SvgPicture.asset( - UaeNumbersAssetPath.share, - semanticsLabel: 'share', - width: 24, - height: 24, - ), - ) + // Render the SVG off-screen and capture it as PNG + final svgWidget = SvgPicture.asset( + svgAssetPath, + width: 200, // Adjust size as needed + height: 200, + ); + // Capture the SVG as a PNG + final Uint8List? capturedImage = await screenshotController.captureFromWidget( + Material( + child: svgWidget, + ), + ); + if (capturedImage == null) { + throw Exception('Failed to capture SVG as image'); + } - // SvgPicture.asset( - // UaeNumbersAssetPath.share, - // semanticsLabel: 'share', - // width: 24, - // height: 24, - // ), - ], - ) + // Save the captured PNG to a temporary file + final directory = await getTemporaryDirectory(); + final file = File('${directory.path}/shared_image.png'); + await file.writeAsBytes(capturedImage); + + // Share the PNG file with text and link + await Share.shareXFiles( + [XFile(file.path)], + text: '$shareText\n$shareLink', + subject: 'Shared Content', + ); + + // Clean up temporary file + await file.delete(); + } catch (e) { + print("Error sharing file: $e"); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Error sharing: $e')), + ); + } + }, + child: Container( + width: 24, + height: 24, + child: Icon( + Icons.share, + color: Colors.white, + size: 24, + semanticLabel: 'Share', + ), + ), + ), ], ), SizedBox( diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart index 42280b3b..bbc2e6c4 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart @@ -544,7 +544,7 @@ class _EditProfileState extends State { ? NetworkImage( _avatarUrl) // Load from URL : AssetImage( - 'assets/edit_profile/profile.png') + 'assets/edit_profile/profile.jpg') as ImageProvider, child: _avatarUrl.isNotEmpty ? FutureBuilder( diff --git a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart index 52ade75c..0811419e 100644 --- a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart +++ b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart @@ -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/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/bottom_bar_asset_icon_path.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/drawer_asset_icon_path.dart'; @@ -787,7 +788,7 @@ class _BaseScaffoldState extends ConsumerState { ) : Image( image: AssetImage( - 'assets/edit_profile/profile.png', + 'assets/edit_profile/profile.jpg', ), fit: BoxFit.cover, width: double.infinity, @@ -912,7 +913,7 @@ class _BaseScaffoldState extends ConsumerState { leading: Icon(Icons.logout), // title: const Text('Logout'), title: Text(AppLocalizations.of(context)!.logout), - onTap: () => logout(context), + onTap: () => _showLogoutConfirmationDialog(context), ), if (userId == 'guest') ListTile( @@ -1084,3 +1085,85 @@ class _BaseScaffoldState extends ConsumerState { } } } +void _showLogoutConfirmationDialog(context) { + double myheight = MediaQuery.of(context).size.height; + showDialog( + context: context, + barrierDismissible: false, // User must tap a button to dismiss dialog + builder: (context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), // Rounded corners + ), + contentPadding: EdgeInsets.zero, + title: Text( + context.translate('Log Out Confirmation', 'تأكيد تسجيل الخروج'), + textAlign: TextAlign.center, + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + content: Padding( + padding: const EdgeInsets.all(20.0), + child: Text( + context.translate( + 'Are you sure you want to log out?', + 'هل أنت متأكد أنك تريد تسجيل الخروج؟'), + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 18, + color: Color(0xFF898C81), + ), + ), + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, // Space buttons evenly + children: [ + SizedBox( + width: 120, // Set button width + child: TextButton( + onPressed: () => Navigator.pop(context), + style: TextButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + side: BorderSide( + color: Color(0xFFAA8E83), // Border color + width: 1, + ), + ), + child: Text( + context.translate('Cancel', 'إلغاء'), + style: TextStyle( + color: Color(0xFFAA8E83), + fontSize: 16, + ), + ), + ), + ), + SizedBox( + width: 120, // Set button width + child: TextButton( + onPressed: () { + Navigator.pop(context); + // Add logout function here + }, + style: TextButton.styleFrom( + backgroundColor: Color(0xFFAA8E83), // Background color + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + ), + child: Text( + context.translate('Log Out', 'تسجيل الخروج'), + style: TextStyle(color: Colors.white, fontSize: 16), + ), + ), + ), + ], + ), + SizedBox(height: 10), // Add spacing below buttons + ], + ), + ); +} + diff --git a/pubspec.lock b/pubspec.lock index 1bdd3452..a90e1d09 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1177,6 +1177,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.28.0" + screenshot: + dependency: "direct main" + description: + name: screenshot + sha256: "63817697a7835e6ce82add4228e15d233b74d42975c143ad8cfe07009fab866b" + url: "https://pub.dev" + source: hosted + version: "3.0.0" sdmx: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b9904725..b5dfb3ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: marquee: ^2.2.3 url_launcher: ^6.3.1 path_provider: ^2.1.5 + screenshot: ^3.0.0 # dynamic_layouts: # git: # url: https://github.com/flutter/packages.git