Update: 2026-06-26 17:29:23

This commit is contained in:
Hamza-Ayed
2026-06-26 17:29:23 +03:00
parent a323da29aa
commit 9ded734e38
139 changed files with 1815 additions and 2676 deletions

View File

@@ -121,7 +121,7 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
// mySnackbarSuccess('Contacts sync completed successfully!'.tr);
}
} catch (e) {
// mySnackeBarError('An error occurred during contact sync: $e'.tr);
// mySnackbarError('An error occurred during contact sync: $e'.tr);
}
}
@@ -183,7 +183,7 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
Get.back(); // إغلاق شاشة التحميل
if (validContacts.isEmpty) {
mySnackeBarError('No contacts with phone numbers found'.tr);
mySnackbarError('No contacts with phone numbers found'.tr);
return;
}
@@ -291,12 +291,12 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
);
} else {
log('Permission DENIED', name: 'ContactPicker');
mySnackeBarError('Contact permission is required to pick contacts'.tr);
mySnackbarError('Contact permission is required to pick contacts'.tr);
}
} catch (e) {
if (Get.isDialogOpen ?? false) Get.back();
log('CRITICAL ERROR: $e', name: 'ContactPicker');
mySnackeBarError('An error occurred while loading contacts: $e'.tr);
mySnackbarError('An error occurred while loading contacts: $e'.tr);
}
log('=== END: FETCHING CONTACTS ===', name: 'ContactPicker');
}
@@ -383,7 +383,7 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
// refresh stats
fetchDriverStats();
} else {
mySnackeBarError(data['message'] ?? 'Claim failed'.tr);
mySnackbarError(data['message'] ?? 'Claim failed'.tr);
}
}
} else {
@@ -475,13 +475,13 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
/// Sends an invitation to a potential new driver.
void sendInvite() async {
if (invitePhoneController.text.isEmpty) {
mySnackeBarError('Please enter a phone number'.tr);
mySnackbarError('Please enter a phone number'.tr);
return;
}
String formattedPhoneNumber =
CountryLogic.formatCurrentCountryPhone(invitePhoneController.text);
if (formattedPhoneNumber.length != 12) {
mySnackeBarError('Please enter a correct phone'.tr);
mySnackbarError('Please enter a correct phone'.tr);
return;
}
@@ -507,14 +507,14 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
launchCommunication('whatsapp', formattedPhoneNumber, message);
invitePhoneController.clear();
} else {
mySnackeBarError("Invite code already used".tr);
mySnackbarError("Invite code already used".tr);
}
}
/// Sends an invitation to a potential new passenger.
void sendInviteToPassenger() async {
if (invitePhoneController.text.isEmpty) {
mySnackeBarError('Please enter a phone number'.tr);
mySnackbarError('Please enter a phone number'.tr);
return;
}
@@ -522,7 +522,7 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
if (formattedPhoneNumber.length < 12) {
// +963 + 9 digits = 12+
mySnackeBarError('Please enter a correct phone'.tr);
mySnackbarError('Please enter a correct phone'.tr);
return;
}
@@ -552,7 +552,7 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
launchCommunication('whatsapp', formattedPhoneNumber, message);
invitePhoneController.clear();
} else {
mySnackeBarError("Invite code already used".tr);
mySnackbarError("Invite code already used".tr);
}
}
}

View File

@@ -605,17 +605,17 @@ class LoginDriverController extends GetxController {
Get.off(() => HomeCaptain());
} else {
mySnackeBarError('Login failed'.tr);
mySnackbarError('Login failed'.tr);
isloading = false;
update();
}
} else {
mySnackeBarError('Server error'.tr);
mySnackbarError('Server error'.tr);
isloading = false;
update();
}
} catch (e) {
mySnackeBarError('Network error'.tr);
mySnackbarError('Network error'.tr);
isloading = false;
update();
}

View File

@@ -116,10 +116,10 @@ class OtpVerificationController extends GetxController {
Get.offAll(() => HomeCaptain());
} else {
mySnackeBarError('OTP is incorrect or expired'.tr);
mySnackbarError('OTP is incorrect or expired'.tr);
}
} catch (e) {
mySnackeBarError(e.toString());
mySnackbarError(e.toString());
} finally {
isVerifying.value = false;
}

