common_point_page.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 Center(
  107. child: IntrinsicHeight(
  108. child: Column(
  109. children: [
  110. Assets.images.iconCommonPointNoData.image(width: 157.w),
  111. SizedBox(height: 12.8.w),
  112. Text(StringName.commonPointNoData,
  113. style: TextStyle(fontSize: 13.sp, color: ColorName.black60)),
  114. SizedBox(height: 36.w),
  115. GestureDetector(
  116. onTap: controller.onAddCommonPointClick,
  117. child: Container(
  118. decoration: getPrimaryBtnDecoration(10.r),
  119. width: 136.w,
  120. height: 46.w,
  121. child: Row(
  122. mainAxisAlignment: MainAxisAlignment.center,
  123. children: [
  124. Assets.images.iconCommonPointAdd
  125. .image(width: 14.w, height: 14.w),
  126. SizedBox(width: 2.w),
  127. Text(StringName.commonPointAdd,
  128. style:
  129. TextStyle(fontSize: 14.sp, color: ColorName.white))
  130. ],
  131. ),
  132. ),
  133. )
  134. ],
  135. ),
  136. ),
  137. );
  138. }
  139. Widget buildCommonPointListItem(CommonPointBean item) {
  140. return Slidable(
  141. // Specify a key if the Slidable is dismissible.
  142. key: ValueKey(item),
  143. // The end action pane is the one at the right or the bottom side.
  144. endActionPane: ActionPane(
  145. extentRatio: 0.1666666666666667,
  146. motion: ScrollMotion(),
  147. children: [
  148. CustomSlidableAction(
  149. padding: EdgeInsets.zero,
  150. borderRadius: BorderRadius.circular(10.r),
  151. backgroundColor: '#FF7272'.color,
  152. onPressed: (ctx) {},
  153. child: Text(StringName.commonPointDelete,
  154. style: TextStyle(fontSize: 12.sp, color: Colors.white)))
  155. ],
  156. ),
  157. child: buildListItem(item));
  158. }
  159. Widget buildListItem(CommonPointBean item) {
  160. return SizedBox(
  161. width: double.infinity,
  162. height: 70.w,
  163. child: Row(
  164. crossAxisAlignment: CrossAxisAlignment.center,
  165. children: [
  166. SizedBox(width: 16.w),
  167. Container(
  168. width: 40.w,
  169. height: 40.w,
  170. decoration: BoxDecoration(
  171. shape: BoxShape.circle,
  172. color: ColorName.colorPrimary.withOpacity(0.1)),
  173. child: Center(
  174. child: Text(
  175. item.title.substring(0, 1),
  176. style: TextStyle(
  177. fontSize: 16.sp,
  178. color: ColorName.colorPrimary,
  179. fontWeight: FontWeight.bold),
  180. ),
  181. )),
  182. SizedBox(width: 12.w),
  183. Expanded(
  184. child: Column(
  185. mainAxisAlignment: MainAxisAlignment.center,
  186. crossAxisAlignment: CrossAxisAlignment.start,
  187. children: [
  188. Text(item.title,
  189. style: TextStyle(fontSize: 14.sp, color: ColorName.black90)),
  190. SizedBox(height: 6.w),
  191. Text(item.addr ?? '',
  192. style: TextStyle(
  193. overflow: TextOverflow.ellipsis,
  194. fontSize: 12.sp,
  195. color: ColorName.black30))
  196. ],
  197. )),
  198. SizedBox(width: 16.w),
  199. ],
  200. ),
  201. );
  202. }
  203. }