common_point_page.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/src/widgets/framework.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:flutter_slidable/flutter_slidable.dart';
  6. import 'package:get/get.dart';
  7. import 'package:get/get_core/src/get_main.dart';
  8. import 'package:location/base/base_page.dart';
  9. import 'package:location/data/bean/common_point_bean.dart';
  10. import 'package:location/resource/assets.gen.dart';
  11. import 'package:location/resource/colors.gen.dart';
  12. import 'package:location/resource/string.gen.dart';
  13. import 'package:location/utils/common_expand.dart';
  14. import '../../router/app_pages.dart';
  15. import '../../utils/common_style.dart';
  16. import '../../widget/common_view.dart';
  17. import 'common_point_controller.dart';
  18. class CommonPointPage extends BasePage<CommonPointController> {
  19. const CommonPointPage({super.key});
  20. static void start() {
  21. Get.toNamed(RoutePath.commonPoint);
  22. }
  23. @override
  24. bool immersive() {
  25. return true;
  26. }
  27. @override
  28. Widget buildBody(BuildContext context) {
  29. return Stack(
  30. children: [
  31. Assets.images.bgPageBackground.image(width: double.infinity),
  32. SafeArea(
  33. child: Column(
  34. children: [buildHeaderView(), Expanded(child: buildContentView())],
  35. ),
  36. ),
  37. Positioned(
  38. right: 12.5.w,
  39. bottom: 141.w,
  40. child: Assets.images.iconCommonPointAiSummary.image(width: 60.w))
  41. ],
  42. );
  43. }
  44. Widget buildHeaderView() {
  45. return CommonView.buildAppBar(StringName.commonPointTitle,
  46. backOnTap: controller.onBack,
  47. rightWidget: GestureDetector(
  48. onTap: controller.onSettingClick,
  49. child: Center(
  50. child: Text(
  51. StringName.commonPointSetting,
  52. style: TextStyle(fontSize: 14.sp, color: ColorName.colorPrimary),
  53. ),
  54. ),
  55. ));
  56. }
  57. Widget buildContentView() {
  58. return Obx(() {
  59. if (controller.commonPointList.isEmpty) {
  60. return buildCommonPointEmptyView();
  61. }
  62. return buildCommonPointListView();
  63. });
  64. }
  65. Widget buildCommonPointListView() {
  66. return Column(
  67. children: [
  68. Expanded(
  69. child: ListView.separated(
  70. padding: EdgeInsets.only(bottom: 160.w),
  71. separatorBuilder: (context, index) {
  72. return Container(
  73. height: 0.5.w,
  74. margin: EdgeInsets.only(left: 16.w, right: 16.w),
  75. color: ColorName.black10,
  76. );
  77. },
  78. itemBuilder: (BuildContext context, int index) =>
  79. buildCommonPointListItem(controller.commonPointList[index]),
  80. itemCount: controller.commonPointList.length),
  81. ),
  82. GestureDetector(
  83. onTap: controller.onAddCommonPointClick,
  84. child: Container(
  85. margin: EdgeInsets.only(
  86. top: 15.w, left: 15.w, right: 15.w, bottom: 12.w),
  87. decoration: getPrimaryBtnDecoration(10.r),
  88. width: double.infinity,
  89. height: 46.w,
  90. child: Row(
  91. mainAxisAlignment: MainAxisAlignment.center,
  92. children: [
  93. Assets.images.iconCommonPointAdd
  94. .image(width: 14.w, height: 14.w),
  95. SizedBox(width: 2.w),
  96. Text(StringName.commonPointAdd,
  97. style: TextStyle(fontSize: 14.sp, color: ColorName.white))
  98. ],
  99. ),
  100. ),
  101. )
  102. ],
  103. );
  104. }
  105. Widget buildCommonPointEmptyView() {
  106. return Align(
  107. alignment: Alignment(0.0, -0.4),
  108. child: IntrinsicHeight(
  109. child: Column(
  110. children: [
  111. Assets.images.iconCommonPointNoData
  112. .image(width: 157.w, height: 103.w),
  113. SizedBox(height: 12.8.w),
  114. Text(StringName.commonPointNoData,
  115. style: TextStyle(fontSize: 13.sp, color: ColorName.black60)),
  116. SizedBox(height: 36.w),
  117. GestureDetector(
  118. onTap: controller.onAddCommonPointClick,
  119. child: Container(
  120. decoration: getPrimaryBtnDecoration(10.r),
  121. width: 136.w,
  122. height: 46.w,
  123. child: Row(
  124. mainAxisAlignment: MainAxisAlignment.center,
  125. children: [
  126. Assets.images.iconCommonPointAdd
  127. .image(width: 14.w, height: 14.w),
  128. SizedBox(width: 2.w),
  129. Text(StringName.commonPointAdd,
  130. style:
  131. TextStyle(fontSize: 14.sp, color: ColorName.white))
  132. ],
  133. ),
  134. ),
  135. )
  136. ],
  137. ),
  138. ),
  139. );
  140. }
  141. Widget buildCommonPointListItem(CommonPointBean item) {
  142. return Slidable(
  143. // Specify a key if the Slidable is dismissible.
  144. key: ValueKey(item),
  145. // The end action pane is the one at the right or the bottom side.
  146. endActionPane: ActionPane(
  147. extentRatio: 0.1666666666666667,
  148. motion: ScrollMotion(),
  149. children: [
  150. CustomSlidableAction(
  151. padding: EdgeInsets.zero,
  152. borderRadius: BorderRadius.circular(10.r),
  153. backgroundColor: '#FF7272'.color,
  154. onPressed: (ctx) {},
  155. child: Text(StringName.commonPointDelete,
  156. style: TextStyle(fontSize: 12.sp, color: Colors.white)))
  157. ],
  158. ),
  159. child: buildListItem(item));
  160. }
  161. Widget buildListItem(CommonPointBean item) {
  162. return SizedBox(
  163. width: double.infinity,
  164. height: 70.w,
  165. child: Row(
  166. crossAxisAlignment: CrossAxisAlignment.center,
  167. children: [
  168. SizedBox(width: 16.w),
  169. Container(
  170. width: 40.w,
  171. height: 40.w,
  172. decoration: BoxDecoration(
  173. shape: BoxShape.circle,
  174. color: ColorName.colorPrimary.withOpacity(0.1)),
  175. child: Center(
  176. child: Text(
  177. item.title.substring(0, 1),
  178. style: TextStyle(
  179. fontSize: 16.sp,
  180. color: ColorName.colorPrimary,
  181. fontWeight: FontWeight.bold),
  182. ),
  183. )),
  184. SizedBox(width: 12.w),
  185. Expanded(
  186. child: Column(
  187. mainAxisAlignment: MainAxisAlignment.center,
  188. crossAxisAlignment: CrossAxisAlignment.start,
  189. children: [
  190. Text(item.title,
  191. style: TextStyle(fontSize: 14.sp, color: ColorName.black90)),
  192. SizedBox(height: 6.w),
  193. Text(item.addr ?? '',
  194. style: TextStyle(
  195. overflow: TextOverflow.ellipsis,
  196. fontSize: 12.sp,
  197. color: ColorName.black30))
  198. ],
  199. )),
  200. SizedBox(width: 16.w),
  201. ],
  202. ),
  203. );
  204. }
  205. }