لتحسين مظهر القائمة داخل الـ AlertDialog دون التأثير على عملها، يمكننا إجراء بعض التعديلات التي تضيف تحسينات بصرية وتجعل التنسيق أنيقًا أكثر، مثل:
- إضافة حدود محددة لكل سجل (Card أو Container مع BoxDecoration).
- زيادة تباعد العناصر padding/margin من أجل وضوح المحتوى.
- تحسين شكل الأيقونات (مثلاً Icon داخل CircleAvatar).
- استخدام Text.rich أو RichText إذا أردنا تمييز أجزاء معينة من النصوص.
- تحسين ألوان النصوص والخطوط مع الالتزام بالخط المستخدم (tajawalFont) والتنسيق من اليمين لليسار.
- جعل العناوين والوصف أكثر وضوحًا.
- تحسين الشكل العام لبعض المكونات مثل الـ trailing icon button لتكون أكثر وضوحًا.
إليك نسخة محسنة من الدالة مع هذه التحسينات:
void _showTransferLogsDialog() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text(
'سجل عمليات التحويل',
textAlign: TextAlign.right,
style: TextStyle(fontFamily: tajawalFont, fontWeight: FontWeight.bold),
),
content: SizedBox(
width: double.maxFinite,
child: _transferLogs.isEmpty
? Center(
child: Text(
'لا توجد عمليات تحويل حتى الآن',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontFamily: tajawalFont,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
)
: Directionality(
textDirection: TextDirection.rtl,
child: ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _transferLogs.length,
itemBuilder: (_, i) {
final log = _transferLogs[i];
final success = log['success'] as bool;
final timestamp = log['timestamp'] != null
? DateTime.parse(log['timestamp'])
: null;
final timeFormatted = timestamp != null
? '${timestamp.year}-${timestamp.month.toString().padLeft(2, '0')}-${timestamp.day.toString().padLeft(2, '0')} ${timestamp.hour.toString().padLeft(2, '0')}:${timestamp.minute.toString().padLeft(2, '0')}'
: '';
return Container(
margin: const EdgeInsets.symmetric(vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.2),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: success
? Theme.of(context).colorScheme.primary.withOpacity(0.6)
: Theme.of(context).colorScheme.error.withOpacity(0.6),
width: 1,
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 20,
backgroundColor: success
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.errorContainer,
child: Icon(
success ? Icons.check : Icons.close,
color: success
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.error,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${_getMethodName(log['method'])} - ${log['number']}',
style: TextStyle(
fontWeight: FontWeight.w700,
fontFamily: tajawalFont,
fontSize: 16,
),
textAlign: TextAlign.right,
),
const SizedBox(height: 4),
Text(
'المبلغ: ${_formatWithThousandsSeparator(log['amount'] ?? 0)}',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 14,
),
textAlign: TextAlign.right,
),
if (timeFormatted.isNotEmpty)
Text(
'الوقت: $timeFormatted',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 12,
color: Colors.grey[600],
),
textAlign: TextAlign.right,
),
if (log['error'] != null)
Text(
'خطأ: ${log['error']}',
style: TextStyle(
fontFamily: tajawalFont,
fontSize: 12,
color: Colors.red[700],
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.right,
),
],
),
),
IconButton(
icon: Icon(
Icons.delete_forever_rounded,
color: Theme.of(context).colorScheme.error,
size: 28,
),
tooltip: 'حذف السجل',
onPressed: () {
_removeTransferLog(i);
Navigator.pop(context);
Future.delayed(
const Duration(milliseconds: 100),
_showTransferLogsDialog,
);
},
),
],
),
);
},
),
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'إغلاق',
style: TextStyle(fontFamily: tajawalFont),
),
),
TextButton(
onPressed: () {
setState(() {
_transferLogs.clear();
});
_saveTransferHistory();
Navigator.pop(context);
_showSnackBar('تم حذف جميع سجلات التحويل');
},
child: const Text(
'حذف الكل',
style: TextStyle(fontFamily: tajawalFont),
),
),
TextButton(
onPressed: () {
Navigator.pop(context);
_exportTransferLogsToCsv();
},
child: const Text(
'تصدير Excel',
style: TextStyle(fontFamily: tajawalFont),
),
),
],
);
},
);
}
ما تم تحسينه:
- استبدال
ListTile بتصميم مخصص داخل Container مع حدود واضحة وزوايا دائرية لجعل كل سجل أكثر وضوحاً.
- استخدام
CircleAvatar للأيقونات الدائرية بدلاً من Container مع BoxDecoration لأنها تبسط الكود وتعطي شكل مريح.
- زيادة المسافات البادئة (
margin و padding) بين العناصر لتحسين القراءة.
- تحسين حجم الخطوط وأوزانها، مع ترك النصوص من اليمين لليسار.
- الألوان تم تحسينها قليلًا لتتناسب مع ثيم التطبيق وتعطي تباين واضح.
- جعل محتوى النصوص متوائمًا مع اتجاه النص (محاذاة يمين).
هذه التعديلات ستجعل القائمة تبدو أكثر عصرية ونظافة مع الحفاظ على نفس الوظائف تمامًا.
إذا تريد يمكنني مساعدتك أيضاً في إضافة عناصر تحسين أخرى مثل دعم الـDark Mode أو إضافة انميشن بسيطة عند الحذف. فقط أخبرني!