USER
حل مشاكل ال overloaded by pixel
await showDialog(
context: context,
builder: (context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Dialog(
insetPadding: const EdgeInsets.all(16), // إضافة مسافة حول الدايلوج
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
elevation: 8,
child: StatefulBuilder(
builder: (context, setDialogState) {
return ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.9,
maxHeight: MediaQuery.of(context).size.height * 0.8,
),
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom, // أخذ لوحة المفاتيح في الاعتبار
),
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
child: Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(24),
),
child: Column(
mainAxisSize: MainAxisSize.min, // لجعل العمود يأخذ أقل مساحة ممكنة
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Header
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(
Icons.close,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
),
onPressed: () => Navigator.pop(context),
),
Text(
'المحفظة الرقمية',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 20,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
Icon(
Icons.account_balance_wallet_rounded,
color: Theme.of(context).colorScheme.primary,
),
],
),
const SizedBox(height: 24),
// Amount Cards Grid أو رسالة عدم وجود مبالغ
if (_savedAmounts.isNotEmpty)
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.4,
),
child: GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), // تعطيل التمرير الخاص بالجريد
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 12,
crossAxisSpacing: 12,
childAspectRatio: 1.8,
),
itemCount: _savedAmounts.length,
itemBuilder: (context, index) {
final amt = _savedAmounts[index];
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(16),
),
padding: const EdgeInsets.all(12),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
icon: Icon(
Icons.delete_outline,
size: 20,
color: Theme.of(context).colorScheme.error,
),
onPressed: () {
setDialogState(() {
_savedAmounts.removeAt(index);
});
},
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'المبلغ',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 12,
color: Theme.of(context)
.colorScheme
.onPrimaryContainer
.withOpacity(0.8),
),
),
Text(
'${_formatWithThousandsSeparator(amt)} ريال',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 18,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
],
),
],
),
);
},
),
)
else
Container(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Column(
children: [
Icon(
Icons.wallet_outlined,
size: 48,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.3),
),
const SizedBox(height: 16),
Text(
'لا توجد مبالغ محفوظة',
style: TextStyle(
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
),
),
const SizedBox(height: 8),
Text(
'قم بإضافة مبالغك المفضلة',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 12,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.4),
),
),
],
),
),
const SizedBox(height: 24),
// Add Amount Section
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.1),
borderRadius: BorderRadius.circular(16),
),
padding: const EdgeInsets.all(16),
child: Column(
children: [
TextField(
controller: amountsController,
keyboardType: TextInputType.number,
inputFormatters: [ThousandsSeparatorInputFormatter()],
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
decoration: InputDecoration(
hintText: 'أدخل المبلغ',
hintStyle: TextStyle(
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
),
prefixIcon: Icon(
Icons.attach_money_rounded,
color: Theme.of(context).colorScheme.primary,
),
suffixText: 'ريال سعودي',
suffixStyle: TextStyle(
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.primary,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
filled: true,
fillColor: Theme.of(context).colorScheme.surface,
),
onChanged: (value) {
setDialogState(() {});
},
onSubmitted: (value) {
if (isValidInput(value)) {
addAmount(value, setDialogState);
}
},
),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: FilledButton.icon(
onPressed: isValidInput(amountsController.text)
? () => addAmount(amountsController.text, setDialogState)
: null,
icon: const Icon(Icons.add),
label: const Text(
'إضافة إلى المحفظة',
style: TextStyle(fontFamily: tajawalFont),
),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
],
),
),
const SizedBox(height: 16),
// Save Button
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () async {
await _saveSavedAmounts();
Navigator.pop(context);
_showSnackBar('تم تحديث المحفظة بنجاح');
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Text(
'حفظ التغييرات',
style: TextStyle(
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onPrimary,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
),
),
);
},
),
),
);
},
);