View File

@@ -44,15 +44,15 @@ class PhoneAuthHelper {
mySnackbarSuccess('An OTP has been sent to your number.'.tr);
return true;
} else {
mySnackeBarError(data['message'] ?? 'Failed to send OTP.'.tr);
mySnackbarError(data['message'] ?? 'Failed to send OTP.'.tr);
return false;
}
} else {
mySnackeBarError('Server error. Please try again.'.tr);
mySnackbarError('Server error. Please try again.'.tr);
return false;
}
} catch (e) {
// mySnackeBarError('An error occurred: $e');
// mySnackbarError('An error occurred: $e');
return false;
}
}
@@ -99,13 +99,13 @@ class PhoneAuthHelper {
Get.to(() => RegistrationView());
}
} else {
mySnackeBarError(data['message'] ?? 'Verification failed.');
mySnackbarError(data['message'] ?? 'Verification failed.');
}
} else {
mySnackeBarError('Server error. Please try again.');
mySnackbarError('Server error. Please try again.');
}
} catch (e) {
mySnackeBarError('An error occurred: $e');
mySnackbarError('An error occurred: $e');
}
}
@@ -130,11 +130,11 @@ class PhoneAuthHelper {
// Registration successful, log user in
await _handleSuccessfulLogin(data['message']);
} else {
mySnackeBarError(
mySnackbarError(
"User with this phone number or email already exists.".tr);
}
} catch (e) {
mySnackeBarError('An error occurred: $e');
mySnackbarError('An error occurred: $e');
}
}

View File

@@ -143,7 +143,7 @@ class RegisterCaptainController extends GetxController {
update();
}
} else {
mySnackeBarError(
mySnackbarError(
'Phone Number wrong'.tr,
);
}
@@ -285,7 +285,7 @@ class RegisterCaptainController extends GetxController {
// }
}
} else {
mySnackeBarError('you must insert token code '.tr);
mySnackbarError('you must insert token code '.tr);
}
}

View File

