first commit

This commit is contained in:
Hamza-Ayed
2026-06-09 08:40:31 +03:00
commit d8901e1a87
3161 changed files with 536187 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
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,
this.borderColor,
}) : 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.isAccented ? AppColor.accentColor : (backgroundColor ?? AppColor.secondaryColor),
border: Border.all(
color: borderColor ?? AppColor.accentColor,
width: 1,
),
),
child: Center(child: child),
),
)));
}
}
class CircleController extends GetxController {
bool isAccented = false;
double size = 40;
void changeColor() {
isAccented = !isAccented;
size = 60;
update();
}
void onEnd() {
size = 40;
update();
}
}

View File

@@ -0,0 +1,182 @@
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 StatefulWidget {
final String title;
final VoidCallback onPressed;
final Color kolor;
final int vibrateDuration;
final IconData? icon;
final bool isLoading;
final double? height;
final double? fontSize;
const MyElevatedButton({
Key? key,
required this.title,
required this.onPressed,
this.kolor = AppColor.primaryColor,
this.vibrateDuration = 50, // Shorter = crisper feedback
this.icon,
this.isLoading = false,
this.height = 52,
this.fontSize,
}) : super(key: key);
@override
State<MyElevatedButton> createState() => _MyElevatedButtonState();
}
class _MyElevatedButtonState extends State<MyElevatedButton>
with SingleTickerProviderStateMixin {
late final AnimationController _pressController;
bool _isVibrateEnabled = true;
@override
void initState() {
super.initState();
_pressController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 120),
reverseDuration: const Duration(milliseconds: 180),
);
_loadVibratePreference();
}
Future<void> _loadVibratePreference() async {
// Reactive to preference changes if needed later
setState(() {
_isVibrateEnabled = box.read(BoxName.isvibrate) ?? true;
});
}
@override
void dispose() {
_pressController.dispose();
super.dispose();
}
void _triggerHaptic() {
if (!_isVibrateEnabled) return;
// Unified approach: HapticFeedback works well on both platforms
if (Platform.isIOS) {
HapticFeedback.lightImpact();
} else if (Platform.isAndroid) {
// Try native haptic first, fallback to Vibration package if needed
HapticFeedback.mediumImpact();
// Optional stronger feedback:
// Vibration.vibrate(duration: widget.vibrateDuration);
}
}
void _handlePress() {
if (widget.isLoading) return;
_triggerHaptic();
_pressController.forward().then((_) => _pressController.reverse());
// Small delay ensures animation starts before callback
Future.delayed(const Duration(milliseconds: 80), widget.onPressed);
}
@override
Widget build(BuildContext context) {
final isEnabled = !widget.isLoading && widget.onPressed != () {};
return AnimatedBuilder(
animation: _pressController,
builder: (context, child) {
final scale = 1.0 - (_pressController.value * 0.03);
return Transform.scale(
scale: scale,
child: Container(
height: widget.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
boxShadow: isEnabled
? [
BoxShadow(
color: widget.kolor.withOpacity(0.25),
blurRadius: 12,
offset: const Offset(0, 4),
),
]
: null,
),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith<Color>(
(states) {
if (!isEnabled) return widget.kolor.withOpacity(0.5);
if (states.contains(WidgetState.pressed)) {
return widget.kolor.withOpacity(0.92);
}
return widget.kolor;
},
),
elevation: WidgetStateProperty.resolveWith<double>(
(states) => isEnabled
? (states.contains(WidgetState.pressed) ? 2 : 6)
: 0,
),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
),
),
onPressed: isEnabled ? _handlePress : null,
child: _buildContent(),
),
),
);
},
);
}
Widget _buildContent() {
if (widget.isLoading) {
return SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation<Color>(AppColor.secondaryColor),
),
);
}
final textStyle = AppStyle.title.copyWith(
color: AppColor.secondaryColor,
fontSize: widget.fontSize,
fontWeight: FontWeight.w600,
letterSpacing: 0.3,
);
if (widget.icon != null) {
return Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(widget.icon, size: 18, color: AppColor.secondaryColor),
const SizedBox(width: 8),
Text(widget.title, style: textStyle, textAlign: TextAlign.center),
],
);
}
return Text(widget.title, style: textStyle, textAlign: TextAlign.center);
}
}

