address_item.dart 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import 'package:flutter/material.dart';
  2. import 'package:twong/config/style.dart';
  3. import 'package:twong/utils/index.dart';
  4. import 'package:twong/router/index.dart';
  5. import 'package:twong/models/address.dart';
  6. class AddressItem extends StatelessWidget {
  7. final bool editable;
  8. final Address address;
  9. AddressItem(this.address, { this.editable = true });
  10. @override
  11. Widget build(BuildContext context) {
  12. return Row(
  13. children: [
  14. Container(
  15. margin: EdgeInsets.only(right: 12.px),
  16. child: CircleAvatar(child: Text(Utils.formatName(address.real_name),
  17. style: TextStyle(fontSize: 14.px)),
  18. backgroundColor: DColors.Main, foregroundColor: Colors.white),
  19. ),
  20. Expanded(child: Column(
  21. crossAxisAlignment: CrossAxisAlignment.start,
  22. children: [
  23. Row(
  24. children: [
  25. address.is_default == 1 ? Container(
  26. margin: EdgeInsets.only(right: 6.px),
  27. padding: EdgeInsets.only(left: 4.px, right: 4.px),
  28. child: Text("默认", style: TextStyle(color: DColors.Main)),
  29. decoration: BoxDecoration(
  30. color: Color.fromRGBO(248, 226, 218, 0.7),
  31. borderRadius: BorderRadius.circular(4.px)
  32. ),
  33. ) : Container(),
  34. Text(address.real_name, style: TextStyle(fontSize: 14.px)),
  35. Container(
  36. margin: EdgeInsets.only(left: 12.px),
  37. child: Text(
  38. address.phone, style: TextStyle(color: Colors.grey)),
  39. )
  40. ],
  41. ),
  42. Wrap(
  43. direction: Axis.horizontal,
  44. children: [
  45. Container(
  46. height: 36.px,
  47. alignment: Alignment.topLeft,
  48. child: Text("${address.province} ${address.city} "
  49. "${address.district} ${address.detail}",
  50. style: TextStyle(fontSize: 12.px)),
  51. )
  52. ],
  53. )
  54. ],
  55. )),
  56. editable ? Row(children: [
  57. SizedBox(
  58. width: 0.5,
  59. height: 24.px,
  60. child: DecoratedBox(
  61. decoration: BoxDecoration(color: Colors.grey),
  62. ),
  63. ),
  64. InkWell(
  65. onTap: () {
  66. Navigator.pushNamed(context,
  67. RouteNames.editAddress, arguments: address);
  68. },
  69. child: Container(
  70. margin: EdgeInsets.only(left: 16.px, right: 6.px),
  71. child: Text("编辑", style: TextStyle(color: Colors.grey)),
  72. ),
  73. )
  74. ]) : Icon(Icons.chevron_right, color: Colors.grey),
  75. ],
  76. );
  77. }
  78. }