feat: refactor financial wallet UI components and add offline map service support

This commit is contained in:
Hamza-Ayed
2026-04-21 00:35:30 +03:00
parent 4293d20561
commit b92db3bb39
99 changed files with 22888 additions and 27387 deletions

View File

@@ -6,65 +6,72 @@ import 'mydialoug.dart';
class MyCircleContainer extends StatelessWidget {
final Widget child;
final Color backgroundColor;
final Color borderColor;
final Color? backgroundColor;
final Color? borderColor;
MyCircleContainer({
Key? key,
super.key,
required this.child,
this.backgroundColor = AppColor.secondaryColor,
this.borderColor = AppColor.accentColor,
}) : super(key: key);
this.backgroundColor,
this.borderColor,
});
final controller = Get.put(CircleController());
@override
Widget build(BuildContext context) {
final effectiveBorderColor = borderColor ?? AppColor.borderColor;
return GetBuilder<CircleController>(
builder: ((controller) => GestureDetector(
onTap: () {
controller.changeColor();
MyDialog().getDialog(
'Rejected Orders Count'.tr,
'This is the total number of rejected orders per day after accepting the orders'
.tr, () {
Get.back();
});
},
child: AnimatedContainer(
onEnd: () {
controller.onEnd();
builder: ((controller) {
final effectiveBackgroundColor = backgroundColor ??
(controller.isActive ? AppColor.accentColor : AppColor.secondaryColor);
return GestureDetector(
onTap: () {
controller.toggleActive();
MyDialog().getDialog(
'Rejected Orders Count'.tr,
'This is the total number of rejected orders per day after accepting the orders'
.tr, () {
Get.back();
});
},
duration: const Duration(milliseconds: 300),
width: controller.size,
height: controller.size,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: controller.backgroundColor,
border: Border.all(
color: borderColor,
width: 1,
child: AnimatedContainer(
onEnd: () {
controller.resetSize();
},
duration: const Duration(milliseconds: 300),
width: controller.size,
height: controller.size,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: effectiveBackgroundColor,
border: Border.all(
color: effectiveBorderColor,
width: 1,
),
),
child: Center(child: child),
),
child: Center(child: child),
),
)));
);
}));
}
}
class CircleController extends GetxController {
Color backgroundColor = AppColor.secondaryColor;
bool isActive = false;
double size = 40;
void changeColor() {
backgroundColor = backgroundColor == AppColor.secondaryColor
? AppColor.accentColor
: AppColor.secondaryColor;
void toggleActive() {
isActive = !isActive;
size = 60;
update();
}
void onEnd() {
void resetSize() {
size = 40;
update();
}
}

View File

@@ -51,8 +51,14 @@ class MyElevatedButton extends StatelessWidget {
child: Text(
title,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(color: AppColor.secondaryColor),
style: AppStyle.title.copyWith(
color: (kolor == AppColor.primaryColor || kolor == AppColor.blueColor || kolor == AppColor.redColor || kolor == AppColor.greenColor)
? Colors.white
: AppColor.writeColor,
fontWeight: FontWeight.bold,
),
),
);
}
}

View File

