import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/pages/widgets/local_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; typedef SelectionCallback(DeliveryAddress deliveryAddress); class DeliveryAddressRow extends StatelessWidget { final DeliveryAddress deliveryAddress; final SelectionCallback? selectionCallback; const DeliveryAddressRow( {Key? key, required this.deliveryAddress, this.selectionCallback}) : super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: selectionCallback == null ? null : () => this.selectionCallback!(deliveryAddress), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ deliveryAddress.fullName!="" ? line(context, deliveryAddress.fullName, iconData: MaterialCommunityIcons.account, color: Colors.black, fontSize: 16):SizedBox(), deliveryAddress.phoneNumber!="" ? line(context, deliveryAddress.phoneNumber, iconData: Icons.phone, color: Colors.black, fontSize: 16):SizedBox(), deliveryAddress.addressLine1!="" ? line(context, deliveryAddress.addressLine1, iconData: Icons.location_on,color: Colors.grey, fontSize: 16):SizedBox(), deliveryAddress.addressLine2!="" ? line( context, deliveryAddress.addressLine2,color: Colors.grey, fontSize: 16 ):SizedBox(), deliveryAddress.city!="" ? line( context, deliveryAddress.city,color: Colors.grey, fontSize: 16 ):SizedBox(), deliveryAddress.state!="" ? line(context, deliveryAddress.state,color: Colors.grey, fontSize: 16):SizedBox(), ], ), ), ], ), ); } Widget line(BuildContext context, String? text, {IconData? iconData, Color? color, double? fontSize}) { return Row( children: [ iconData == null ? SizedBox(width: 40) : Padding( padding: const EdgeInsets.only(left: 8.0, right: 8), child: Icon(iconData, color: Colors.grey), ), Flexible( child: TextLocalStyle( context, text ?? "", fontSize: fontSize ?? 14, color: color ?? Colors.grey, ), ), ], ); } }