25-7-26-1

This commit is contained in:
Hamza-Ayed
2025-07-26 10:30:10 +03:00
parent 83fa8c776c
commit 3742d5b417
645 changed files with 134317 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import 'mydialoug.dart';
class MyCircleContainer extends StatelessWidget {
final Widget child;
final Color backgroundColor;
final Color borderColor;
MyCircleContainer({
Key? key,
required this.child,
this.backgroundColor = AppColor.secondaryColor,
this.borderColor = AppColor.accentColor,
}) : super(key: key);
final controller = Get.put(CircleController());
@override
Widget build(BuildContext context) {
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();
},
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: Center(child: child),
),
)));
}
}
class CircleController extends GetxController {
Color backgroundColor = AppColor.secondaryColor;
double size = 40;
void changeColor() {
backgroundColor = backgroundColor == AppColor.secondaryColor
? AppColor.accentColor
: AppColor.secondaryColor;
size = 60;
update();
}
void onEnd() {
size = 40;
update();
}
}

View File

@@ -0,0 +1,58 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:vibration/vibration.dart';
import '../../constant/box_name.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../main.dart';
class MyElevatedButton extends StatelessWidget {
final String title;
final VoidCallback onPressed;
final Color kolor;
final int vibrateDuration;
const MyElevatedButton({
Key? key,
required this.title,
required this.onPressed,
this.kolor = AppColor.primaryColor,
this.vibrateDuration = 100,
}) : super(key: key);
@override
Widget build(BuildContext context) {
bool vibrate = box.read(BoxName.isvibrate) ?? true;
return ElevatedButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(kolor),
shadowColor: WidgetStateProperty.all(Colors.transparent),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
onPressed: () async {
// Handle haptic feedback for both iOS and Android
if (vibrate == true) {
if (Platform.isIOS) {
HapticFeedback.selectionClick();
} else if (Platform.isAndroid) {
await Vibration.vibrate(duration: vibrateDuration);
} else {}
}
// Ensure the onPressed callback is called after haptic feedback
onPressed();
},
child: Text(
title,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(color: AppColor.secondaryColor),
),
);
}
}

View File