@@ -1,123 +1,292 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
class SnackbarConfig {
static const duration = Duration(seconds: 3);
static const animationDuration = Duration(milliseconds: 300);
static const margin = EdgeInsets.symmetric(horizontal: 16, vertical: 10);
static const borderRadius = 12.0;
static const elevation = 6.0;
// ─────────────────────────────────────────────────────────────────────────────
// Snackbar variant definition
// ─────────────────────────────────────────────────────────────────────────────
enum _SnackVariant { success, error, info, warning }
static final BoxShadow shadow = BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 10,
offset: const Offset(0, 2),
);
extension _VariantProps on _SnackVariant {
Color get baseColor => switch (this) {
_SnackVariant.success => const Color(0xFF1A9E5C),
_SnackVariant.error => const Color(0xFFD93025),
_SnackVariant.info => const Color(0xFF1A73E8),
_SnackVariant.warning => const Color(0xFFF29900),
};
Color get surfaceColor => switch (this) {
_SnackVariant.success => const Color(0xFFF0FBF5),
_SnackVariant.error => const Color(0xFFFEF2F1),
_SnackVariant.info => const Color(0xFFF0F6FF),
_SnackVariant.warning => const Color(0xFFFFF8E6),
};
IconData get icon => switch (this) {
_SnackVariant.success => Icons.check_circle_rounded,
_SnackVariant.error => Icons.error_rounded,
_SnackVariant.info => Icons.info_rounded,
_SnackVariant.warning => Icons.warning_amber_rounded,
};
String get label => switch (this) {
_SnackVariant.success => 'Success',
_SnackVariant.error => 'Error',
_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,
};
}
SnackbarController mySnackeBarError(String message) {
// Trigger error haptic feedback
HapticFeedback.mediumImpact();
enum HapticFeedbackType { light, medium, selection }
// ─────────────────────────────────────────────────────────────────────────────
// Core snackbar widget
// ─────────────────────────────────────────────────────────────────────────────
class _SnackContent extends StatefulWidget {
final String message;
final _SnackVariant variant;
const _SnackContent({required this.message, required this.variant});
@override
State<_SnackContent> createState() => _SnackContentState();
}
class _SnackContentState extends State<_SnackContent>
with TickerProviderStateMixin {
late final AnimationController _ctrl;
late final Animation<double> _scaleAnim;
late final Animation<double> _progressAnim;
static const Duration _displayDuration = Duration(seconds: 4);
@override
void initState() {
super.initState();
_ctrl = AnimationController(vsync: this, duration: _displayDuration);
_scaleAnim = CurvedAnimation(
parent: AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
)..forward(),
curve: Curves.elasticOut,
);
_progressAnim = Tween<double>(begin: 1.0, end: 0.0).animate(
CurvedAnimation(parent: _ctrl, curve: Curves.linear),
);
_ctrl.forward();
}
@override
void dispose() {
_ctrl.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final v = widget.variant;
final accent = v.baseColor;
final surface = v.surfaceColor;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration: BoxDecoration(
color: surface,
borderRadius: BorderRadius.circular(18),
border: Border.all(color: accent.withOpacity(0.18), width: 1.2),
boxShadow: [
BoxShadow(
color: accent.withOpacity(0.12),
blurRadius: 20,
spreadRadius: -2,
offset: const Offset(0, 6),
),
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(18),
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),
shape: BoxShape.circle,
),
child: Icon(v.icon, color: accent, size: 22),
),
),
const SizedBox(width: 12),
// Text content
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
v.label.tr,
style: TextStyle(
color: accent,
fontSize: 13,
fontWeight: FontWeight.w700,
letterSpacing: 0.2,
),
),
const SizedBox(height: 3),
Text(
widget.message,
style: TextStyle(
color: Colors.grey[800],
fontSize: 13.5,
height: 1.4,
fontWeight: FontWeight.w400,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
),
),
// Close button
GestureDetector(
onTap: () {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
child: Container(
width: 30,
height: 30,
margin: const EdgeInsets.only(left: 6),
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
shape: BoxShape.circle,
),
child: Icon(
Icons.close_rounded,
size: 16,
color: Colors.grey[500],
),
),
),
],
),
),
// ── Thin progress strip ───────────────────────────────────────
AnimatedBuilder(
animation: _progressAnim,
builder: (_, __) => Stack(
children: [
// Track
Container(
height: 3,
color: accent.withOpacity(0.08),
),
// Fill
FractionallySizedBox(
widthFactor: _progressAnim.value,
child: Container(
height: 3,
decoration: BoxDecoration(
color: accent.withOpacity(0.45),
borderRadius: const BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4),
),
),
),
),
],
),
),
],
),
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// Internal dispatcher — single source of truth
// ─────────────────────────────────────────────────────────────────────────────
SnackbarController _show(_SnackVariant variant, String message) {
// Dismiss any existing snackbar first (no stacking)
if (Get.isSnackbarOpen) Get.closeCurrentSnackbar();
switch (variant.haptic) {
case HapticFeedbackType.light:
HapticFeedback.lightImpact();
case HapticFeedbackType.medium:
HapticFeedback.mediumImpact();
case HapticFeedbackType.selection:
HapticFeedback.selectionClick();
}
return Get.snackbar(
'Error'.tr,
message,
backgroundColor: AppColor.redColor.withOpacity(0.95),
colorText: AppColor.secondaryColor,
icon: const Icon(
Icons.error_outline_rounded,
color: AppColor.secondaryColor,
size: 28,
),
shouldIconPulse: true,
'',
'',
snackPosition: SnackPosition.TOP,
margin: SnackbarConfig.margin,
borderRadius: SnackbarConfig.borderRadius,
duration: SnackbarConfig.duration,
animationDuration: SnackbarConfig.animationDuration,
forwardAnimationCurve: Curves.easeOutCirc,
reverseAnimationCurve: Curves.easeInCirc,
boxShadows: [SnackbarConfig.shadow],
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
titleText: Text(
'Error'.tr,
style: const TextStyle(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16,
letterSpacing: 0.2,
),
),
messageText: Text(
message,
style: TextStyle(
color: Colors.white.withOpacity(0.95),
fontSize: 14,
height: 1.3,
),
),
onTap: (_) {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
backgroundColor: Colors.transparent,
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
duration: const Duration(seconds: 4),
animationDuration: const Duration(milliseconds: 380),
barBlur: 0,
overlayBlur: 0,
overlayColor: Colors.transparent,
isDismissible: true,
dismissDirection: DismissDirection.horizontal,
overlayBlur: 0.8,
overlayColor: Colors.black12,
dismissDirection: DismissDirection.up,
forwardAnimationCurve: Curves.easeOutCubic,
reverseAnimationCurve: Curves.easeInCubic,
snackStyle: SnackStyle.FLOATING,
userInputForm: Form(
child: _SnackContent(message: message, variant: variant),
),
);
}
SnackbarController mySnackbarSuccess(String message) {
// Trigger success haptic feedback
HapticFeedback.lightImpact();
// ─────────────────────────────────────────────────────────────────────────────
// Public API — drop-in replacements for the old functions
// ─────────────────────────────────────────────────────────────────────────────
SnackbarController mySnackbarSuccess(String message) =>
_show(_SnackVariant.success, message);
return Get.snackbar(
'Success'.tr,
message,
backgroundColor: AppColor.greenColor.withOpacity(0.95),
colorText: AppColor.secondaryColor,
icon: const Icon(
Icons.check_circle_outline_rounded,
color: AppColor.secondaryColor,
size: 28,
),
shouldIconPulse: true,
snackPosition: SnackPosition.TOP,
margin: SnackbarConfig.margin,
borderRadius: SnackbarConfig.borderRadius,
duration: SnackbarConfig.duration,
animationDuration: SnackbarConfig.animationDuration,
forwardAnimationCurve: Curves.easeOutCirc,
reverseAnimationCurve: Curves.easeInCirc,
boxShadows: [SnackbarConfig.shadow],
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
titleText: Text(
'Success'.tr,
style: const TextStyle(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16,
letterSpacing: 0.2,
),
),
messageText: Text(
message,
style: TextStyle(
color: Colors.white.withOpacity(0.95),
fontSize: 14,
height: 1.3,
),
),
onTap: (_) {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
isDismissible: true,
dismissDirection: DismissDirection.horizontal,
overlayBlur: 0.8,
overlayColor: Colors.black12,
);
}
SnackbarController mySnackeBarError(String message) =>
_show(_SnackVariant.error, message);
SnackbarController mySnackbarInfo(String message) =>
_show(_SnackVariant.info, message);
SnackbarController mySnackbarWarning(String message) =>
_show(_SnackVariant.warning, message);

View File

@@ -26,18 +26,18 @@ class IconWidgetMenu extends StatelessWidget {
children: [
Container(
width: 50,
decoration: const BoxDecoration(
decoration: BoxDecoration(
color: AppColor.secondaryColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: AppColor.secondaryColor,
offset: Offset(-2, -2),
offset: const Offset(-2, -2),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer,
),
BoxShadow(
const BoxShadow(
color: AppColor.accentColor,
offset: Offset(3, 3),
blurRadius: 0,

View File

@@ -9,29 +9,27 @@ class MyScafolld extends StatelessWidget {
super.key,
required this.title,
required this.body,
this.action = const Icon(
Icons.clear,
color: AppColor.secondaryColor,
),
this.action,
required this.isleading,
});
final String title;
final List<Widget> body;
final Widget action;
final Widget? action;
final bool isleading;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
backgroundColor: AppColor.secondaryColor,
backgroundColor: theme.scaffoldBackgroundColor,
appBar: AppBar(
backgroundColor: AppColor.secondaryColor,
backgroundColor: theme.appBarTheme.backgroundColor,
elevation: 0,
leading: isleading
? IconButton(
onPressed: () {
Get.back();
Navigator.maybePop(context);
},
icon: const Icon(
Icons.arrow_back_ios_new,
@@ -39,12 +37,19 @@ class MyScafolld extends StatelessWidget {
),
)
: const SizedBox(),
actions: [action],
actions: [
action ??
Icon(
Icons.clear,
color: Colors.transparent,
)
],
title: Text(
title,
style: AppStyle.title.copyWith(fontSize: 30),
style: theme.textTheme.titleLarge?.copyWith(fontSize: 24, fontWeight: FontWeight.bold),
),
),
body: SafeArea(child: Stack(children: body)));
}
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:sefer_driver/constant/box_name.dart';
@@ -18,6 +19,7 @@ class MyTextForm extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: SizedBox(
@@ -27,9 +29,7 @@ class MyTextForm extends StatelessWidget {
children: [
Text(
label.tr,
style: TextStyle(
color: CupertinoColors.label,
fontSize: 16,
style: theme.textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
@@ -40,13 +40,14 @@ class MyTextForm extends StatelessWidget {
placeholder: hint.tr,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: CupertinoColors.systemBackground,
border: Border.all(color: CupertinoColors.systemGrey4),
color: theme.cardColor,
border: Border.all(color: theme.dividerColor),
borderRadius: BorderRadius.circular(8),
),
style: const TextStyle(color: CupertinoColors.label),
placeholderStyle:
const TextStyle(color: CupertinoColors.placeholderText),
style: theme.textTheme.bodyLarge,
placeholderStyle: theme.textTheme.bodyMedium?.copyWith(
color: theme.hintColor,
),
),
const SizedBox(height: 4),
ValueListenableBuilder<TextEditingValue>(
@@ -56,9 +57,10 @@ class MyTextForm extends StatelessWidget {
return errorText != null
? Text(
errorText,
style: const TextStyle(
color: CupertinoColors.destructiveRed,
fontSize: 12),
style: TextStyle(
color: theme.colorScheme.error,
fontSize: 12,
),
)
: const SizedBox.shrink();
},

View File

@@ -44,11 +44,9 @@ class MyDialog extends GetxController {
sigmaX: DialogConfig.blurStrength,
sigmaY: DialogConfig.blurStrength,
),
child: Theme(
data: ThemeData.light().copyWith(
dialogBackgroundColor: CupertinoColors.systemBackground,
),
child: CupertinoAlertDialog(
child: Builder(builder: (context) {
final theme = Theme.of(context);
return CupertinoAlertDialog(
title: Column(
children: [
Text(
@@ -92,7 +90,7 @@ class MyDialog extends GetxController {
style: AppStyle.title.copyWith(
fontSize: 16,
height: 1.3,
color: Colors.black87,
color: theme.textTheme.bodyLarge?.color ?? AppColor.writeColor,
),
textAlign: TextAlign.center,
),
@@ -102,7 +100,7 @@ class MyDialog extends GetxController {
CupertinoDialogAction(
onPressed: () {
HapticFeedback.lightImpact();
Get.back();
Navigator.of(context, rootNavigator: true).pop();
},
child: Text(
'Cancel'.tr,
@@ -116,6 +114,7 @@ class MyDialog extends GetxController {
CupertinoDialogAction(
onPressed: () {
HapticFeedback.mediumImpact();
Navigator.of(context, rootNavigator: true).pop();
onPressed();
},
child: Text(
@@ -128,10 +127,11 @@ class MyDialog extends GetxController {
),
),
],
),
),
);
}),
),
),
barrierDismissible: true,
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
);
@@ -159,11 +159,8 @@ class MyDialogContent extends GetxController {
sigmaX: DialogConfig.blurStrength,
sigmaY: DialogConfig.blurStrength,
),
child: Theme(
data: ThemeData.light().copyWith(
dialogBackgroundColor: CupertinoColors.systemBackground,
),
child: CupertinoAlertDialog(
child: Builder(builder: (context) {
return CupertinoAlertDialog(
title: Column(
children: [
Text(
@@ -208,7 +205,7 @@ class MyDialogContent extends GetxController {
CupertinoDialogAction(
onPressed: () {
HapticFeedback.lightImpact();
Get.back();
Navigator.of(context, rootNavigator: true).pop();
},
child: Text(
'Cancel',
@@ -222,6 +219,7 @@ class MyDialogContent extends GetxController {
CupertinoDialogAction(
onPressed: () {
HapticFeedback.mediumImpact();
Navigator.of(context, rootNavigator: true).pop();
onPressed();
},
child: Text(
@@ -234,10 +232,11 @@ class MyDialogContent extends GetxController {
),
),
],
),
),
);
}),
),
),
barrierDismissible: true,
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
);