@@ -220,7 +220,7 @@ class RegistrationController extends GetxController {
// // الإرسال للذكاء الاصطناعي
// await sendToAI(type, imageFile: outFile);
} catch (e) {
mySnackeBarError('${'An unexpected error occurred:'.tr} $e');
mySnackbarError('${'An unexpected error occurred:'.tr} $e');
}
}
@@ -344,7 +344,7 @@ class RegistrationController extends GetxController {
Log.print('✅ Uploaded $imageType => $imageUrl');
} catch (e, st) {
Log.print('❌ Error in choosImage: $e\n$st');
mySnackeBarError('Image Upload Failed'.tr);
mySnackbarError('Image Upload Failed'.tr);
} finally {
isloading = false;
update();
@@ -717,10 +717,10 @@ class RegistrationController extends GetxController {
c.loginDriver(driverID, email);
} else {
final msg = (json?['message'] ?? 'Registration failed.').toString();
mySnackeBarError(msg);
mySnackbarError(msg);
}
} catch (e) {
mySnackeBarError('Error: $e');
mySnackbarError('Error: $e');
} finally {
client.close();
isLoading.value = false;

View File

@@ -146,7 +146,7 @@ class CRUD {
} on SocketException catch (_) {
Log.print('⚠️ SocketException attempt $attempts$link');
if (attempts >= 3) {
_netGuard.notifyOnce((title, msg) => mySnackeBarError(msg));
_netGuard.notifyOnce((title, msg) => mySnackbarError(msg));
return 'no_internet';
}
await Future.delayed(Duration(seconds: attempts));

View File

@@ -122,7 +122,7 @@ class AI extends GetxController {
driverList: [], category: 'You have received a gift token!',
);
} else {
// mySnackeBarError(
// mySnackbarError(
// "You dont have invitation code".tr); // Localized error message
}
}
@@ -137,7 +137,7 @@ class AI extends GetxController {
update();
mySnackbarSuccess("Code approved".tr);
} else {
mySnackeBarError("Code not approved".tr);
mySnackbarError("Code not approved".tr);
}
}
}
@@ -313,12 +313,12 @@ class AI extends GetxController {
'${box.read(BoxName.phoneDriver)}${Env.email}');
mySnackbarSuccess('Driver data saved successfully');
} else {
mySnackeBarError('${'Failed to save driver data'.tr}: }');
mySnackbarError('${'Failed to save driver data'.tr}: }');
}
} catch (e) {
isLoading = false;
update();
mySnackeBarError(
mySnackbarError(
'An error occurred while saving driver data'.tr,
);
}
@@ -1020,7 +1020,7 @@ class AI extends GetxController {
update();
} else {
mySnackeBarError("JSON string not found");
mySnackbarError("JSON string not found");
}
// Rest of your code...

View File

@@ -77,7 +77,7 @@ class LogOutController extends GetxController {
var id = await checkBeforeDelete();
deleteMyAccountDriver(id);
} else {
mySnackeBarError('Your Name is Wrong'.tr);
mySnackbarError('Your Name is Wrong'.tr);
}
}));
}
@@ -148,7 +148,7 @@ class LogOutController extends GetxController {
'email': box.read(BoxName.email),
});
} else {
mySnackeBarError(
mySnackbarError(
'Email you inserted is Wrong.'.tr,
);
}

View File

@@ -155,7 +155,7 @@ class ImageController extends GetxController {
);
} catch (e) {
print('Error in choosImage: $e');
mySnackeBarError('Image Upload Failed'.tr);
mySnackbarError('Image Upload Failed'.tr);
// Get.snackbar('Image Upload Failed'.tr, e.toString(),
// backgroundColor: AppColor.primaryColor);
} finally {
@@ -218,7 +218,7 @@ class ImageController extends GetxController {
print('Error in choosImage: $e');
// Get.snackbar('Image Upload Failed'.tr, e.toString(),
// backgroundColor: AppColor.primaryColor);
mySnackeBarError('Image Upload Failed'.tr);
mySnackbarError('Image Upload Failed'.tr);
} finally {
isloading = false;
update();
@@ -293,7 +293,7 @@ class ImageController extends GetxController {
link,
);
} catch (e) {
mySnackeBarError('Image Upload Failed'.tr);
mySnackbarError('Image Upload Failed'.tr);
// Get.snackbar('Image Upload Failed'.tr, e.toString(),
// backgroundColor: AppColor.redColor);
} finally {
@@ -439,7 +439,7 @@ class ImageController extends GetxController {
}
} catch (e) {
Log.print('e: ${e}');
mySnackeBarError('Image Upload Failed'.tr);
mySnackbarError('Image Upload Failed'.tr);
} finally {
isloading = false;
update();

View File

@@ -136,7 +136,7 @@ class DurationController extends GetxController {
update();
if (res == 'no_internet') {
mySnackeBarError('No internet connection'.tr);
mySnackbarError('No internet connection'.tr);
}
}
}

View File

@@ -48,7 +48,7 @@ class AssuranceHealthController extends GetxController {
} else {
// Handle failure (e.g., show an error message)
print("Failed to save health assurance data");
mySnackeBarError("Please enter a health insurance status.".tr);
mySnackbarError("Please enter a health insurance status.".tr);
}
} catch (e) {
// Handle any errors

View File

@@ -82,10 +82,10 @@ class VideoController extends GetxController {
box.write(lastFetchKey, DateTime.now().toIso8601String());
update();
} else {
mySnackeBarError('');
mySnackbarError('');
}
} catch (e) {
mySnackeBarError(e.toString());
mySnackbarError(e.toString());
} finally {
isLoading(false);
}

View File

