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