@@ -0,0 +1,547 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'dart:ui';
import '../../constant/colors.dart';
class SnackbarConfig {
static const duration = Duration(seconds: 4);
static const animationDuration = Duration(milliseconds: 400);
static const margin = EdgeInsets.symmetric(horizontal: 16, vertical: 12);
static const borderRadius = 16.0;
static const elevation = 0.0; // تقليل الارتفاع لأننا سنستخدم تأثيرات زجاجية
// تأثير زجاجي
static const double blurStrength = 15.0;
static const double opacity = 0.85;
// حدود شفافة
static final Border glassBorder = Border.all(
color: Colors.white.withOpacity(0.25),
width: 1.5,
);
// ظل أكثر نعومة وانتشار
static final List<BoxShadow> shadows = [
BoxShadow(
color: Colors.black.withOpacity(0.15),
blurRadius: 12,
spreadRadius: 1,
offset: const Offset(0, 4),
),
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 20,
spreadRadius: 0,
offset: const Offset(0, 2),
),
];
}
// تطبيق تأثير زجاجي باستخدام Container مخصص
class GlassSnackbar extends StatelessWidget {
final Color baseColor;
final Widget child;
const GlassSnackbar({
required this.baseColor,
required this.child,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(SnackbarConfig.borderRadius),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: SnackbarConfig.blurStrength,
sigmaY: SnackbarConfig.blurStrength,
),
child: Container(
decoration: BoxDecoration(
color: baseColor.withOpacity(SnackbarConfig.opacity),
borderRadius: BorderRadius.circular(SnackbarConfig.borderRadius),
border: SnackbarConfig.glassBorder,
boxShadow: SnackbarConfig.shadows,
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
baseColor.withOpacity(SnackbarConfig.opacity + 0.05),
baseColor.withOpacity(SnackbarConfig.opacity - 0.05),
],
),
),
child: child,
),
),
);
}
}
SnackbarController mySnackeBarError(String message) {
// تأثير اهتزاز للأخطاء
HapticFeedback.mediumImpact();
final Color errorBaseColor = AppColor.redColor;
return Get.snackbar(
'',
'',
snackPosition: SnackPosition.TOP,
margin: SnackbarConfig.margin,
duration: SnackbarConfig.duration,
animationDuration: SnackbarConfig.animationDuration,
borderRadius: SnackbarConfig.borderRadius,
backgroundColor: Colors.transparent, // شفاف لأننا سنستخدم حاوية مخصصة
barBlur: 0, // إيقاف تشويش الخلفية الافتراضي لأننا سنستخدم BlurFilter
overlayBlur: 1.5,
overlayColor: Colors.black12,
userInputForm: Form(
child: GlassSnackbar(
baseColor: errorBaseColor,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
child: Row(
children: [
// أيقونة متحركة
TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 500),
curve: Curves.elasticOut,
builder: (context, value, child) {
return Transform.scale(
scale: value,
child: child,
);
},
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.25),
shape: BoxShape.circle,
),
child: const Icon(
Icons.error_rounded,
color: Colors.white,
size: 26,
),
),
),
const SizedBox(width: 16),
// محتوى النص
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Error'.tr,
style: const TextStyle(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16,
letterSpacing: 0.3,
shadows: [
Shadow(
color: Colors.black26,
offset: Offset(0, 1),
blurRadius: 2,
),
],
),
),
const SizedBox(height: 4),
Text(
message,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
height: 1.3,
fontWeight: FontWeight.w400,
),
),
],
),
),
// زر الإغلاق
InkWell(
onTap: () {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: const Icon(
Icons.close_rounded,
color: Colors.white,
size: 18,
),
),
),
],
),
),
),
),
isDismissible: true,
dismissDirection: DismissDirection.horizontal,
forwardAnimationCurve: Curves.easeOutBack,
reverseAnimationCurve: Curves.easeInCubic,
);
}
SnackbarController mySnackbarSuccess(String message) {
// تأثير اهتزاز للنجاح
HapticFeedback.lightImpact();
final Color successBaseColor = AppColor.greenColor;
return Get.snackbar(
'',
'',
snackPosition: SnackPosition.TOP,
margin: SnackbarConfig.margin,
duration: SnackbarConfig.duration,
animationDuration: SnackbarConfig.animationDuration,
borderRadius: SnackbarConfig.borderRadius,
backgroundColor: Colors.transparent, // شفاف لأننا سنستخدم حاوية مخصصة
barBlur: 0, // إيقاف تشويش الخلفية الافتراضي لأننا سنستخدم BlurFilter
overlayBlur: 1.5,
overlayColor: Colors.black12,
userInputForm: Form(
child: GlassSnackbar(
baseColor: successBaseColor,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
child: Row(
children: [
// أيقونة متحركة
TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 600),
curve: Curves.elasticOut,
builder: (context, value, child) {
return Transform.scale(
scale: value,
child: child,
);
},
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.25),
shape: BoxShape.circle,
),
child: const Icon(
Icons.check_circle_rounded,
color: Colors.white,
size: 26,
),
),
),
const SizedBox(width: 16),
// محتوى النص
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Success'.tr,
style: const TextStyle(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16,
letterSpacing: 0.3,
shadows: [
Shadow(
color: Colors.black26,
offset: Offset(0, 1),
blurRadius: 2,
),
],
),
),
const SizedBox(height: 4),
Text(
message,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
height: 1.3,
fontWeight: FontWeight.w400,
),
),
],
),
),
// زر الإغلاق
InkWell(
onTap: () {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: const Icon(
Icons.close_rounded,
color: Colors.white,
size: 18,
),
),
),
],
),
),
),
),
isDismissible: true,
dismissDirection: DismissDirection.horizontal,
forwardAnimationCurve: Curves.easeOutBack,
reverseAnimationCurve: Curves.easeInCubic,
);
}
// إضافة: دالة للمعلومات والتنبيهات
SnackbarController mySnackbarInfo(String message) {
// تأثير اهتزاز خفيف
HapticFeedback.selectionClick();
final Color infoBaseColor = Colors.blue;
return Get.snackbar(
'',
'',
snackPosition: SnackPosition.TOP,
margin: SnackbarConfig.margin,
duration: SnackbarConfig.duration,
animationDuration: SnackbarConfig.animationDuration,
borderRadius: SnackbarConfig.borderRadius,
backgroundColor: Colors.transparent, // شفاف لأننا سنستخدم حاوية مخصصة
barBlur: 0, // إيقاف تشويش الخلفية الافتراضي لأننا سنستخدم BlurFilter
overlayBlur: 1.5,
overlayColor: Colors.black12,
userInputForm: Form(
child: GlassSnackbar(
baseColor: infoBaseColor,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
child: Row(
children: [
// أيقونة متحركة
TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 500),
curve: Curves.elasticOut,
builder: (context, value, child) {
return Transform.scale(
scale: value,
child: child,
);
},
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.25),
shape: BoxShape.circle,
),
child: const Icon(
Icons.info_rounded,
color: Colors.white,
size: 26,
),
),
),
const SizedBox(width: 16),
// محتوى النص
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Info'.tr,
style: const TextStyle(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16,
letterSpacing: 0.3,
shadows: [
Shadow(
color: Colors.black26,
offset: Offset(0, 1),
blurRadius: 2,
),
],
),
),
const SizedBox(height: 4),
Text(
message,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
height: 1.3,
fontWeight: FontWeight.w400,
),
),
],
),
),
// زر الإغلاق
InkWell(
onTap: () {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: const Icon(
Icons.close_rounded,
color: Colors.white,
size: 18,
),
),
),
],
),
),
),
),
isDismissible: true,
dismissDirection: DismissDirection.horizontal,
forwardAnimationCurve: Curves.easeOutBack,
reverseAnimationCurve: Curves.easeInCubic,
);
}
// إضافة: دالة للتحذيرات
SnackbarController mySnackbarWarning(String message) {
// تأثير اهتزاز متوسط
HapticFeedback.mediumImpact();
final Color warningBaseColor = Colors.orange;
return Get.snackbar(
'',
'',
snackPosition: SnackPosition.TOP,
margin: SnackbarConfig.margin,
duration: SnackbarConfig.duration,
animationDuration: SnackbarConfig.animationDuration,
borderRadius: SnackbarConfig.borderRadius,
backgroundColor: Colors.transparent, // شفاف لأننا سنستخدم حاوية مخصصة
barBlur: 0, // إيقاف تشويش الخلفية الافتراضي لأننا سنستخدم BlurFilter
overlayBlur: 1.5,
overlayColor: Colors.black12,
userInputForm: Form(
child: GlassSnackbar(
baseColor: warningBaseColor,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
child: Row(
children: [
// أيقونة متحركة
TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 500),
curve: Curves.elasticOut,
builder: (context, value, child) {
return Transform.scale(
scale: value,
child: child,
);
},
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.25),
shape: BoxShape.circle,
),
child: const Icon(
Icons.warning_rounded,
color: Colors.white,
size: 26,
),
),
),
const SizedBox(width: 16),
// محتوى النص
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Warning'.tr,
style: const TextStyle(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16,
letterSpacing: 0.3,
shadows: [
Shadow(
color: Colors.black26,
offset: Offset(0, 1),
blurRadius: 2,
),
],
),
),
const SizedBox(height: 4),
Text(
message,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
height: 1.3,
fontWeight: FontWeight.w400,
),
),
],
),
),
// زر الإغلاق
InkWell(
onTap: () {
HapticFeedback.lightImpact();
Get.closeCurrentSnackbar();
},
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: const Icon(
Icons.close_rounded,
color: Colors.white,
size: 18,
),
),
),
],
),
),
),
),
isDismissible: true,
dismissDirection: DismissDirection.horizontal,
forwardAnimationCurve: Curves.easeOutBack,
reverseAnimationCurve: Curves.easeInCubic,
);
}