@@ -544,7 +544,7 @@ class MapDriverController extends GetxController
box.write(BoxName.statusDriverLocation, 'blocked');
// عرض رسالة العقوبة
mySnackeBarError(
mySnackbarError(
"Due to excessive cancellations (3 times), receiving orders has been suspended for 4 hours."
.tr,
);
@@ -603,7 +603,7 @@ class MapDriverController extends GetxController
if (Get.isDialogOpen == true) {
Get.back();
}
mySnackeBarError("Failed to cancel ride".tr);
mySnackbarError("Failed to cancel ride".tr);
}
} catch (e) {
if (Get.isDialogOpen == true) {
@@ -1038,7 +1038,7 @@ class MapDriverController extends GetxController
box.write(BoxName.rideStatus, 'Apply');
isPassengerInfoWindow = true;
stopListeningStepNavigation();
mySnackeBarError("Failed to start ride. Please try again.");
mySnackbarError("Failed to start ride. Please try again.");
update();
}
}).catchError((error) {
@@ -1048,7 +1048,7 @@ class MapDriverController extends GetxController
box.write(BoxName.rideStatus, 'Apply');
isPassengerInfoWindow = true;
stopListeningStepNavigation();
mySnackeBarError("Network error. Failed to start ride.");
mySnackbarError("Network error. Failed to start ride.");
update();
});
} else {
@@ -1075,7 +1075,7 @@ class MapDriverController extends GetxController
Get.back();
}
Log.print("Error starting ride: $e");
mySnackeBarError("Could not start ride. Please check internet.".tr);
mySnackbarError("Could not start ride. Please check internet.".tr);
}
}
@@ -1251,7 +1251,7 @@ class MapDriverController extends GetxController
} catch (e) {
if (Get.isDialogOpen == true) Get.back();
Log.print("Error: $e");
mySnackeBarError("Transaction failed, please try again.".tr);
mySnackbarError("Transaction failed, please try again.".tr);
}
}
@@ -1443,7 +1443,7 @@ class MapDriverController extends GetxController
} catch (e) {
if (Get.isDialogOpen == true) Get.back(); // إغلاق اللودينج
Log.print("Error finishing ride: $e");
mySnackeBarError("Failed to finish ride: $e");
mySnackbarError("Failed to finish ride: $e");
// إعادة الحالة محلياً للسماح للمستخدم بالمحاولة مرة أخرى بأمان
isRideFinished = false;
@@ -1930,7 +1930,7 @@ class MapDriverController extends GetxController
final String? encodedPoints = response['points'];
if (encodedPoints == null) {
mySnackeBarError("No route points found".tr);
mySnackbarError("No route points found".tr);
return;
}
@@ -1941,7 +1941,7 @@ class MapDriverController extends GetxController
);
if (fullRoute.isEmpty) {
mySnackeBarError("Failed to process route points".tr);
mySnackbarError("Failed to process route points".tr);
return;
}
@@ -2148,11 +2148,11 @@ class MapDriverController extends GetxController
);
} else {
if (Get.isDialogOpen == true) Get.back();
mySnackeBarError("You must be closer than 100 meters to arrive".tr);
mySnackbarError("You must be closer than 100 meters to arrive".tr);
}
} catch (e) {
if (Get.isDialogOpen == true) Get.back();
mySnackeBarError("A connection error occurred".tr);
mySnackbarError("A connection error occurred".tr);
}
}

View File

@@ -66,13 +66,13 @@ class InvitesRewardsController extends GetxController {
mySnackbarSuccess('Reward claimed successfully!'.tr);
await getReferralStats(); // refresh list
} else {
mySnackeBarError(jsonData['error'] ?? 'Failed to claim reward'.tr);
mySnackbarError(jsonData['error'] ?? 'Failed to claim reward'.tr);
}
} catch (e) {
mySnackeBarError('Failed to claim reward'.tr);
mySnackbarError('Failed to claim reward'.tr);
}
} else {
mySnackeBarError('Connection error'.tr);
mySnackbarError('Connection error'.tr);
}
}

View File

@@ -79,10 +79,10 @@ class CaptainWalletController extends GetxController {
'',
);
} else {
mySnackeBarError(mapRes['message']?.toString() ?? 'Error');
mySnackbarError(mapRes['message']?.toString() ?? 'Error');
}
} else {
mySnackeBarError('Error processing request'.tr);
mySnackbarError('Error processing request'.tr);
}
}
}
@@ -113,10 +113,10 @@ class CaptainWalletController extends GetxController {
amountToNewDriverMap = d['data'];
// update();
} else {
mySnackeBarError("This driver is not registered".tr);
mySnackbarError("This driver is not registered".tr);
}
} else {
mySnackeBarError('Your Budget less than needed'.tr);
mySnackbarError('Your Budget less than needed'.tr);
}
}
}
@@ -250,7 +250,7 @@ class CaptainWalletController extends GetxController {
}
} else {
Get.back();
mySnackeBarError(
mySnackbarError(
"A promotion record for this driver already exists for today.".tr);
}
}
@@ -314,10 +314,10 @@ class CaptainWalletController extends GetxController {
await refreshCaptainWallet();
}));
} else {
mySnackeBarError(mapRes['message']?.toString() ?? 'Error');
mySnackbarError(mapRes['message']?.toString() ?? 'Error');
}
} else {
mySnackeBarError('Error processing request'.tr);
mySnackbarError('Error processing request'.tr);
}
}

