diff --git a/assets/icons/bookmark/delete.svg b/assets/icons/bookmark/delete.svg
new file mode 100644
index 00000000..daf0bcd5
--- /dev/null
+++ b/assets/icons/bookmark/delete.svg
@@ -0,0 +1,4 @@
+
diff --git a/lib/infrastructure/services/img_asset_paths/icons/bookmark_asset_path.dart b/lib/infrastructure/services/img_asset_paths/icons/bookmark_asset_path.dart
new file mode 100644
index 00000000..d6b59b45
--- /dev/null
+++ b/lib/infrastructure/services/img_asset_paths/icons/bookmark_asset_path.dart
@@ -0,0 +1,4 @@
+abstract class BookmarkAssetPath {
+ static const _basePath = 'assets/icons/bookmark';
+ static const delete = '$_basePath/delete.svg';
+}
\ No newline at end of file
diff --git a/lib/presentation/Screens/charts/screens/chart_screen.dart b/lib/presentation/Screens/charts/screens/chart_screen.dart
index 2bab742c..17943f2f 100644
--- a/lib/presentation/Screens/charts/screens/chart_screen.dart
+++ b/lib/presentation/Screens/charts/screens/chart_screen.dart
@@ -319,103 +319,103 @@ class _ChartScreen1State extends ConsumerState {
}
//when the popup need for bookmark
- // void showAddBookmarkDialog() {
- // double myheight = MediaQuery.of(context).size.height;
- // showDialog(
- // context: context,
- // barrierDismissible: false, // User must tap button to dismiss dialog
- // builder: (context) => AlertDialog(
- // shape: RoundedRectangleBorder(
- // borderRadius: BorderRadius.circular(5.0), // Rounded corners
- // ),
- // contentPadding: EdgeInsets.zero,
- // content: Stack(
- // children: [
- // Padding(
- // padding: const EdgeInsets.all(10.0),
- // child: Column(
- // mainAxisSize: MainAxisSize.min,
- // children: [
- // SizedBox(
- // height: myheight / 30,
- // ),
- // Text(
- // context.translate(
- // 'Do you want to add this to bookmarks?',
- // 'هل تريد إضافة هذا إلى الإشارات المرجعية؟',
- // ),
- // textAlign: TextAlign.center,
- // style: TextStyle(
- // fontSize: 18,
- // color: Color(0xFF898C81),
- // ),
- // )
- // ],
- // ),
- // ),
- // ],
- // ),
- // actions: [
- // SizedBox(height: 20),
- // SizedBox(
- // width: 100, // Set the desired width
- // child: TextButton(
- // onPressed: () => Navigator.pop(context),
- // 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
- // ),
- // ),
- // child: Text(
- // context.translate('No', 'لا'),
- // style: TextStyle(
- // color: Color(0xFFAA8E83),
- // fontSize: 16,
- // ),
- // ),
- // ),
- // ),
- // SizedBox(
- // width: 100, // Set the desired width
- // child: TextButton(
- // onPressed: () {
- // Navigator.pop(context);
- // addBookmark(); // 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(
- // context.translate('Yes', 'نعم'),
- // style: TextStyle(color: Colors.white, fontSize: 16),
- // ),
- // ),
- // ),
- // ],
- // ),
- // );
- // }
void showAddBookmarkDialog() {
- addBookmark();
- // ScaffoldMessenger.of(context).showSnackBar(
- // SnackBar(
- // content: Text(
- // 'The bookmark is added successfully',
- // ),
- // backgroundColor: Colors.green,
- // duration: Duration(seconds: 2),
- // ),
- // );
+ double myheight = MediaQuery.of(context).size.height;
+ showDialog(
+ context: context,
+ barrierDismissible: false, // User must tap button to dismiss dialog
+ builder: (context) => AlertDialog(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(5.0), // Rounded corners
+ ),
+ contentPadding: EdgeInsets.zero,
+ content: Stack(
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(10.0),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ SizedBox(
+ height: myheight / 30,
+ ),
+ Text(
+ context.translate(
+ 'Do you want to add this to bookmarks?',
+ 'هل تريد إضافة هذا إلى الإشارات المرجعية؟',
+ ),
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 18,
+ color: Color(0xFF898C81),
+ ),
+ )
+ ],
+ ),
+ ),
+ ],
+ ),
+ actions: [
+ SizedBox(height: 20),
+ SizedBox(
+ width: 100, // Set the desired width
+ child: TextButton(
+ onPressed: () => Navigator.pop(context),
+ 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
+ ),
+ ),
+ child: Text(
+ context.translate('No', 'لا'),
+ style: TextStyle(
+ color: Color(0xFFAA8E83),
+ fontSize: 16,
+ ),
+ ),
+ ),
+ ),
+ SizedBox(
+ width: 100, // Set the desired width
+ child: TextButton(
+ onPressed: () {
+ Navigator.pop(context);
+ addBookmark(); // 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(
+ context.translate('Yes', 'نعم'),
+ style: TextStyle(color: Colors.white, fontSize: 16),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
}
+ // void showAddBookmarkDialog() {
+ // addBookmark();
+ // // ScaffoldMessenger.of(context).showSnackBar(
+ // // SnackBar(
+ // // content: Text(
+ // // 'The bookmark is added successfully',
+ // // ),
+ // // backgroundColor: Colors.green,
+ // // duration: Duration(seconds: 2),
+ // // ),
+ // // );
+ // }
void handleSkip() {
tutorialCoachMark.skip();
@@ -2048,45 +2048,67 @@ class _ChartScreen1State extends ConsumerState {
showAddBookmarkDialog();
}
},
- child: Row(
- children: [
- Text(
- context.translate(
- 'Bookmark',
- 'إشارة مرجعية',
+ child: Container(
+ padding: EdgeInsets.all(4),
+ decoration: BoxDecoration(
+ color: isBookmarked ?Colors.white.withAlpha(90):null, // Background color
+ borderRadius: BorderRadius.circular(8), // Curved corners
+ ),
+ child: Row(
+ children: [
+ isBookmarked?
+ Text(
+ context.translate(
+ 'Bookmarked',
+ 'إشارة مرجعية',
+ ),
+ style: TextStyle(
+ fontSize: 16,
+ color: Color(int.parse(
+ (chartScreenData['body_color'] ?? '#898C81')
+ .replaceFirst('#', '0xff'))),
+ ),
+ ):
+ Text(
+ context.translate(
+ 'Bookmark',
+ 'إشارة مرجعية',
+ ),
+ style: const TextStyle(
+ fontSize: 16,
+ color: Colors.white,
+ ),
),
- style: const TextStyle(
- fontSize: 16,
- color: Colors.white,
- ),
- ),
- SizedBox(width: 5),
+ SizedBox(width: 5),
- // Text(
- // "Bookmark",
- // style: const TextStyle(
- // fontSize: 16,
- // color: Colors.white),
- // ),
- // const SizedBox(width: 5),
- // Image.asset(
- // isBookmarked
- // ? UaeNumbersAssetPath
- // .bookmarksSelectedUae // Filled bookmark image
- // : UaeNumbersAssetPath
- // .bookmarksUae, // Default bookmark image
- // // color: Colors.white,
- // width: 24,
- // height: 24,
- // ),
- Icon(
- Icons.bookmarks_rounded,
- color: isBookmarked
- ? Colors.black
- : Colors.white,
- size: 23,
- ),
- ],
+ // Text(
+ // "Bookmark",
+ // style: const TextStyle(
+ // fontSize: 16,
+ // color: Colors.white),
+ // ),
+ // const SizedBox(width: 5),
+ // Image.asset(
+ // isBookmarked
+ // ? UaeNumbersAssetPath
+ // .bookmarksSelectedUae // Filled bookmark image
+ // : UaeNumbersAssetPath
+ // .bookmarksUae, // Default bookmark image
+ // // color: Colors.white,
+ // width: 24,
+ // height: 24,
+ // ),
+ Icon(
+ size: 24,
+ Icons.bookmarks_rounded,
+ color: isBookmarked
+ ? Color(int.parse(
+ (chartScreenData['body_color'] ?? '#898C81')
+ .replaceFirst('#', '0xff')))
+ : Colors.white,
+ ),
+ ],
+ ),
),
),
],
@@ -2106,77 +2128,13 @@ class _ChartScreen1State extends ConsumerState {
),
SizedBox(width: 5),
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
-
- // Create a controller to capture the SVG as an image
- final screenshotController =
- ScreenshotController();
-
- // 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');
- }
-
- // 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(
+ onTap: () => shareCurrentPage(context),
+ child: SvgPicture.asset(
+ UaeNumbersAssetPath.share,
+ semanticsLabel: 'share',
width: 24,
height: 24,
- child: Icon(
- Icons.share,
- color: Colors.white,
- size: 24,
- semanticLabel: 'Share',
- ),
- ),
+ )
),
],
),
@@ -2825,7 +2783,47 @@ class _ChartScreen1State extends ConsumerState {
);
}
}
+Future shareCurrentPage(BuildContext context) async {
+ try {
+ // Get current route from go_router
+ final String currentRoute = GoRouterState.of(context).uri.toString();
+ final String baseAppLink = 'https://fcsc-da580.web.app';
+ final String shareLink = '$baseAppLink$currentRoute';
+ final String shareText = 'Check this out!';
+ final String svgAssetPath = 'assets/logos/fcsc.png';
+ 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');
+ }
+
+ final directory = await getTemporaryDirectory();
+ final file = File('${directory.path}/shared_image.png');
+ 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");
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(content: Text('Error sharing: $e')),
+ );
+ }
+}
// Function to convert hex color string to Color
Color _getColorFromHex(String hexColor) {
hexColor = hexColor.replaceFirst('#', '');
diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart
index 4a192cac..68f06844 100644
--- a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart
+++ b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart
@@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:dio/dio.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/services/img_asset_paths/icons/bookmark_asset_path.dart';
+import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/uae_numbers_asset_path.dart';
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart';
@@ -20,6 +23,17 @@ class _BookMarkState extends ConsumerState {
List