View File

@@ -0,0 +1,292 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
// ─────────────────────────────────────────────────────────────────────────────
// Snackbar variant definition
// ─────────────────────────────────────────────────────────────────────────────
enum _SnackVariant { success, error, info, warning }
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,
};
}
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(
'',
'',
snackPosition: SnackPosition.TOP,
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.up,
forwardAnimationCurve: Curves.easeOutCubic,
reverseAnimationCurve: Curves.easeInCubic,
snackStyle: SnackStyle.FLOATING,
userInputForm: Form(
child: _SnackContent(message: message, variant: variant),
),
);
}
// ─────────────────────────────────────────────────────────────────────────────
// 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);

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: BoxDecoration(
color: AppColor.secondaryColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: AppColor.secondaryColor,
offset: const Offset(-2, -2),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer,
),
const 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,159 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
class MyCircularProgressIndicatorWithTimer extends StatefulWidget {
final Color backgroundColor;
final bool isLoading;
const MyCircularProgressIndicatorWithTimer({
Key? key,
this.backgroundColor = Colors.transparent,
required this.isLoading,
}) : super(key: key);
@override
State<MyCircularProgressIndicatorWithTimer> createState() =>
_MyCircularProgressIndicatorWithTimerState();
}
class _MyCircularProgressIndicatorWithTimerState
extends State<MyCircularProgressIndicatorWithTimer> {
Timer? _timer;
int _timeLeft = 60;
bool _isLowTime = false;
@override
void initState() {
super.initState();
if (widget.isLoading) _startTimer();
}
@override
void didUpdateWidget(
covariant MyCircularProgressIndicatorWithTimer oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.isLoading && !oldWidget.isLoading) {
_resetTimer();
_startTimer();
} else if (!widget.isLoading && oldWidget.isLoading) {
_cancelTimer();
}
}
void _startTimer() {
_cancelTimer(); // Ensure no duplicate timers
_timer = Timer.periodic(const Duration(seconds: 1), (_) {
if (!mounted) return;
setState(() {
if (_timeLeft > 0) {
_timeLeft--;
_isLowTime = _timeLeft <= 10;
} else {
_cancelTimer();
}
});
});
}
void _resetTimer() {
_cancelTimer();
setState(() {
_timeLeft = 60;
_isLowTime = false;
});
}
void _cancelTimer() {
_timer?.cancel();
_timer = null;
}
@override
void dispose() {
_cancelTimer();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (!widget.isLoading) return const SizedBox.shrink();
final progress = _timeLeft / 60.0;
final timerColor = _isLowTime ? Colors.orangeAccent : Colors.blueAccent;
return Center(
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color: widget.backgroundColor == Colors.transparent
? AppColor.secondaryColor.withOpacity(0.96)
: widget.backgroundColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 24,
spreadRadius: 2,
offset: const Offset(0, 8),
),
],
),
child: Stack(
alignment: Alignment.center,
children: [
// Elegant circular progress ring
SizedBox(
width: 184,
height: 184,
child: CircularProgressIndicator(
value: progress,
strokeWidth: 6,
backgroundColor: Get.isDarkMode
? Colors.grey.shade800
: Colors.grey.shade100,
valueColor: AlwaysStoppedAnimation<Color>(timerColor),
strokeCap: StrokeCap.round,
),
),
// Center content
Column(
mainAxisSize: MainAxisSize.min,
children: [
// Subtle scale animation when time is low
AnimatedContainer(
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutCubic,
transform: Matrix4.identity()..scale(_isLowTime ? 1.08 : 1.0),
child: Image.asset(
'assets/images/logo.gif',
width: 96,
height: 96,
fit: BoxFit.contain,
),
),
const SizedBox(height: 14),
// Clean, modern timer text
AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w600,
color:
_isLowTime ? Colors.orangeAccent : AppColor.writeColor,
letterSpacing: 1.2,
fontFeatures: const [FontFeature.tabularFigures()],
),
child: Text('${_timeLeft}s'),
),
],
),
],
),
),
);
}
}

View File