View File

@@ -68,7 +68,7 @@ class PaymobPayout extends GetxController {
// Get.find<CaptainWalletController>().refreshCaptainWallet();
// } else if (dec['disbursement_status'] == 'failed') {
// mySnackeBarError('Transaction failed'.tr);
// mySnackbarError('Transaction failed'.tr);
// }
} else {
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {
@@ -166,7 +166,7 @@ class PaymobPayout extends GetxController {
mySnackbarSuccess('${'Transaction successful'.tr} ${dec['amount']}');
Get.find<CaptainWalletController>().refreshCaptainWallet();
} else if (dec['disbursement_status'] == 'failed') {
mySnackeBarError('Transaction failed'.tr);
mySnackbarError('Transaction failed'.tr);
}
} else {
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {

View File

@@ -43,7 +43,7 @@ class ComplaintController extends GetxController {
if (title.toLowerCase() == 'success') {
mySnackbarSuccess(message.tr);
} else if (isError) {
mySnackeBarError(message.tr);
mySnackbarError(message.tr);
} else {
mySnackbarWarning(message.tr);
}

View File

@@ -33,7 +33,7 @@ class CaptainProfileController extends GetxController {
update();
Get.back();
} else {
mySnackeBarError((res)['message']);
mySnackbarError((res)['message']);
}
}

View File

@@ -31,7 +31,7 @@ class RatingController extends GetxController {
if (await launchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {
mySnackeBarError("Could not open the app store.");
mySnackbarError("Could not open the app store.");
}
}
@@ -80,7 +80,7 @@ class RatingController extends GetxController {
// Send confirmation email if the rating was successfully submitted
} else {
mySnackeBarError('Failed to submit rating');
mySnackbarError('Failed to submit rating');
}
} catch (e) {
// If JSON decoding fails, log the response directly
@@ -88,7 +88,7 @@ class RatingController extends GetxController {
// backgroundColor: AppColor.greenColor);
}
} else {
mySnackeBarError('Failed to connect to the server');
mySnackbarError('Failed to connect to the server');
}
}
}

View File

@@ -65,7 +65,7 @@ class DriverCarController extends GetxController {
fetchCatrsForDrivers();
} else {
mySnackeBarError('');
mySnackbarError('');
}
}
@@ -84,7 +84,7 @@ class DriverCarController extends GetxController {
if (response != 'failure') {
mySnackbarSuccess('Updated'.tr);
} else {
mySnackeBarError('Not updated'.tr);
mySnackbarError('Not updated'.tr);
}
}

View File

@@ -313,7 +313,7 @@ class InviteScreen extends StatelessWidget {
rewardsController.linkInviteCode(manualCodeController.text.trim());
manualCodeController.clear();
} else {
mySnackeBarError('Please enter a referral code'.tr);
mySnackbarError('Please enter a referral code'.tr);
}
},
child: Text('Link'.tr, style: const TextStyle(color: Colors.white, fontSize: 14)),

View File