View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
class IconWidgetMenu extends StatelessWidget {
const IconWidgetMenu({
Key? key,
required this.onpressed,
required this.icon,
required this.title,
}) : super(key: key);
final VoidCallback onpressed;
final IconData icon;
final String title;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onpressed,
child: Padding(
padding: const EdgeInsets.only(top: 25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 40,
decoration: const BoxDecoration(
color: AppColor.secondaryColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: AppColor.secondaryColor,
offset: Offset(-2, -2),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer,
),
BoxShadow(
color: AppColor.accentColor,
offset: Offset(3, 3),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer,
),
],
),
child: Center(
child: Icon(
icon,
size: 30,
color: AppColor.primaryColor,
),
),
),
Text(
title,
style: AppStyle.subtitle,
)
],
),
),
);
}
}

View File

@@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
import 'dart:async';
import '../../constant/style.dart';
class MyCircularProgressIndicatorWithTimer extends StatelessWidget {
final Color backgroundColor;
final bool isLoading;
MyCircularProgressIndicatorWithTimer({
Key? key,
this.backgroundColor = Colors.transparent,
required this.isLoading,
}) : super(key: key);
final StreamController<int> _streamController = StreamController<int>();
void startTimer() {
int _timeLeft = 60;
Timer.periodic(const Duration(seconds: 1), (timer) {
if (_timeLeft > 0 && isLoading) {
_streamController.add(_timeLeft);
_timeLeft--;
} else {
timer.cancel();
_streamController.close();
}
});
}
@override
Widget build(BuildContext context) {
if (isLoading) {
startTimer();
}
return Center(
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color: backgroundColor,
shape: BoxShape.circle,
),
child: Stack(
children: [
const Center(child: CircularProgressIndicator()),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
alignment: Alignment.center,
child: Image.asset(
'assets/images/logo.gif',
width: 140,
height: 140,
),
),
const SizedBox(height: 10),
StreamBuilder<int>(
stream: _streamController.stream,
initialData: 60,
builder: (context, snapshot) {
return Text('${snapshot.data}', style: AppStyle.title);
},
),
],
),
],
),
),
);
}
}