@@ -0,0 +1,52 @@
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,
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: Icon(
Icons.arrow_back_ios_new,
color: AppColor.primaryColor,
),
)
: const SizedBox(),
actions: [
action ?? Icon(
Icons.clear,
color: AppColor.secondaryColor,
)
],
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,523 @@
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';
// ─────────────────────────────────────────────────────────────────────────────
// Config
// ─────────────────────────────────────────────────────────────────────────────
class _DC {
static const Duration animDuration = Duration(milliseconds: 280);
static const double blur = 20.0;
static const double radius = 24.0;
static const Color barrierColor = Color(0x66000000);
}
// ─────────────────────────────────────────────────────────────────────────────
// Shared animated wrapper — every dialog uses this
// ─────────────────────────────────────────────────────────────────────────────
class _DialogShell extends StatelessWidget {
final Widget child;
const _DialogShell({required this.child});
@override
Widget build(BuildContext context) {
return TweenAnimationBuilder<double>(
duration: _DC.animDuration,
tween: Tween(begin: 0.0, end: 1.0),
curve: Curves.easeOutBack,
builder: (_, v, c) => Transform.scale(
scale: 0.88 + (0.12 * v),
child: Opacity(opacity: v.clamp(0.0, 1.0), child: c),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: _DC.blur, sigmaY: _DC.blur),
child: Dialog(
backgroundColor: Colors.transparent,
insetPadding:
const EdgeInsets.symmetric(horizontal: 28, vertical: 40),
child: child,
),
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// Shared glass card
// ─────────────────────────────────────────────────────────────────────────────
class _GlassCard extends StatelessWidget {
final Widget child;
const _GlassCard({required this.child});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(_DC.radius),
gradient: LinearGradient(
colors: [
AppColor.secondaryColor.withOpacity(0.95),
AppColor.secondaryColor.withOpacity(0.88),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.18),
blurRadius: 40,
spreadRadius: -4,
offset: const Offset(0, 16),
),
BoxShadow(
color: AppColor.primaryColor.withOpacity(0.08),
blurRadius: 20,
offset: const Offset(0, 4),
),
],
border: Border.all(
color: AppColor.secondaryColor.withOpacity(0.6),
width: 1.2,
),
),
child: child,
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// Shared bottom action row
// ─────────────────────────────────────────────────────────────────────────────
class _ActionRow extends StatelessWidget {
final VoidCallback onCancel;
final VoidCallback onConfirm;
final String confirmLabel;
final bool isDestructive;
const _ActionRow({
required this.onCancel,
required this.onConfirm,
this.confirmLabel = 'OK',
this.isDestructive = false,
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Colors.grey.withOpacity(0.15), width: 1),
),
),
child: Row(
children: [
// Cancel
Expanded(
child: _ActionButton(
label: 'Cancel'.tr,
color: Colors.grey[600]!,
backgroundColor: Colors.grey.withOpacity(0.07),
onPressed: () {
HapticFeedback.lightImpact();
onCancel();
},
isLeft: true,
),
),
Container(width: 1, height: 52, color: Colors.grey.withOpacity(0.15)),
// Confirm
Expanded(
child: _ActionButton(
label: confirmLabel,
color: isDestructive ? AppColor.redColor : AppColor.primaryColor,
backgroundColor: isDestructive
? AppColor.redColor.withOpacity(0.07)
: AppColor.primaryColor.withOpacity(0.07),
onPressed: () {
HapticFeedback.mediumImpact();
onConfirm();
},
isLeft: false,
isBold: true,
),
),
],
),
);
}
}
class _ActionButton extends StatelessWidget {
final String label;
final Color color;
final Color backgroundColor;
final VoidCallback onPressed;
final bool isLeft;
final bool isBold;
const _ActionButton({
required this.label,
required this.color,
required this.backgroundColor,
required this.onPressed,
required this.isLeft,
this.isBold = false,
});
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onPressed,
borderRadius: BorderRadius.only(
bottomLeft: isLeft ? const Radius.circular(_DC.radius) : Radius.zero,
bottomRight:
!isLeft ? const Radius.circular(_DC.radius) : Radius.zero,
),
child: Container(
height: 52,
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.only(
bottomLeft:
isLeft ? const Radius.circular(_DC.radius) : Radius.zero,
bottomRight:
!isLeft ? const Radius.circular(_DC.radius) : Radius.zero,
),
),
alignment: Alignment.center,
child: Text(
label,
style: TextStyle(
color: color,
fontSize: 15,
fontWeight: isBold ? FontWeight.w700 : FontWeight.w500,
letterSpacing: -0.2,
),
),
),
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// TTS speak button
// ─────────────────────────────────────────────────────────────────────────────
class _SpeakButton extends StatefulWidget {
final List<String> texts;
const _SpeakButton({required this.texts});
@override
State<_SpeakButton> createState() => _SpeakButtonState();
}
class _SpeakButtonState extends State<_SpeakButton>
with SingleTickerProviderStateMixin {
bool _speaking = false;
late AnimationController _pulse;
@override
void initState() {
super.initState();
_pulse = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 900),
lowerBound: 0.92,
upperBound: 1.0,
);
}
@override
void dispose() {
_pulse.dispose();
super.dispose();
}
Future<void> _onTap() async {
if (_speaking) return;
HapticFeedback.selectionClick();
setState(() => _speaking = true);
_pulse.repeat(reverse: true);
final tts = Get.find<TextToSpeechController>();
for (final t in widget.texts) {
await tts.speakText(t);
}
_pulse.stop();
_pulse.reset();
if (mounted) setState(() => _speaking = false);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _onTap,
child: AnimatedBuilder(
animation: _pulse,
builder: (_, child) =>
Transform.scale(scale: _pulse.value, child: child),
child: AnimatedContainer(
duration: const Duration(milliseconds: 250),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration: BoxDecoration(
color: _speaking
? AppColor.primaryColor.withOpacity(0.15)
: AppColor.primaryColor.withOpacity(0.08),
borderRadius: BorderRadius.circular(30),
border: Border.all(
color: AppColor.primaryColor.withOpacity(_speaking ? 0.4 : 0.15),
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
_speaking
? CupertinoIcons.speaker_3_fill
: CupertinoIcons.speaker_2_fill,
color: AppColor.primaryColor,
size: 16,
),
const SizedBox(width: 6),
Text(
_speaking ? 'Speaking...'.tr : 'Listen'.tr,
style: TextStyle(
color: AppColor.primaryColor,
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// MyDialog — title + text content
// ─────────────────────────────────────────────────────────────────────────────
class MyDialog extends GetxController {
void getDialog(
String title,
String? midTitle,
VoidCallback onPressed, {
IconData? icon,
bool isDestructive = false,
}) {
HapticFeedback.mediumImpact();
Get.dialog(
Builder(builder: (dialogContext) {
return _DialogShell(
child: _GlassCard(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// ── Body ──────────────────────────────────────────────
Padding(
padding: const EdgeInsets.fromLTRB(24, 28, 24, 20),
child: Column(
children: [
// Icon badge
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: (isDestructive
? AppColor.redColor
: AppColor.primaryColor)
.withOpacity(0.1),
border: Border.all(
color: (isDestructive
? AppColor.redColor
: AppColor.primaryColor)
.withOpacity(0.2),
),
),
child: Icon(
icon ??
(isDestructive
? Icons.warning_amber_rounded
: Icons.info_outline_rounded),
color: isDestructive
? AppColor.redColor
: AppColor.primaryColor,
size: 26,
),
),
const SizedBox(height: 16),
// Title
Text(
title,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(
fontSize: 18,
fontWeight: FontWeight.w700,
letterSpacing: -0.4,
color: AppColor.writeColor,
),
),
if (midTitle != null && midTitle.isNotEmpty) ...[
const SizedBox(height: 10),
Text(
midTitle,
textAlign: TextAlign.center,
style: AppStyle.subtitle.copyWith(
fontSize: 14.5,
height: 1.5,
color: Colors.grey[600],
),
),
const SizedBox(height: 16),
// TTS button
_SpeakButton(
texts: [title, if (midTitle.isNotEmpty) midTitle]),
],
],
),
),
// ── Actions ───────────────────────────────────────────
_ActionRow(
onCancel: () =>
Navigator.of(dialogContext, rootNavigator: true).pop(),
onConfirm: () {
// إغلاق الديالوج مباشرة باستخدام Navigator.pop
Navigator.of(dialogContext, rootNavigator: true).pop();
// تنفيذ الأمر بعد إغلاق الديالوج
Future.delayed(const Duration(milliseconds: 100), () {
onPressed();
});
},
confirmLabel: 'OK'.tr,
isDestructive: isDestructive,
),
],
),
),
);
}),
barrierDismissible: true,
barrierColor: _DC.barrierColor,
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// MyDialogContent — title + arbitrary widget content
// ─────────────────────────────────────────────────────────────────────────────
class MyDialogContent extends GetxController {
void getDialog(
String title,
Widget? content,
VoidCallback onPressed, {
IconData? icon,
bool isDestructive = false,
String confirmLabel = 'OK',
}) {
HapticFeedback.mediumImpact();
Get.dialog(
_DialogShell(
child: _GlassCard(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// ── Body ──────────────────────────────────────────────
Padding(
padding: const EdgeInsets.fromLTRB(24, 28, 24, 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header row: icon + title + TTS
Row(
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: (isDestructive
? AppColor.redColor
: AppColor.primaryColor)
.withOpacity(0.1),
),
child: Icon(
icon ??
(isDestructive
? Icons.warning_amber_rounded
: Icons.tune_rounded),
color: isDestructive
? AppColor.redColor
: AppColor.primaryColor,
size: 22,
),
),
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: AppStyle.title.copyWith(
fontSize: 17,
fontWeight: FontWeight.w700,
letterSpacing: -0.3,
color: AppColor.writeColor,
),
),
),
_SpeakButton(texts: [title]),
],
),
// Divider
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Divider(
height: 1,
color: Colors.grey.withOpacity(0.15),
),
),
// Content
if (content != null) content,
],
),
),
// ── Actions ───────────────────────────────────────────
_ActionRow(
onCancel: () => Get.back(),
onConfirm: () {
Get.back(); // Dismiss dialog first
WidgetsBinding.instance.addPostFrameCallback((_) {
onPressed();
});
},
confirmLabel: confirmLabel.tr,
isDestructive: isDestructive,
),
],
),
),
),
barrierDismissible: true,
barrierColor: _DC.barrierColor,
);
}
}