@@ -192,7 +192,7 @@ class PassengerInfoWindow extends StatelessWidget {
context, controller);
} else {
// هنا ممكن تظهر رسالة: تم منع الاتصال بسبب كثرة الإلغاءات
mySnackeBarError(
mySnackbarError(
"You cannot call the passenger due to policy violations"
.tr);
}

View File

@@ -348,7 +348,7 @@ class WalletCaptainRefactored extends StatelessWidget {
await controller.payFromBudget();
} else {
Get.back();
mySnackeBarError('Your Budget less than needed'.tr);
mySnackbarError('Your Budget less than needed'.tr);
}
} else {
MyDialog().getDialog(

View File

@@ -2,12 +2,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../main.dart';
// ─────────────────────────────────────────────────────────────────────────────
// Snackbar variant definition
// ─────────────────────────────────────────────────────────────────────────────
enum _SnackVariant { success, error, info, warning }
extension _VariantProps on _SnackVariant {
@@ -38,20 +33,8 @@ extension _VariantProps on _SnackVariant {
_SnackVariant.info => 'Info',
_SnackVariant.warning => 'Warning',
};
HapticFeedbackType get haptic => switch (this) {
_SnackVariant.error => HapticFeedbackType.medium,
_SnackVariant.warning => HapticFeedbackType.medium,
_SnackVariant.success => HapticFeedbackType.light,
_SnackVariant.info => HapticFeedbackType.selection,
};
}
enum HapticFeedbackType { light, medium, selection }
// ─────────────────────────────────────────────────────────────────────────────
// Core snackbar widget
// ─────────────────────────────────────────────────────────────────────────────
class _SnackContent extends StatefulWidget {
final String message;
final _SnackVariant variant;
@@ -65,6 +48,7 @@ class _SnackContent extends StatefulWidget {
class _SnackContentState extends State<_SnackContent>
with TickerProviderStateMixin {
late final AnimationController _ctrl;
late final AnimationController _scaleCtrl;
late final Animation<double> _scaleAnim;
late final Animation<double> _progressAnim;
@@ -74,25 +58,25 @@ class _SnackContentState extends State<_SnackContent>
void initState() {
super.initState();
_ctrl = AnimationController(vsync: this, duration: _displayDuration);
_scaleCtrl = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
);
_scaleAnim = CurvedAnimation(
parent: AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
)..forward(),
parent: _scaleCtrl,
curve: Curves.elasticOut,
);
_progressAnim = Tween<double>(begin: 1.0, end: 0.0).animate(
CurvedAnimation(parent: _ctrl, curve: Curves.linear),
);
_scaleCtrl.forward();
_ctrl.forward();
}
@override
void dispose() {
_ctrl.dispose();
_scaleCtrl.dispose();
super.dispose();
}
@@ -107,16 +91,16 @@ class _SnackContentState extends State<_SnackContent>
decoration: BoxDecoration(
color: surface,
borderRadius: BorderRadius.circular(18),
border: Border.all(color: accent.withOpacity(0.18), width: 1.2),
border: Border.all(color: accent.withAlpha(46), width: 1.2),
boxShadow: [
BoxShadow(
color: accent.withOpacity(0.12),
color: accent.withAlpha(31),
blurRadius: 20,
spreadRadius: -2,
offset: const Offset(0, 6),
),
BoxShadow(
color: Colors.black.withOpacity(0.06),
color: Colors.black.withAlpha(15),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -127,28 +111,24 @@ class _SnackContentState extends State<_SnackContent>
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// ── Main row ──────────────────────────────────────────────────
Padding(
padding: const EdgeInsets.fromLTRB(14, 14, 10, 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Animated icon badge
ScaleTransition(
scale: _scaleAnim,
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: accent.withOpacity(0.12),
color: accent.withAlpha(31),
shape: BoxShape.circle,
),
child: Icon(v.icon, color: accent, size: 22),
),
),
const SizedBox(width: 12),
// Text content
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -166,8 +146,8 @@ class _SnackContentState extends State<_SnackContent>
const SizedBox(height: 3),
Text(
widget.message,
style: TextStyle(
color: Colors.grey[800],
style: const TextStyle(
color: Color(0xFF424242),
fontSize: 13.5,
height: 1.4,
fontWeight: FontWeight.w400,
@@ -178,19 +158,17 @@ class _SnackContentState extends State<_SnackContent>
],
),
),
// Close button
GestureDetector(
onTap: () {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
_closeSnackbar(context);
},
child: Container(
width: 30,
height: 30,
margin: const EdgeInsets.only(left: 6),
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
color: Colors.grey.withAlpha(25),
shape: BoxShape.circle,
),
child: Icon(
@@ -203,24 +181,17 @@ class _SnackContentState extends State<_SnackContent>
],
),
),
// ── Thin progress strip ───────────────────────────────────────
AnimatedBuilder(
animation: _progressAnim,
builder: (_, __) => Stack(
children: [
// Track
Container(
height: 3,
color: accent.withOpacity(0.08),
),
// Fill
Container(height: 3, color: accent.withAlpha(20)),
FractionallySizedBox(
widthFactor: _progressAnim.value,
child: Container(
height: 3,
decoration: BoxDecoration(
color: accent.withOpacity(0.45),
color: accent.withAlpha(115),
borderRadius: const BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4),
@@ -236,74 +207,57 @@ class _SnackContentState extends State<_SnackContent>
),
);
}
void _closeSnackbar(BuildContext context) {
ScaffoldMessenger.maybeOf(context)?.hideCurrentSnackBar();
}
}
// ─────────────────────────────────────────────────────────────────────────────
// Internal dispatcher — single source of truth
// ─────────────────────────────────────────────────────────────────────────────
SnackbarController _show(_SnackVariant variant, String message) {
// Dismiss any existing snackbar first (no stacking)
if (Get.isSnackbarOpen) Get.closeCurrentSnackbar();
int _retryCount = 0;
switch (variant.haptic) {
case HapticFeedbackType.light:
HapticFeedback.lightImpact();
case HapticFeedbackType.medium:
void _show(_SnackVariant variant, String message) {
if (Get.context == null) {
if (_retryCount < 3) {
_retryCount++;
WidgetsBinding.instance.addPostFrameCallback((_) => _show(variant, message));
}
return;
}
_retryCount = 0;
final context = Get.context;
if (context == null) return;
final messenger = ScaffoldMessenger.maybeOf(context);
if (messenger == null) return;
messenger.clearSnackBars();
switch (variant) {
case _SnackVariant.error:
case _SnackVariant.warning:
HapticFeedback.mediumImpact();
case HapticFeedbackType.selection:
case _SnackVariant.success:
HapticFeedback.lightImpact();
case _SnackVariant.info:
HapticFeedback.selectionClick();
}
final BuildContext? context = Get.context ?? navigatorKey.currentContext;
if (context != null) {
final overlay = Overlay.maybeOf(context);
if (overlay == null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.transparent,
elevation: 0,
padding: EdgeInsets.zero,
content: _SnackContent(message: message, variant: variant),
duration: const Duration(seconds: 4),
),
);
return SnackbarController(GetSnackBar(title: '', message: ''));
}
}
return Get.snackbar(
'',
'',
snackPosition: SnackPosition.TOP,
backgroundColor: Colors.transparent,
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
duration: const Duration(seconds: 4),
barBlur: 0,
overlayBlur: 0,
overlayColor: Colors.transparent,
isDismissible: true,
dismissDirection: DismissDirection.up,
forwardAnimationCurve: Curves.easeOutCubic,
reverseAnimationCurve: Curves.easeInCubic,
snackStyle: SnackStyle.FLOATING,
userInputForm: Form(
child: _SnackContent(message: message, variant: variant),
messenger.showSnackBar(
SnackBar(
content: _SnackContent(message: message, variant: variant),
backgroundColor: Colors.transparent,
elevation: 0,
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
behavior: SnackBarBehavior.floating,
duration: const Duration(seconds: 4),
dismissDirection: DismissDirection.up,
),
);
}
// ─────────────────────────────────────────────────────────────────────────────
// Public API — drop-in replacements for the old functions
// ─────────────────────────────────────────────────────────────────────────────
SnackbarController mySnackbarSuccess(String message) =>
_show(_SnackVariant.success, message);
SnackbarController mySnackeBarError(String message) =>
_show(_SnackVariant.error, message);
SnackbarController mySnackbarInfo(String message) =>
_show(_SnackVariant.info, message);
SnackbarController mySnackbarWarning(String message) =>
_show(_SnackVariant.warning, message);
void mySnackbarSuccess(String message) => _show(_SnackVariant.success, message);
void mySnackbarError(String message) => _show(_SnackVariant.error, message);
void mySnackbarInfo(String message) => _show(_SnackVariant.info, message);
void mySnackbarWarning(String message) => _show(_SnackVariant.warning, message);