photo_preview_view.dart 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. import 'package:clean/base/base_page.dart';
  2. import 'package:clean/data/bean/photos_type.dart';
  3. import 'package:clean/module/photo_preview/photo_preview_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/src/widgets/framework.dart';
  8. import 'package:flutter_card_swiper/flutter_card_swiper.dart';
  9. import 'package:flutter_screenutil/flutter_screenutil.dart';
  10. import 'package:get/get.dart';
  11. import 'package:wechat_assets_picker/wechat_assets_picker.dart';
  12. class PhotoPreviewPage extends BasePage<PhotoPreviewController> {
  13. PhotoPreviewPage({Key? key}) : super(key: key);
  14. static void start(PhotosType photosType, String currentImageId) {
  15. print(' PhotoPreviewPage start $photosType $currentImageId');
  16. Get.toNamed(RoutePath.photoPreview, arguments: {
  17. "photosType": photosType,
  18. "currentImageId": currentImageId,
  19. });
  20. }
  21. @override
  22. bool immersive() {
  23. // TODO: implement immersive
  24. return true;
  25. }
  26. @override
  27. bool statusBarDarkFont() {
  28. // TODO: implement statusBarDarkFont
  29. return false;
  30. }
  31. @override
  32. Widget buildBody(BuildContext context) {
  33. return Stack(children: [
  34. Container(
  35. child: SafeArea(
  36. child: Column(
  37. children: [
  38. _titleCard(),
  39. Spacer(),
  40. (controller.photoGroups.length == 1)
  41. ? Container(
  42. width: 314.w,
  43. height: 392.h,
  44. child: AssetEntityImage(
  45. controller.photoGroups[0],
  46. width: 314.w,
  47. height: 392.h,
  48. ),
  49. )
  50. : Container(
  51. width: 314.w,
  52. height: 392.h,
  53. child: CardSwiper(
  54. scale: 0.8,
  55. allowedSwipeDirection: AllowedSwipeDirection.only(
  56. right: true,
  57. left: true,
  58. ),
  59. isLoop: false,
  60. backCardOffset: Offset(0.w, -20.h),
  61. controller: controller.cardSwiperController.value,
  62. cardsCount: controller.photoGroups.length,
  63. onSwipe: controller.onSwipe,
  64. onUndo: controller.onSwiperUndo,
  65. cardBuilder: (context,
  66. index,
  67. horizontalOffsetPercentage,
  68. verticalOffsetPercentage) {
  69. final assetEntity = controller.photoGroups[index];
  70. return AssetEntityImage(
  71. assetEntity,
  72. width: 314.w,
  73. height: 392.h,
  74. );
  75. },
  76. ),
  77. ),
  78. Spacer(),
  79. bottomButtonCard(),
  80. _bottomBarCard(),
  81. ],
  82. ),
  83. ),
  84. ),
  85. IgnorePointer(
  86. child: Assets.images.bgHome.image(
  87. width: 360.w,
  88. height: 234.h,
  89. ),
  90. ),
  91. ]);
  92. }
  93. Widget _titleCard() {
  94. return Container(
  95. alignment: Alignment.centerLeft,
  96. padding: EdgeInsets.only(left: 16.w, top: 14.h, right: 16.w),
  97. child: Column(
  98. crossAxisAlignment: CrossAxisAlignment.start,
  99. children: [
  100. Row(
  101. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  102. children: [
  103. GestureDetector(
  104. onTap: controller.clickBack,
  105. child: Assets.images.iconBackArrow.image(
  106. width: 28.w,
  107. height: 28.h,
  108. ),
  109. ),
  110. Obx(() => Row(
  111. mainAxisAlignment: MainAxisAlignment.center,
  112. children: [
  113. Text(
  114. '${controller.groupIndex.value + 1}',
  115. textAlign: TextAlign.center,
  116. style: TextStyle(
  117. color: Colors.white,
  118. fontSize: 16.sp,
  119. fontWeight: FontWeight.w700,
  120. ),
  121. ),
  122. Text(
  123. ' / ${controller.photoGroups.length}',
  124. textAlign: TextAlign.center,
  125. style: TextStyle(
  126. color: Colors.white.withValues(alpha: 0.6),
  127. fontSize: 16.sp,
  128. fontWeight: FontWeight.w500,
  129. ),
  130. ),
  131. ],
  132. )),
  133. GestureDetector(
  134. onTap: controller.recoverSelectPhoto,
  135. child: Assets.images.iconPreviewRecover.image(
  136. width: 30.w,
  137. height: 30.h,
  138. ),
  139. ),
  140. ],
  141. ),
  142. SizedBox(height: 12.h),
  143. ],
  144. ),
  145. );
  146. }
  147. Widget _bottomBarCard() {
  148. return Container(
  149. width: 360.w,
  150. height: 81.h,
  151. padding: EdgeInsets.symmetric(horizontal: 16.w),
  152. decoration: ShapeDecoration(
  153. color: Color(0xFF23232A),
  154. shape: RoundedRectangleBorder(
  155. side: BorderSide(
  156. width: 1.w, color: Colors.white.withValues(alpha: 0.1)),
  157. borderRadius: BorderRadius.only(
  158. topLeft: Radius.circular(14.r),
  159. topRight: Radius.circular(14.r),
  160. ),
  161. ),
  162. ),
  163. child: Row(
  164. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  165. children: [
  166. Obx(() {
  167. return Text(
  168. '${controller.selectedFileCount.value} files selected (${controller.selectedFilesSize.value.toStringAsFixed(1)} KB)',
  169. textAlign: TextAlign.center,
  170. style: TextStyle(
  171. color: Colors.white.withValues(alpha: 0.9),
  172. fontSize: 13.sp,
  173. fontWeight: FontWeight.w500,
  174. ),
  175. );
  176. }),
  177. Container(
  178. width: 108.w,
  179. height: 38.h,
  180. decoration: ShapeDecoration(
  181. color: Color(0xFF0279FB),
  182. shape: RoundedRectangleBorder(
  183. borderRadius: BorderRadius.circular(10.r),
  184. ),
  185. ),
  186. child: Row(
  187. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  188. children: [
  189. Text(
  190. 'Delete',
  191. textAlign: TextAlign.center,
  192. style: TextStyle(
  193. color: Colors.white,
  194. fontSize: 16.sp,
  195. fontWeight: FontWeight.w500,
  196. ),
  197. ),
  198. Assets.images.iconDelete.image(
  199. width: 18.w,
  200. height: 18.h,
  201. ),
  202. ],
  203. ),
  204. ),
  205. ],
  206. ),
  207. );
  208. }
  209. Widget bottomButtonCard() {
  210. return Container(
  211. margin: EdgeInsets.only(bottom: 54.h),
  212. child: Row(
  213. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  214. children: [
  215. GestureDetector(
  216. onTap: () => controller.clickSelect(),
  217. child: Assets.images.iconPreviewSelect.image(
  218. width: 62.w,
  219. height: 62.h,
  220. ),
  221. ),
  222. GestureDetector(
  223. onTap: () => controller.clickUnselect(),
  224. child: Assets.images.iconPreviewNoSelect.image(
  225. width: 62.w,
  226. height: 62.h,
  227. ),
  228. ),
  229. ],
  230. ),
  231. );
  232. }
  233. }