View File

@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
class MyScafolld extends StatelessWidget {
const MyScafolld({
super.key,
required this.title,
required this.body,
this.action = const Icon(
Icons.clear,
color: AppColor.secondaryColor,
),
required this.isleading,
});
final String title;
final List<Widget> body;
final Widget action;
final bool isleading;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.secondaryColor,
appBar: AppBar(
backgroundColor: AppColor.secondaryColor,
elevation: 0,
leading: isleading
? IconButton(
onPressed: () {
Get.back();
},
icon: const Icon(
Icons.arrow_back_ios_new,
color: AppColor.primaryColor,
),
)
: const SizedBox(),
actions: [action],
title: Text(
title,
style: AppStyle.title.copyWith(fontSize: 30),
),
),
body: SafeArea(child: Stack(children: body)));
}
}

View File

@@ -0,0 +1,95 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import '../../constant/box_name.dart';
class MyTextForm extends StatelessWidget {
const MyTextForm({
Key? key,
required this.controller,
required this.label,
required this.hint,
required this.type,
}) : super(key: key);
final TextEditingController controller;
final String label, hint;
final TextInputType type;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: SizedBox(
width: Get.width * .8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label.tr,
style: TextStyle(
color: CupertinoColors.label,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
CupertinoTextField(
controller: controller,
keyboardType: type,
placeholder: hint.tr,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: CupertinoColors.systemBackground,
border: Border.all(color: CupertinoColors.systemGrey4),
borderRadius: BorderRadius.circular(8),
),
style: const TextStyle(color: CupertinoColors.label),
placeholderStyle:
const TextStyle(color: CupertinoColors.placeholderText),
),
const SizedBox(height: 4),
ValueListenableBuilder<TextEditingValue>(
valueListenable: controller,
builder: (context, value, child) {
String? errorText = _getErrorText(value.text);
return errorText != null
? Text(
errorText,
style: const TextStyle(
color: CupertinoColors.destructiveRed,
fontSize: 12),
)
: const SizedBox.shrink();
},
),
],
),
),
);
}
String? _getErrorText(String value) {
if (value.isEmpty) {
return '${'Please enter'.tr} $label'.tr;
}
if (type == TextInputType.emailAddress) {
if (!value.contains('@')) {
return 'Please enter a valid email.'.tr;
}
} else if (type == TextInputType.phone) {
final box = GetStorage();
if (box.read(BoxName.countryCode) == 'Egypt') {
if (value.length != 11) {
return 'Please enter a valid phone number.'.tr;
}
} else if (value.length != 10) {
return 'Please enter a valid phone number.'.tr;
}
}
return null;
}
}

