AddressCard.dart 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import 'package:farmer_client/models/entities/Address.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. class AddressCard extends StatelessWidget {
  5. final Address item;
  6. final int No;
  7. final bool isBack;
  8. final GestureTapCallback onChange;
  9. final GestureTapCallback onDelete;
  10. final GestureTapCallback onEdit;
  11. final GestureTapCallback onBack;
  12. const AddressCard(
  13. {Key? key,
  14. required this.item,
  15. required this.No,
  16. required this.isBack,
  17. required this.onChange,
  18. required this.onDelete,
  19. required this.onEdit,
  20. required this.onBack})
  21. : super(key: key);
  22. @override
  23. Widget build(BuildContext context) {
  24. return Container(
  25. width: 345.w,
  26. padding: EdgeInsets.all(15.w),
  27. margin: EdgeInsets.fromLTRB(0, 0, 0, 15.w),
  28. decoration: BoxDecoration(
  29. color: const Color(0xFFFFFFFF),
  30. borderRadius: BorderRadius.all(Radius.circular(10.w)),
  31. boxShadow: [
  32. BoxShadow(
  33. color: const Color(0x19000000),
  34. offset: Offset(0, 5.w),
  35. blurRadius: 12.w),
  36. ],
  37. ),
  38. child: Column(
  39. crossAxisAlignment: CrossAxisAlignment.start,
  40. children: [
  41. GestureDetector(
  42. onTap: isBack ? onBack : () {},
  43. child: Row(
  44. children: [
  45. if (item.isDefault == true)
  46. Container(
  47. margin: EdgeInsets.fromLTRB(0, 0, 5.w, 0),
  48. padding:
  49. EdgeInsets.symmetric(vertical: 1.w, horizontal: 5.w),
  50. decoration: BoxDecoration(
  51. color: const Color(0xffff0000),
  52. borderRadius: BorderRadius.all(Radius.circular(5.w)),
  53. ),
  54. child: Text(
  55. '默认地址',
  56. style: TextStyle(
  57. fontSize: 15.sp,
  58. fontWeight: FontWeight.bold,
  59. color: const Color(0xffffffff),
  60. ),
  61. ),
  62. ),
  63. Text(
  64. '我的地址' + No.toString(),
  65. style:
  66. TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w700),
  67. ),
  68. ],
  69. ),
  70. ),
  71. Container(
  72. padding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 0),
  73. decoration: BoxDecoration(
  74. border: Border(
  75. bottom: BorderSide(
  76. width: 1.h,
  77. color: const Color(0xcc000000),
  78. style: BorderStyle.solid),
  79. ),
  80. ),
  81. child: GestureDetector(
  82. onTap: isBack ? onBack : () {},
  83. child: Row(
  84. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  85. children: [
  86. Container(
  87. padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 0),
  88. width: 282.w,
  89. child: Text(
  90. item.address.toString(),
  91. //最多显示两行
  92. maxLines: 2,
  93. //多余文本用点点点表示
  94. overflow: TextOverflow.ellipsis,
  95. style: TextStyle(
  96. fontSize: 15.sp,
  97. color: const Color(0xff666666),
  98. ),
  99. ),
  100. ),
  101. GestureDetector(
  102. onTap: onEdit,
  103. child: Image.asset(
  104. 'images/icons/edit.png',
  105. width: 33.w,
  106. height: 33.w,
  107. ),
  108. ),
  109. ],
  110. ),
  111. ),
  112. ),
  113. if (isBack)
  114. GestureDetector(
  115. onTap: onBack,
  116. child: Container(
  117. width: 315.w,
  118. margin: EdgeInsets.fromLTRB(0, 5.w, 0, 0),
  119. child: Text(
  120. '选择此地址',
  121. style:
  122. TextStyle(fontSize: 17.sp, fontWeight: FontWeight.w800),
  123. ),
  124. ),
  125. ),
  126. if (!isBack)
  127. Row(
  128. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  129. children: [
  130. GestureDetector(
  131. // onTap: onChange,
  132. child: Row(
  133. children: [
  134. const Text('设为默认地址'),
  135. Radio<bool>(
  136. value: true,
  137. activeColor: const Color(0xFFFF703B),
  138. groupValue: item.isDefault,
  139. onChanged: (value) {
  140. onChange();
  141. }),
  142. ],
  143. ),
  144. ),
  145. GestureDetector(
  146. onTap: onDelete,
  147. child: Row(
  148. children: [
  149. const Text('删除'),
  150. Image.asset(
  151. 'images/icons/delete.png',
  152. width: 25.w,
  153. height: 25.w,
  154. ),
  155. ],
  156. ),
  157. ),
  158. ],
  159. ),
  160. ],
  161. ),
  162. );
  163. }
  164. }