import 'package:wanisclient/config/custom_text.dart'; import 'package:wanisclient/utils/colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import '../providers/myAddress_provider.dart'; /// One small helper → picks the right leading icon Widget _leadingIcon(String tag) { switch (tag.trim().toUpperCase()) { case 'HOME': return Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.grey.shade200, shape: BoxShape.circle, ), child: SvgPicture.asset( 'assets/icons/location_icon.svg', width: 20, height: 20, color: AppNewColors.black, ), ); case 'WORK': return Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.grey.shade200, shape: BoxShape.circle, ), child: SvgPicture.asset( 'assets/icons/location_icon.svg', width: 20, height: 20, color: AppNewColors.black, ), ); case 'HISTORY': return Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.grey.shade200, shape: BoxShape.circle, ), child: SvgPicture.asset( 'assets/icons/History_Icon.svg', width: 20, height: 20, color: AppNewColors.black, ), ); default: return SvgPicture.asset( 'assets/icons/addressicon.svg', width: 20, height: 20, color: AppColors.primaryColor, ); } } Widget _leadingText(String tag, name, position) { switch (tag.trim().toUpperCase()) { case 'HOME': return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Txt( text: "House", style: TextStyle( color: Colors.black, fontWeight: FontWeight.w700, fontSize: 15), ), Text( "$name", style: const TextStyle( color: Colors.black87, fontWeight: FontWeight.w400, fontSize: 10), ), ], ); case 'WORK': return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Txt( text: "Work", style: TextStyle( color: Colors.black, fontWeight: FontWeight.w700, fontSize: 15), ), Text( "$name", style: const TextStyle( color: Colors.black87, fontWeight: FontWeight.w400, fontSize: 10), ), ], ); case 'HISTORY': return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "$name", style: const TextStyle( color: Colors.black, fontWeight: FontWeight.w500, fontSize: 12), ), Text( "$position", style: const TextStyle( color: Colors.black87, fontWeight: FontWeight.w400, fontSize: 10), ), ], ); default: return const Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [], ); } } Widget addressCard(isaddressscreen, name, position, id, tag, UserAddressProvider addressProvider) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(12), ), child: ListTile( leading: _leadingIcon(tag), title: _leadingText(tag, name, position), trailing: isaddressscreen ? IconButton( onPressed: () { addressProvider.deleteAddress(id); }, icon: const Icon( Icons.delete_outline_outlined, color: Colors.redAccent, )) : const SizedBox(), ), ); }