View File

@@ -0,0 +1,132 @@
import 'package:flutter/material.dart';
class MyCircularProgressIndicator extends StatefulWidget {
final Color backgroundColor;
final double size;
final Color progressColor;
final double strokeWidth;
const MyCircularProgressIndicator({
super.key,
this.backgroundColor = Colors.transparent,
this.size = 110,
this.progressColor = Colors.blue,
this.strokeWidth = 3.0,
});
@override
State<MyCircularProgressIndicator> createState() =>
_MyCircularProgressIndicatorState();
}
class _MyCircularProgressIndicatorState
extends State<MyCircularProgressIndicator>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _scaleAnimation;
late Animation<double> _rotationAnimation;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat(reverse: true);
_scaleAnimation = Tween<double>(
begin: 0.95,
end: 1.05,
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
));
_rotationAnimation = Tween<double>(
begin: 0,
end: 2,
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.linear,
));
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Center(
child: AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Transform.scale(
scale: _scaleAnimation.value,
child: Container(
width: widget.size,
height: widget.size,
decoration: BoxDecoration(
color: widget.backgroundColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: widget.progressColor.withAlpha(30),
blurRadius: 12,
spreadRadius: 2,
),
],
),
child: Stack(
alignment: Alignment.center,
children: [
// Outer rotating progress indicator
Transform.rotate(
angle: _rotationAnimation.value * 3.14,
child: CircularProgressIndicator(
strokeWidth: widget.strokeWidth,
valueColor: AlwaysStoppedAnimation<Color>(
widget.progressColor,
),
),
),
// Inner static progress indicator
CircularProgressIndicator(
strokeWidth: widget.strokeWidth * 0.7,
valueColor: AlwaysStoppedAnimation<Color>(
widget.progressColor.withAlpha(150),
),
),
// Logo container with scale animation
ScaleTransition(
scale: Tween<double>(
begin: 0.9,
end: 1.0,
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
)),
child: Container(
width: widget.size * 0.7,
height: widget.size * 0.7,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.backgroundColor,
),
child: Image.asset(
'assets/images/logo.gif',
fit: BoxFit.contain,
),
),
),
],
),
),
);
},
),
);
}
}

View File