View File

@@ -0,0 +1,290 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../controller/voice_call_controller.dart';
class VoiceCallBottomSheet extends StatelessWidget {
const VoiceCallBottomSheet({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final controller = Get.find<VoiceCallController>();
final double screenHeight = MediaQuery.of(context).size.height;
final bool isDark = Theme.of(context).brightness == Brightness.dark;
// Harmonious curated colors
final Color bgColor = isDark ? const Color(0xFF121212) : Colors.white;
final Color cardColor = isDark ? const Color(0xFF1E1E1E) : const Color(0xFFF5F5F7);
final Color textColor = isDark ? Colors.white : const Color(0xFF1C1C1E);
final Color subTextColor = isDark ? Colors.white70 : Colors.black54;
return WillPopScope(
onWillPop: () async => false,
child: Container(
height: screenHeight * 0.9,
decoration: BoxDecoration(
color: bgColor,
borderRadius: const BorderRadius.vertical(top: Radius.circular(32)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 20,
offset: const Offset(0, -5),
)
],
),
child: Obx(() {
final state = controller.state.value;
final seconds = controller.elapsedSeconds.value;
final remoteName = controller.remoteName.value;
final isMuted = controller.isMuted.value;
final isSpeakerOn = controller.isSpeakerOn.value;
// Progress ring logic
final double progress = seconds / 60.0;
final Color ringColor = seconds > 10 ? const Color(0xFF2ECC71) : const Color(0xFFE74C3C);
// Status text translations
String statusText = "";
switch (state) {
case VoiceCallState.dialing:
statusText = "${'Calling'.tr} $remoteName...";
break;
case VoiceCallState.ringing:
statusText = "${'Captain'.tr} $remoteName ${'is calling you'.tr}...";
break;
case VoiceCallState.connecting:
statusText = "Connecting...".tr;
break;
case VoiceCallState.active:
statusText = "Call Connected".tr;
break;
case VoiceCallState.ended:
statusText = "Call Ended".tr;
break;
case VoiceCallState.idle:
statusText = "";
break;
}
return Column(
children: [
// Top Drag Handle Indicator
Center(
child: Container(
margin: const EdgeInsets.only(top: 12, bottom: 24),
width: 44,
height: 5,
decoration: BoxDecoration(
color: isDark ? Colors.white24 : Colors.black12,
borderRadius: BorderRadius.circular(10),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Header Info
Column(
children: [
Text(
"Free Call".tr,
style: TextStyle(
color: ringColor,
fontWeight: FontWeight.w800,
fontSize: 14,
letterSpacing: 1.2,
),
),
const SizedBox(height: 8),
Text(
remoteName,
style: TextStyle(
color: textColor,
fontWeight: FontWeight.w900,
fontSize: 26,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
statusText,
style: TextStyle(
color: subTextColor,
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
],
),
// Avatar & Animated Progress Ring
Stack(
alignment: Alignment.center,
children: [
// Progress ring around avatar (Active state only)
if (state == VoiceCallState.active)
SizedBox(
width: 172,
height: 172,
child: CircularProgressIndicator(
value: progress,
strokeWidth: 5,
backgroundColor: isDark ? Colors.white10 : Colors.black12,
valueColor: AlwaysStoppedAnimation<Color>(ringColor),
),
),
// Main Avatar Card
Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: cardColor,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 15,
offset: const Offset(0, 8),
)
],
),
child: Center(
child: remoteName.isNotEmpty
? Text(
remoteName[0].toUpperCase(),
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
fontSize: 54,
),
)
: Icon(
Icons.person,
color: textColor.withOpacity(0.6),
size: 64,
),
),
),
],
),
// Timer Counter Display
if (state == VoiceCallState.active)
Text(
"0:${seconds.toString().padLeft(2, '0')}",
style: TextStyle(
color: seconds > 10 ? textColor : const Color(0xFFE74C3C),
fontWeight: FontWeight.bold,
fontSize: 22,
fontFamily: 'monospace',
),
)
else
const SizedBox(height: 24),
// Action Controls Block
if (state == VoiceCallState.ringing)
// Incoming Ringing Controls: Accept / Decline
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildCircleActionButton(
icon: Icons.call_end_rounded,
color: Colors.white,
bgColor: const Color(0xFFE74C3C),
onTap: () => controller.declineCall(),
label: "Decline".tr,
),
_buildCircleActionButton(
icon: Icons.call_rounded,
color: Colors.white,
bgColor: const Color(0xFF2ECC71),
onTap: () => controller.acceptCall(),
label: "Accept".tr,
),
],
)
else
// Dialing or Connected Controls: Speaker / Mute / Hangup
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Speakerphone toggle
_buildCircleActionButton(
icon: isSpeakerOn ? Icons.volume_up_rounded : Icons.volume_down_rounded,
color: isSpeakerOn ? Colors.white : textColor,
bgColor: isSpeakerOn ? const Color(0xFF2ECC71) : cardColor,
onTap: () => controller.toggleSpeaker(),
label: "Speaker".tr,
),
// Hangup Call
_buildCircleActionButton(
icon: Icons.call_end_rounded,
color: Colors.white,
bgColor: const Color(0xFFE74C3C),
onTap: () => controller.hangup(),
label: "End".tr,
),
// Mute Microphone
_buildCircleActionButton(
icon: isMuted ? Icons.mic_off_rounded : Icons.mic_rounded,
color: isMuted ? Colors.white : textColor,
bgColor: isMuted ? const Color(0xFFE74C3C) : cardColor,
onTap: () => controller.toggleMute(),
label: "Mute".tr,
),
],
),
],
),
),
),
],
);
}),
),
);
}
Widget _buildCircleActionButton({
required IconData icon,
required Color color,
required Color bgColor,
required VoidCallback onTap,
required String label,
}) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: onTap,
style: ElevatedButton.styleFrom(
shape: const CircleBorder(),
padding: const EdgeInsets.all(18),
backgroundColor: bgColor,
foregroundColor: color,
elevation: 2,
),
child: Icon(icon, size: 28),
),
const SizedBox(height: 8),
Text(
label,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.grey,
),
),
],
);
}
}