gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
اريد تغيير هذا التصميم الى شكل اكثر اناقة void showSavedNumbersSelection() async { final…
- User
اريد تغيير هذا التصميم الى شكل اكثر اناقة void _showSavedNumbersSelection() async { final hasPermission = await _requestPermissions(); if (!hasPermission) return;
final contacts = await FlutterContacts.getContacts( withProperties: true, withThumbnail: true, ); List<String> selectedNumbers = List.from(_savedNumbers); TextEditingController searchController = TextEditingController(); String searchQuery = ''; showModalBottomSheet( context: context, isScrollControlled: true, builder: (context) { return StatefulBuilder( builder: (context, setModal) { final filteredContacts = searchQuery.isEmpty ? contacts : contacts.where((contact) { final contactNameLower = contact.displayName.toLowerCase(); final queryLower = searchQuery.toLowerCase(); final phonesMatch = contact.phones.any( (phone) => phone.number.toLowerCase().contains(queryLower), ); return contactNameLower.contains(queryLower) || phonesMatch; }).toList(); return Container( height: MediaQuery.of(context).size.height * 0.85, padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), child: Column( children: [ Padding( padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 12, ), child: Row( children: [ Expanded( child: TextField( controller: searchController, decoration: InputDecoration( prefixIcon: const Icon(Icons.search), hintText: 'ابحث في جهات الاتصال أو الأرقام', isDense: true, ), onChanged: (value) { setModal(() { searchQuery = value.trim(); }); }, ), ), const SizedBox(width: 8), IconButton( icon: const Icon(Icons.close_rounded), onPressed: () => Navigator.pop(context), tooltip: 'إغلاق', ), ], ), ), const Divider(height: 1), Expanded( child: filteredContacts.isEmpty ? Center( child: Text( 'لا توجد جهات اتصال تطابق البحث', style: Theme.of( context, ).textTheme.bodyMedium?.copyWith( fontFamily: tajawalFont, color: Theme.of( context, ).colorScheme.onSurfaceVariant, ), ), ) : ListView.builder( keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, physics: const BouncingScrollPhysics(), itemCount: filteredContacts.length, itemBuilder: (context, index) { final contact = filteredContacts[index]; final phones = contact.phones; return Card( margin: const EdgeInsets.symmetric( horizontal: 12, vertical: 6, ), child: Padding( padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 12, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( contentPadding: EdgeInsets.zero, leading: CircleAvatar( radius: 24, backgroundImage: (contact.thumbnail != null && contact .thumbnail! .isNotEmpty) ? MemoryImage( contact.thumbnail!, ) : null, child: (contact.thumbnail == null || contact .thumbnail! .isEmpty) ? Text( contact.initials(), style: const TextStyle( fontFamily: tajawalFont, fontWeight: FontWeight.bold, color: Colors.white, fontSize: 18, ), ) : null, backgroundColor: Theme.of( context, ).colorScheme.primary, ), title: Text( contact.displayName, style: const TextStyle( fontFamily: tajawalFont, fontSize: 16, fontWeight: FontWeight.w600, ), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), const SizedBox(height: 4), Column( children: phones.map((phone) { final normalized = phone.number .replaceAll( RegExp(r'[^\d+]'), '', ); final isSelected = selectedNumbers.any((num) { final n = num.replaceAll( RegExp(r'[^\d+]'), '', ); return n == normalized; }); return CheckboxListTile( contentPadding: EdgeInsets.zero, value: isSelected, title: Text( phone.number, style: const TextStyle( fontFamily: tajawalFont, fontSize: 14, fontWeight: FontWeight.w500, ), ), controlAffinity: ListTileControlAffinity .leading, onChanged: (val) { setModal(() { if (val == true) { if (!selectedNumbers.any( (num) { final n = num.replaceAll( RegExp( r'[^\d+]', ), '', ); return n == normalized; }, )) { selectedNumbers.add( phone.number, ); } } else { selectedNumbers .removeWhere((num) { final n = num.replaceAll( RegExp( r'[^\d+]', ), '', ); return n == normalized; }); } }); }, ); }).toList(), ), ], ), ), ); }, ), ), Padding( padding: const EdgeInsets.all(16), child: Row( children: [ Expanded( child: OutlinedButton( onPressed: () => Navigator.pop(context), child: const Text( 'إلغاء', style: TextStyle(fontFamily: tajawalFont), ), ), ), const SizedBox(width: 12), Expanded( child: FilledButton( onPressed: () async { _savedNumbers = List.from(selectedNumbers); await _saveSavedNumbers(); Navigator.pop(context); _showSnackBar('تم حفظ الأرقام المختارة'); if (mounted) setState(() {}); }, child: const Text( 'حفظ', style: TextStyle(fontFamily: tajawalFont), ), ), ), ], ), ), ], ), ); }, ); }, );}
- Assistant
لتطوير تصميم هذه القائمة وجعلها أكثر أناقة وعصرية، يُفضّل اتباع بعض المبادئ المهمة في التصميم مثل تبسيط الواجهة، استخدام ألوان متناسقة، تحسين استخدام المساحات، إضافة تأثيرات بصرية خفيفة، وتحسين تجربة المستخدم في التفاعل مع القائمة.
في ما يلي نسخة محسنة من كودك مع بعض التغييرات التصميمية:
- استخدام
Cardذو ظل خفيف. - إضافة هوامش داخلية أو padding أفضل.
- استخدام
ListTileبشكل أفعال الاختيار بدلاً من CheckboxListTile لجعل الشكل أنظف. - تحسين ألوان النصوص بما يتوافق مع الوضع المظلم والفاتح (لو موجود في app).
- جعل البحث أكثر بروزًا وبمسافة.
- استخدام
ElevatedButtonوOutlinedButtonبألوان مناسبة. - تحسين ظهور الصور ودائرية الـ avatar.
- إضافة تهذيب في عرض الأسماء والأرقام.
- تحسين استخدام الفضاءات البيضاء.
void _showSavedNumbersSelection() async { final hasPermission = await _requestPermissions(); if (!hasPermission) return; final contacts = await FlutterContacts.getContacts( withProperties: true, withThumbnail: true, ); List<String> selectedNumbers = List.from(_savedNumbers); TextEditingController searchController = TextEditingController(); String searchQuery = ''; showModalBottomSheet( context: context, isScrollControlled: true, backgroundColor: Theme.of(context).scaffoldBackgroundColor, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(20)), ), builder: (context) { return StatefulBuilder( builder: (context, setModal) { final filteredContacts = searchQuery.isEmpty ? contacts : contacts.where((contact) { final contactNameLower = contact.displayName.toLowerCase(); final queryLower = searchQuery.toLowerCase(); final phonesMatch = contact.phones.any( (phone) => phone.number.toLowerCase().contains(queryLower), ); return contactNameLower.contains(queryLower) || phonesMatch; }).toList(); return Container( height: MediaQuery.of(context).size.height * 0.85, padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, left: 16, right: 16, top: 16, ), child: Column( children: [ // شريط البحث مع شكل أنيق Row( children: [ Expanded( child: TextField( controller: searchController, decoration: InputDecoration( hintText: 'ابحث في جهات الاتصال أو الأرقام', prefixIcon: const Icon(Icons.search), filled: true, fillColor: Theme.of(context).inputDecorationTheme.fillColor ?? Colors.grey.shade200, contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), border: OutlineInputBorder( borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none, ), ), onChanged: (value) { setModal(() { searchQuery = value.trim(); }); }, ), ), const SizedBox(width: 12), IconButton( icon: const Icon(Icons.close_rounded), onPressed: () => Navigator.pop(context), tooltip: 'إغلاق', ), ], ), const SizedBox(height: 12), Expanded( child: filteredContacts.isEmpty ? Center( child: Text( 'لا توجد جهات اتصال تطابق البحث', style: Theme.of(context).textTheme.bodyMedium?.copyWith( fontFamily: tajawalFont, color: Theme.of(context).colorScheme.onSurfaceVariant, ), ), ) : Scrollbar( thumbVisibility: true, radius: const Radius.circular(10), thickness: 6, child: ListView.separated( keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, physics: const BouncingScrollPhysics(), itemCount: filteredContacts.length, separatorBuilder: (_, __) => const SizedBox(height: 8), itemBuilder: (context, index) { final contact = filteredContacts[index]; final phones = contact.phones; return Card( elevation: 2, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), shadowColor: Theme.of(context).colorScheme.primary.withOpacity(0.2), child: Padding( padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( contentPadding: EdgeInsets.zero, leading: CircleAvatar( radius: 26, backgroundImage: (contact.thumbnail != null && contact.thumbnail!.isNotEmpty) ? MemoryImage(contact.thumbnail!) : null, backgroundColor: Theme.of(context).colorScheme.primary, child: (contact.thumbnail == null || contact.thumbnail!.isEmpty) ? Text( contact.initials(), style: const TextStyle( fontFamily: tajawalFont, fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20, ), ) : null, ), title: Text( contact.displayName, style: const TextStyle( fontFamily: tajawalFont, fontSize: 18, fontWeight: FontWeight.w700, ), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), const SizedBox(height: 8), Column( children: phones.map((phone) { final normalized = phone.number.replaceAll(RegExp(r'[^\d+]'), ''); final isSelected = selectedNumbers.any((num) { final n = num.replaceAll(RegExp(r'[^\d+]'), ''); return n == normalized; }); return InkWell( borderRadius: BorderRadius.circular(8), onTap: () { setModal(() { if (isSelected) { selectedNumbers.removeWhere((num) { final n = num.replaceAll(RegExp(r'[^\d+]'), ''); return n == normalized; }); } else { selectedNumbers.add(phone.number); } }); }, child: Container( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), margin: const EdgeInsets.symmetric(vertical: 4), decoration: BoxDecoration( color: isSelected ? Theme.of(context).colorScheme.primary.withOpacity(0.15) : Colors.transparent, borderRadius: BorderRadius.circular(8), ), child: Row( children: [ Icon( isSelected ? Icons.check_circle : Icons.radio_button_unchecked, color: isSelected ? Theme.of(context).colorScheme.primary : Colors.grey, ), const SizedBox(width: 12), Expanded( child: Text( phone.number, style: TextStyle( fontFamily: tajawalFont, fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400, fontSize: 15, color: isSelected ? Theme.of(context).colorScheme.primary : null, ), ), ), ], ), ), ); }).toList(), ), ], ), ), ); }, ), ), ), const SizedBox(height: 12), Row( children: [ Expanded( child: OutlinedButton( style: OutlinedButton.styleFrom( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), side: BorderSide(color: Theme.of(context).colorScheme.primary), padding: const EdgeInsets.symmetric(vertical: 14), ), onPressed: () => Navigator.pop(context), child: Text( 'إلغاء', style: TextStyle( fontFamily: tajawalFont, fontWeight: FontWeight.w600, color: Theme.of(context).colorScheme.primary, fontSize: 16, ), ), ), ), const SizedBox(width: 16), Expanded( child: ElevatedButton( style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), padding: const EdgeInsets.symmetric(vertical: 14), elevation: 3, ), onPressed: () async { _savedNumbers = List.from(selectedNumbers); await _saveSavedNumbers(); Navigator.pop(context); _showSnackBar('تم حفظ الأرقام المختارة'); if (mounted) setState(() {}); }, child: Text( 'حفظ', style: TextStyle( fontFamily: tajawalFont, fontWeight: FontWeight.w600, fontSize: 16, ), ), ), ), ], ), const SizedBox(height: 20), ], ), ); }, ); }, ); }نقاط التحسين المهمة في التصميم الجديد:
- الواجهه أصبحت أكثر تعبيرًا وبساطة مع استخدام ألوان الخلفية المعبأة وإزالة حدود النصوص لجعل البحث أنظف.
- توفير مساحة أعلى وأسفل مدخلات البحث والأزرار.
- إضافة تأثير تمييز عند اختيار الرقم من خلال لون خلفية خفيف ورمز اختيار واضح.
- تم تعديل أزرار "إلغاء" و"حفظ" لتكون ذات حجم أكبر ولون متناسب مع التصميم الحديث.
- استخدام إلففيت كارد مع حواف دائرية لجعل عناصر القائمة أكثر حداثة وأناقة.
- تحسين الـ Avatar ليظهر دائريًا وبحجم مناسب، مع استخدام حرف مميز بحجم أكبر.
إذا كنت تحتاج إلى تحسينات إضافية مثل إضافة أنيميشن أو دعم الوضع الداكن بشكل مخصص، يمكنني مساعدتك في ذلك أيضًا.
- استخدام