locations_photo_view.dart 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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:clean/utils/styles.dart';
  7. import 'package:flutter/Material.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:get/get.dart';
  10. import 'package:wechat_assets_picker/wechat_assets_picker.dart';
  11. class LocationsPhotoPage extends BasePage<LocationsPhotoController> {
  12. @override
  13. bool statusBarDarkFont() => false;
  14. @override
  15. bool immersive() => true;
  16. static void start() {
  17. Get.toNamed(RoutePath.locationsPhoto);
  18. }
  19. @override
  20. Widget buildBody(BuildContext context) {
  21. return Stack(children: [
  22. Container(
  23. child: SafeArea(
  24. child: Obx(() {
  25. if (controller.photoGroups.isEmpty) {
  26. return _noNoPicturesCard();
  27. } else {
  28. return photoDateCard();
  29. }
  30. }),
  31. ),
  32. ),
  33. IgnorePointer(
  34. child: Assets.images.bgHome.image(
  35. width: 360.w,
  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. ),
  153. child: ClipRRect(
  154. borderRadius: BorderRadius.circular(8.r),
  155. child: AssetEntityImage(
  156. imagePath,
  157. width: 304.w,
  158. thumbnailSize: const ThumbnailSize.square(300),
  159. height: 171.h,
  160. frameBuilder: Styles.customFrameBuilder(width: 140.w,
  161. height: 140.h),
  162. fit: BoxFit.cover,
  163. isOriginal: false,
  164. ),
  165. ),
  166. ),
  167. Positioned(
  168. left: 1.w,
  169. right: 1.w,
  170. bottom: 16.sp,
  171. child: Text(
  172. location,
  173. textAlign: TextAlign.center,
  174. style: TextStyle(
  175. color: Colors.white,
  176. fontSize: 20.sp,
  177. fontWeight: FontWeight.w500,
  178. ),
  179. ))
  180. ],
  181. )
  182. : Container();
  183. }),
  184. ),
  185. ),
  186. ],
  187. ),
  188. );
  189. }
  190. Widget _noNoPicturesCard() {
  191. return Column(
  192. // mainAxisAlignment: MainAxisAlignment.start,
  193. children: [
  194. _titleCard(),
  195. SizedBox(
  196. height: 170.h,
  197. ),
  198. Column(
  199. crossAxisAlignment: CrossAxisAlignment.center,
  200. children: [
  201. Container(
  202. width: 70.w,
  203. height: 70.h,
  204. clipBehavior: Clip.antiAlias,
  205. decoration: BoxDecoration(),
  206. child: Assets.images.iconNoPictures.image(),
  207. ),
  208. SizedBox(height: 22.h),
  209. Text(
  210. 'No pictures found',
  211. textAlign: TextAlign.center,
  212. style: TextStyle(
  213. color: Colors.white,
  214. fontSize: 20.sp,
  215. fontWeight: FontWeight.w700,
  216. ),
  217. ),
  218. SizedBox(height: 12.h),
  219. Text(
  220. 'No pictures available at the moment',
  221. textAlign: TextAlign.center,
  222. style: TextStyle(
  223. color: Colors.white.withValues(alpha: 0.6),
  224. fontSize: 14.sp,
  225. fontWeight: FontWeight.w400,
  226. ),
  227. ),
  228. ],
  229. ),
  230. ],
  231. );
  232. }
  233. }