drawer change

This commit is contained in:
Juki-shiba 2025-02-20 18:03:51 +05:30
parent 7935d944a2
commit c879853816
8 changed files with 153 additions and 47 deletions

View File

@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:label="UAE Stats"
android:name="${applicationName}"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

View File

@ -5,6 +5,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pocketbase/pocketbase.dart';
import 'package:screenshot/screenshot.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
import 'package:uae_stat/config/toast_util.dart';
@ -2134,55 +2135,67 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
),
),
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(

View File

@ -544,7 +544,7 @@ class _EditProfileState extends State<EditProfile> {
? NetworkImage(
_avatarUrl) // Load from URL
: AssetImage(
'assets/edit_profile/profile.png')
'assets/edit_profile/profile.jpg')
as ImageProvider,
child: _avatarUrl.isNotEmpty
? FutureBuilder(

View File

@ -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<BaseScaffold> {
)
: 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<BaseScaffold> {
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<BaseScaffold> {
}
}
}
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
],
),
);
}

View File

@ -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:

View File

@ -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