@@ -0,0 +1,246 @@
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../controller/functions/tts.dart';
class DialogConfig {
static const Duration animationDuration = Duration(milliseconds: 200);
static const double blurStrength = 8.0;
static const double cornerRadius = 14.0;
static final BoxDecoration decoration = BoxDecoration(
borderRadius: BorderRadius.circular(cornerRadius),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(38), // 0.15 opacity
blurRadius: 16,
offset: const Offset(0, 8),
),
],
);
}
class MyDialog extends GetxController {
void getDialog(String title, String? midTitle, VoidCallback onPressed) {
final textToSpeechController = Get.put(TextToSpeechController());
HapticFeedback.mediumImpact();
Get.dialog(
TweenAnimationBuilder<double>(
duration: DialogConfig.animationDuration,
tween: Tween(begin: 0.0, end: 1.0),
builder: (context, value, child) {
return Transform.scale(
scale: 0.95 + (0.05 * value),
child: Opacity(opacity: value, child: child),
);
},
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: DialogConfig.blurStrength,
sigmaY: DialogConfig.blurStrength,
),
child: Theme(
data: ThemeData.light().copyWith(
dialogBackgroundColor: CupertinoColors.systemBackground,
),
child: CupertinoAlertDialog(
title: Column(
children: [
Text(
title,
style: AppStyle.title.copyWith(
fontSize: 20,
fontWeight: FontWeight.w700,
letterSpacing: -0.5,
color: AppColor.primaryColor,
),
),
const SizedBox(height: 8),
],
),
content: Column(
children: [
CupertinoButton(
padding: const EdgeInsets.all(8),
onPressed: () async {
HapticFeedback.selectionClick();
await textToSpeechController.speakText(title);
await textToSpeechController.speakText(midTitle!);
},
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color:
AppColor.primaryColor.withAlpha(26), // 0.1 opacity
borderRadius: BorderRadius.circular(8),
),
child: Icon(
CupertinoIcons.speaker_2_fill,
color: AppColor.primaryColor,
size: 24,
),
),
),
const SizedBox(height: 8),
Text(
midTitle!,
style: AppStyle.title.copyWith(
fontSize: 16,
height: 1.3,
color: Colors.black87,
),
textAlign: TextAlign.center,
),
],
),
actions: [
CupertinoDialogAction(
onPressed: () {
HapticFeedback.lightImpact();
Get.back();
},
child: Text(
'Cancel',
style: TextStyle(
color: AppColor.redColor,
fontWeight: FontWeight.w600,
fontSize: 17,
),
),
),
CupertinoDialogAction(
onPressed: () {
HapticFeedback.mediumImpact();
onPressed();
},
child: Text(
'OK'.tr,
style: TextStyle(
color: AppColor.greenColor,
fontWeight: FontWeight.w600,
fontSize: 17,
),
),
),
],
),
),
),
),
barrierDismissible: true,
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
);
}
}
class MyDialogContent extends GetxController {
void getDialog(String title, Widget? content, VoidCallback onPressed) {
final textToSpeechController = Get.put(TextToSpeechController());
HapticFeedback.mediumImpact();
Get.dialog(
TweenAnimationBuilder<double>(
duration: DialogConfig.animationDuration,
tween: Tween(begin: 0.0, end: 1.0),
builder: (context, value, child) {
return Transform.scale(
scale: 0.95 + (0.05 * value),
child: Opacity(opacity: value, child: child),
);
},
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: DialogConfig.blurStrength,
sigmaY: DialogConfig.blurStrength,
),
child: Theme(
data: ThemeData.light().copyWith(
dialogBackgroundColor: CupertinoColors.systemBackground,
),
child: CupertinoAlertDialog(
title: Column(
children: [
Text(
title,
style: AppStyle.title.copyWith(
fontSize: 20,
fontWeight: FontWeight.w700,
letterSpacing: -0.5,
color: AppColor.primaryColor,
),
),
const SizedBox(height: 8),
],
),
content: Column(
children: [
CupertinoButton(
padding: const EdgeInsets.all(8),
onPressed: () async {
HapticFeedback.selectionClick();
await textToSpeechController.speakText(title);
},
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color:
AppColor.primaryColor.withAlpha(26), // 0.1 opacity
borderRadius: BorderRadius.circular(8),
),
child: Icon(
CupertinoIcons.headphones,
color: AppColor.primaryColor,
size: 24,
),
),
),
const SizedBox(height: 12),
content!,
],
),
actions: [
CupertinoDialogAction(
onPressed: () {
HapticFeedback.lightImpact();
Get.back();
},
child: Text(
'Cancel',
style: TextStyle(
color: AppColor.redColor,
fontWeight: FontWeight.w600,
fontSize: 17,
),
),
),
CupertinoDialogAction(
onPressed: () {
HapticFeedback.mediumImpact();
onPressed();
},
child: Text(
'OK'.tr,
style: TextStyle(
color: AppColor.greenColor,
fontWeight: FontWeight.w600,
fontSize: 17,
),
),
),
],
),
),
),
),
barrierDismissible: true,
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
);
}
}