import 'package:flutter/material.dart'; import 'package:twong/config/style.dart'; import 'package:twong/utils/index.dart'; import 'package:twong/router/index.dart'; import 'package:twong/models/address.dart'; class AddressItem extends StatelessWidget { final bool editable; final Address address; AddressItem(this.address, { this.editable = true }); @override Widget build(BuildContext context) { return Row( children: [ Container( margin: EdgeInsets.only(right: 12.px), child: CircleAvatar(child: Text(Utils.formatName(address.real_name), style: TextStyle(fontSize: 14.px)), backgroundColor: DColors.Main, foregroundColor: Colors.white), ), Expanded(child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ address.is_default == 1 ? Container( margin: EdgeInsets.only(right: 6.px), padding: EdgeInsets.only(left: 4.px, right: 4.px), child: Text("默认", style: TextStyle(color: DColors.Main)), decoration: BoxDecoration( color: Color.fromRGBO(248, 226, 218, 0.7), borderRadius: BorderRadius.circular(4.px) ), ) : Container(), Text(address.real_name, style: TextStyle(fontSize: 14.px)), Container( margin: EdgeInsets.only(left: 12.px), child: Text( address.phone, style: TextStyle(color: Colors.grey)), ) ], ), Wrap( direction: Axis.horizontal, children: [ Container( height: 36.px, alignment: Alignment.topLeft, child: Text("${address.province} ${address.city} " "${address.district} ${address.detail}", style: TextStyle(fontSize: 12.px)), ) ], ) ], )), editable ? Row(children: [ SizedBox( width: 0.5, height: 24.px, child: DecoratedBox( decoration: BoxDecoration(color: Colors.grey), ), ), InkWell( onTap: () { Navigator.pushNamed(context, RouteNames.editAddress, arguments: address); }, child: Container( margin: EdgeInsets.only(left: 16.px, right: 6.px), child: Text("编辑", style: TextStyle(color: Colors.grey)), ), ) ]) : Icon(Icons.chevron_right, color: Colors.grey), ], ); } }