turns-00082.parquet:1650
8efbec355c736e7c1de576a1
turn 1/2gpt-4.1-mini-2025-04-14EnglishYemen1541 words
degenerate_repetitionAbsentFinal dense release
USER
اريد اعادة تصميم الواجهه لهذا الكود
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text(
'المحفظة الرقيمة',
style: TextStyle(fontFamily: tajawalFont),
textAlign: TextAlign.center,
),
content: StatefulBuilder(
builder: (context, setDialogState) {
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (_savedAmounts.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Text(
'لا توجد مبالغ محفوظة حالياً',
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
fontFamily: tajawalFont,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
if (_savedAmounts.isNotEmpty)
Container(
constraints: BoxConstraints(maxHeight: 150),
child: SingleChildScrollView(
child: Wrap(
spacing: 8,
runSpacing: 6,
children:
_savedAmounts
.map(
(amt) => Tooltip(
message: 'حذف هذا المبلغ',
child: Chip(
label: Text(
_formatWithThousandsSeparator(amt),
style: const TextStyle(
fontFamily: tajawalFont,
fontWeight: FontWeight.w600,
),
),
backgroundColor:
Theme.of(
context,
).colorScheme.primaryContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
20,
),
),
onDeleted: () {
setDialogState(() {
_savedAmounts.remove(amt);
});
},
deleteIconColor:
Theme.of(
context,
).colorScheme.error,
),
),
)
.toList(),
),
),
),
const Divider(height: 25, thickness: 1),
TextField(
controller: amountsController,
keyboardType: TextInputType.number,
inputFormatters: [ThousandsSeparatorInputFormatter()],
decoration: InputDecoration(
labelText: 'إضافة مبلغ جديد',
suffixIcon: IconButton(
icon: const Icon(Icons.add_circle_rounded),
tooltip: 'إضافة المبلغ',
onPressed:
isValidInput(amountsController.text)
? () => addAmount(
amountsController.text,
setDialogState,
)
: null,
),
),
onChanged: (value) {
setDialogState(() {}); // لتحديث زر الإضافة
},
onSubmitted: (value) {
addAmount(value, setDialogState);
},
),
],
),
);
},
),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'إغلاق',
style: TextStyle(fontFamily: tajawalFont),
),
),
FilledButton.tonal(
onPressed: () async {
await _saveSavedAmounts();
Navigator.pop(context);
_showSnackBar('تم حفظ المبالغ بنجاح');
},
child: const Text(
'حفظ',
style: TextStyle(fontFamily: tajawalFont),
),
),
],
);
},
);
لتصبح مثل الواجهه في هذا الكود مع مراعاة المسميات والايقونات واسلوب العرض
await showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
elevation: 8,
insetPadding: const EdgeInsets.all(20),
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 20,
),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(24),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.primary.withOpacity(0.1),
shape: BoxShape.circle,
),
child: Icon(
Icons.monetization_on_rounded,
size: 28,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(width: 12),
Text(
'المحفظة الرقمية',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onSurface,
),
),
],
),
const SizedBox(height: 24),
// Saved Amounts List
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surfaceVariant.withOpacity(0.1),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Theme.of(
context,
).colorScheme.outline.withOpacity(0.15),
),
),
child:
_savedAmounts.isEmpty
? Column(
children: [
Icon(
Icons.wallet_rounded,
size: 40,
color: Theme.of(
context,
).colorScheme.primary.withOpacity(0.5),
),
const SizedBox(height: 12),
Text(
'أضف المبالغ التي تريد استخدامها بشكل متكرر',
style: TextStyle(
fontFamily: tajawalFont,
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
fontSize: 14,
),
textAlign: TextAlign.center,
),
],
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'اختر من المبالغ المحفوظة:',
style: TextStyle(
fontFamily: tajawalFont,
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 12),
SizedBox(
height: 120,
child: ListView.builder(
itemCount: _savedAmounts.length,
itemBuilder: (context, index) {
final amount = _savedAmounts[index];
return ListTile(
contentPadding: EdgeInsets.zero,
leading: Radio<int>(
value: amount,
groupValue: _savedAmounts.first,
onChanged: (value) {
setState(() {
amountsController.text =
_formatWithThousandsSeparator(
value!,
);
});
},
),
title: Text(
_formatWithThousandsSeparator(
amount,
),
style: TextStyle(
fontFamily: tajawalFont,
fontWeight: FontWeight.w600,
),
),
trailing: IconButton(
icon: Icon(
Icons.delete_outline,
color:
Theme.of(
context,
).colorScheme.error,
),
onPressed: () {
setState(() {
_savedAmounts.remove(amount);
if (_savedAmounts
.isNotEmpty) {
amountsController.text =
_formatWithThousandsSeparator(
_savedAmounts.first,
);
} else {
amountsController.clear();
}
});
},
),
);
},
),
),
],
),
),
const SizedBox(height: 20),
// Amount Input Field
TextField(
controller: amountsController,
keyboardType: TextInputType.number,
inputFormatters: [ThousandsSeparatorInputFormatter()],
decoration: InputDecoration(
labelText: 'أو أدخل مبلغًا جديدًا',
labelStyle: TextStyle(
fontFamily: tajawalFont,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
),
suffixIcon: IconButton(
icon: Icon(
Icons.add_circle_rounded,
color: Theme.of(context).colorScheme.primary,
size: 28,
),
onPressed: () {
final raw = amountsController.text.replaceAll(
',',
'',
);
final numAmount = int.tryParse(raw);
if (numAmount == null || numAmount <= 0) {
_showSnackBar(
'يرجى إدخال مبلغ صحيح أكبر من صفر',
);
return;
}
if (_savedAmounts.contains(numAmount)) {
_showSnackBar('هذا المبلغ موجود بالفعل');
return;
}
setState(() {
_savedAmounts.add(numAmount);
_savedAmounts.sort();
amountsController
.clear(); // التفريغ داخل setState
});
},
),
filled: true,
fillColor: Colors.grey.withOpacity(
0.15,
), // خلفية رمادية باهتة
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide.none,
),
),
onSubmitted: (value) {
final raw = value.replaceAll(',', '');
final numAmount = int.tryParse(raw);
if (numAmount == null || numAmount <= 0) {
_showSnackBar('يرجى إدخال مبلغ صحيح أكبر من صفر');
return;
}
if (_savedAmounts.contains(numAmount)) {
_showSnackBar('هذا المبلغ موجود بالفعل');
return;
}
setState(() {
_savedAmounts.add(numAmount);
_savedAmounts.sort();
amountsController.clear(); // التفريغ داخل setState
});
},
),
const SizedBox(height: 24),
// Action Buttons
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
OutlinedButton(
onPressed: () => Navigator.pop(context),
style: OutlinedButton.styleFrom(
foregroundColor:
Theme.of(context).colorScheme.onSurface,
side: BorderSide(
color: Theme.of(
context,
).colorScheme.outline.withOpacity(0.4),
),
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Text(
'تخطي',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 15,
),
),
),
const SizedBox(width: 12),
ElevatedButton(
onPressed: () async {
if (_savedAmounts.isEmpty) {
_showSnackBar(
'الرجاء إدخال مبلغ واحد على الأقل',
);
return;
}
await _saveSavedAmounts();
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.primary,
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Text(
'حفظ',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
),
],
),
],
),
),
),
);
},
);
},
);ASSISTANT
بالطبع، سأعيد تصميم واجهة الحوار (AlertDialog) الأولى ليصبح مظهرها وهيكلها مشابهين للواجهة الثانية (Dialog) التي أرفقتها، مع مراعاة استخدام نفس المسميات، الأيقونات، وأسلوب العرض. سأحافظ أيضاً على الوظائف نفسها مثل حذف المبالغ، إضافة مبلغ جديد، والتنقل.
إليك الكود بعد إعادة التصميم:
```dart
await showDialog(
context: context,
barrierDismissible: false, // منع الإغلاق بالنقر خارجيًا كمثل الكود الثاني
builder: (context) {
return StatefulBuilder(
builder: (context, setDialogState) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
elevation: 8,
insetPadding: const EdgeInsets.all(20),
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(24),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// العنوان مع الأيقونة
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.1),
shape: BoxShape.circle,
),
child: Icon(
Icons.monetization_on_rounded,
size: 28,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(width: 12),
Text(
'المحفظة الرقمية',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onSurface,
),
),
],
),
const SizedBox(height: 24),
// محتوى المبالغ المحفوظة
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.surfaceVariant
.withOpacity(0.1),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color:
Theme.of(context).colorScheme.outline.withOpacity(0.15),
),
),
child: _savedAmounts.isEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.wallet_rounded,
size: 40,
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.5),
),
const SizedBox(height: 12),
Text(
'أضف المبالغ التي تريد استخدامها بشكل متكرر',
style: TextStyle(
fontFamily: tajawalFont,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 14,
),
textAlign: TextAlign.center,
),
],
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'اختر من المبالغ المحفوظة:',
style: TextStyle(
fontFamily: tajawalFont,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 12),
SizedBox(
height: 120,
child: ListView.builder(
itemCount: _savedAmounts.length,
itemBuilder: (context, index) {
final amount = _savedAmounts[index];
return ListTile(
contentPadding: EdgeInsets.zero,
leading: Radio<int>(
value: amount,
groupValue: null, // أو أي قيمة مناسبة إذا تود التحكم هنا
onChanged: (value) {
setDialogState(() {
amountsController.text =
_formatWithThousandsSeparator(value!);
});
},
),
title: Text(
_formatWithThousandsSeparator(amount),
style: const TextStyle(
fontFamily: tajawalFont,
fontWeight: FontWeight.w600,
),
),
trailing: IconButton(
icon: Icon(
Icons.delete_outline,
color: Theme.of(context).colorScheme.error,
),
onPressed: () {
setDialogState(() {
_savedAmounts.remove(amount);
if (_savedAmounts.isNotEmpty) {
amountsController.text =
_formatWithThousandsSeparator(_savedAmounts.first);
} else {
amountsController.clear();
}
});
},
),
);
},
),
),
],
),
),
const SizedBox(height: 20),
// حقل إدخال المبلغ الجديد
TextField(
controller: amountsController,
keyboardType: TextInputType.number,
inputFormatters: [ThousandsSeparatorInputFormatter()],
decoration: InputDecoration(
labelText: 'أو أدخل مبلغًا جديدًا',
labelStyle: TextStyle(
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
suffixIcon: IconButton(
icon: Icon(
Icons.add_circle_rounded,
color: Theme.of(context).colorScheme.primary,
size: 28,
),
tooltip: 'إضافة المبلغ',
onPressed: () {
final raw = amountsController.text.replaceAll(',', '');
final numAmount = int.tryParse(raw);
if (numAmount == null || numAmount <= 0) {
_showSnackBar('يرجى إدخال مبلغ صحيح أكبر من صفر');
return;
}
if (_savedAmounts.contains(numAmount)) {
_showSnackBar('هذا المبلغ موجود بالفعل');
return;
}
setDialogState(() {
_savedAmounts.add(numAmount);
_savedAmounts.sort();
amountsController.clear();
});
},
),
filled: true,
fillColor: Colors.grey.withOpacity(0.15),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide.none,
),
),
onSubmitted: (value) {
final raw = value.replaceAll(',', '');
final numAmount = int.tryParse(raw);
if (numAmount == null || numAmount <= 0) {
_showSnackBar('يرجى إدخال مبلغ صحيح أكبر من صفر');
return;
}
if (_savedAmounts.contains(numAmount)) {
_showSnackBar('هذا المبلغ موجود بالفعل');
return;
}
setDialogState(() {
_savedAmounts.add(numAmount);
_savedAmounts.sort();
amountsController.clear();
});
},
),
const SizedBox(height: 24),
// أزرار الإجراءات
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
OutlinedButton(
onPressed: () => Navigator.pop(context),
style: OutlinedButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.onSurface,
side: BorderSide(
color: Theme.of(context).colorScheme.outline.withOpacity(0.4),
),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Text(
'إغلاق',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 15,
),
),
),
const SizedBox(width: 12),
ElevatedButton(
onPressed: () async {
if (_savedAmounts.isEmpty) {
_showSnackBar('الرجاء إدخال مبلغ واحد على الأقل');
return;
}
await _saveSavedAmounts();
Navigator.pop(context);
_showSnackBar('تم حفظ المبالغ بنجاح');
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Text(
'حفظ',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
),
],
),
],
),
),
),
);
},
);
},
);
```
---
### ملاحظات على إعادة التصميم:
- تم استبدال `AlertDialog` بـ `Dialog` مع شكله وحواف دائرية للتماشي مع التصميم الجديد.
- **العنوان** أصبح يحتوي على أيقونة دائرية على اليسار وكلمة "المحفظة الرقمية" بهذا النمط.
- منطقة عرض المبالغ المحفوظة أصبحت تحتوي على صندوق بحدود دائرية وخلفية مخففة كما في النموذج الثاني، وتعرض قائمة المبالغ أو رسالة توضيحية مع أيقونة.
- حقل الإدخال أصبح بالتصميم ذاته مع خلفية رمادية فاتحة وحدود دائرية.
- أزرار "إغلاق" و"حفظ" تم تهيئتها لتكون كما في الكود الثاني من حيث التصميم والمكان.
- تم إزالة إدارة حالة `setDialogState` داخل `StatefulBuilder`، كما هو موجود في الكود الثاني.
---
إذا أردت تفاصيل/تعديلات أخرى على أي من العناصر فقط أخبرني.