locations_photo_view.dart 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import 'dart:io';
  2. import 'package:clean/base/base_page.dart';
  3. import 'package:clean/module/locations_photo/locations_photo_controller.dart';
  4. import 'package:clean/resource/assets.gen.dart';
  5. import 'package:clean/router/app_pages.dart';
  6. import 'package:flutter/Material.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'package:get/get.dart';
  9. import 'package:wechat_assets_picker/wechat_assets_picker.dart';
  10. class LocationsPhotoPage extends BasePage<LocationsPhotoController> {
  11. @override
  12. bool statusBarDarkFont() => false;
  13. @override
  14. bool immersive() => true;
  15. static void start() {
  16. Get.toNamed(RoutePath.locationsPhoto);
  17. }
  18. @override
  19. Widget buildBody(BuildContext context) {
  20. return Stack(children: [
  21. Container(
  22. child: SafeArea(
  23. child: Obx(() {
  24. if (controller.photoGroups.isEmpty) {
  25. return _noNoPicturesCard();
  26. } else {
  27. return photoDateCard();
  28. }
  29. }),
  30. ),
  31. ),
  32. IgnorePointer(
  33. child: Assets.images.bgHome.image(
  34. width: 360.w,
  35. height: 234.h,
  36. ),
  37. ),
  38. ]);
  39. }
  40. Widget photoDateCard() {
  41. return Column(
  42. children: [
  43. _titleCard(),
  44. Expanded(
  45. child: Obx(() {
  46. return ListView(
  47. padding: EdgeInsets.symmetric(horizontal: 16.w),
  48. children: [
  49. ...controller.photoGroups.map((group) => Column(
  50. children: [
  51. _buildPhotoGroup(
  52. title: "photo: ${group.images.length}",
  53. location: group.location ?? '',
  54. imageCount: group.images.length,
  55. ),
  56. SizedBox(height: 15.h),
  57. ],
  58. ))
  59. ],
  60. );
  61. }),
  62. ),
  63. ],
  64. );
  65. }
  66. Widget _titleCard() {
  67. return Container(
  68. alignment: Alignment.centerLeft,
  69. padding: EdgeInsets.only(left: 16.w, top: 14.h),
  70. child: Column(
  71. crossAxisAlignment: CrossAxisAlignment.start,
  72. children: [
  73. GestureDetector(
  74. onTap: () => Get.back(),
  75. child: Assets.images.iconBackArrow.image(
  76. width: 28.w,
  77. height: 28.h,
  78. ),
  79. ),
  80. (controller.photoGroups.isEmpty)
  81. ? const SizedBox()
  82. : Column(
  83. children: [
  84. SizedBox(height: 12.h),
  85. Text(
  86. 'Places Photos',
  87. style: TextStyle(
  88. color: Colors.white,
  89. fontSize: 24.sp,
  90. fontWeight: FontWeight.w700,
  91. ),
  92. ),
  93. SizedBox(height: 20.h),
  94. ],
  95. )
  96. ],
  97. ),
  98. );
  99. }
  100. Widget _buildPhotoGroup({
  101. required String location,
  102. required String title,
  103. required int imageCount,
  104. }) {
  105. return Container(
  106. margin: EdgeInsets.only(top: 14.h),
  107. width: 328.w,
  108. height: 227.h,
  109. decoration: ShapeDecoration(
  110. color: Colors.white.withValues(alpha: 0.12),
  111. shape: RoundedRectangleBorder(
  112. borderRadius: BorderRadius.circular(14.sp),
  113. ),
  114. ),
  115. child: Column(
  116. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  117. children: [
  118. Row(
  119. mainAxisAlignment: MainAxisAlignment.start,
  120. children: [
  121. SizedBox(width: 16.w),
  122. Text(
  123. title,
  124. textAlign: TextAlign.center,
  125. style: TextStyle(
  126. color: Colors.white,
  127. fontSize: 14.sp,
  128. fontWeight: FontWeight.w500,
  129. ),
  130. ),
  131. ],
  132. ),
  133. SizedBox(
  134. child: GestureDetector(
  135. onTap: () => controller
  136. .clickPhotoGroup(controller.getGroupByLocation(location)),
  137. child: Obx(() {
  138. final group = controller.getGroupByLocation(location);
  139. final imagePath =
  140. group.images.isNotEmpty ? group.images.first : null;
  141. return imagePath != null
  142. ? Stack(
  143. children: [
  144. Container(
  145. width: 304.w,
  146. height: 171.h,
  147. decoration: ShapeDecoration(
  148. color: Colors.white.withValues(alpha: 0.12),
  149. shape: RoundedRectangleBorder(
  150. borderRadius: BorderRadius.circular(8.r),
  151. ),
  152. image: DecorationImage(
  153. image: AssetEntityImageProvider(
  154. imagePath,
  155. thumbnailSize:
  156. const ThumbnailSize.square(300),
  157. isOriginal: false,
  158. ),
  159. fit: BoxFit.cover,
  160. ),
  161. ),
  162. ),
  163. Positioned(
  164. left: 1.w,
  165. right: 1.w,
  166. bottom: 16.sp,
  167. child: Text(
  168. location,
  169. textAlign: TextAlign.center,
  170. style: TextStyle(
  171. color: Colors.white,
  172. fontSize: 20.sp,
  173. fontWeight: FontWeight.w500,
  174. ),
  175. ))
  176. ],
  177. )
  178. : Container();
  179. }),
  180. ),
  181. ),
  182. ],
  183. ),
  184. );
  185. }
  186. Widget _noNoPicturesCard() {
  187. return Column(
  188. // mainAxisAlignment: MainAxisAlignment.start,
  189. children: [
  190. _titleCard(),
  191. SizedBox(
  192. height: 170.h,
  193. ),
  194. Column(
  195. crossAxisAlignment: CrossAxisAlignment.center,
  196. children: [
  197. Container(
  198. width: 70.w,
  199. height: 70.h,
  200. clipBehavior: Clip.antiAlias,
  201. decoration: BoxDecoration(),
  202. child: Assets.images.iconNoPictures.image(),
  203. ),
  204. SizedBox(height: 22.h),
  205. Text(
  206. 'No pictures found',
  207. textAlign: TextAlign.center,
  208. style: TextStyle(
  209. color: Colors.white,
  210. fontSize: 20.sp,
  211. fontWeight: FontWeight.w700,
  212. ),
  213. ),
  214. SizedBox(height: 12.h),
  215. Text(
  216. 'No pictures available at the moment',
  217. textAlign: TextAlign.center,
  218. style: TextStyle(
  219. color: Colors.white.withValues(alpha: 0.6),
  220. fontSize: 14.sp,
  221. fontWeight: FontWeight.w400,
  222. ),
  223. ),
  224. ],
  225. ),
  226. ],
  227. );
  228. }
  229. }