photo_info_view.dart 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import 'dart:io';
  2. import 'package:clean/base/base_page.dart';
  3. import 'package:clean/module/image_picker/image_picker_util.dart';
  4. import 'package:clean/module/photo_info/photo_info_controller.dart';
  5. import 'package:clean/utils/expand.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. import '../../resource/assets.gen.dart';
  11. import '../../utils/image_util.dart';
  12. import 'dart:typed_data';
  13. class PhotoInfoPage extends BasePage<PhotoInfoController> {
  14. const PhotoInfoPage({super.key});
  15. @override
  16. bool statusBarDarkFont() => false;
  17. @override
  18. bool immersive() => true;
  19. @override
  20. Widget buildBody(BuildContext context) {
  21. return Stack(
  22. children: [
  23. SafeArea(
  24. child: Stack(
  25. children: [
  26. Column(
  27. // mainAxisAlignment: MainAxisAlignment.center,
  28. crossAxisAlignment: CrossAxisAlignment.start,
  29. children: [
  30. Container(
  31. margin: EdgeInsets.only(left: 16.w, top: 14.h),
  32. child: GestureDetector(
  33. onTap: () {
  34. Get.back();
  35. },
  36. child: Assets.images.iconCommonBack
  37. .image(width: 28.w, height: 28.w),
  38. ),
  39. ),
  40. Container(
  41. margin: EdgeInsets.only(left: 16.w, top: 12.h),
  42. child: Obx(() {
  43. if (controller.imageList.isEmpty) {
  44. return SizedBox.shrink();
  45. }
  46. return Text(
  47. controller.imageList[controller.currentImageIndex.value]
  48. .dateTitle ??
  49. "",
  50. style: TextStyle(
  51. color: Colors.white,
  52. fontWeight: FontWeight.w500,
  53. fontSize: 24.sp,
  54. ),
  55. );
  56. }),
  57. ),
  58. SizedBox(
  59. height: 20.h,
  60. ),
  61. _buildImageCarousel(),
  62. ],
  63. ),
  64. Positioned(
  65. left: 0,
  66. right: 0,
  67. bottom: 0,
  68. child: Column(
  69. crossAxisAlignment: CrossAxisAlignment.start,
  70. children: [
  71. Container(
  72. margin: EdgeInsets.only(left: 18.w),
  73. child: Column(
  74. children: [
  75. Text(
  76. "Analysis Results",
  77. style: TextStyle(
  78. color: Colors.white,
  79. fontWeight: FontWeight.w900,
  80. fontSize: 16.sp,
  81. ),
  82. ),
  83. ],
  84. ),
  85. ),
  86. Center(
  87. child: GestureDetector(
  88. onTap: () {
  89. controller.deleteBtnClick(
  90. controller.imageList[
  91. controller.currentImageIndex.value],
  92. controller.currentImageIndex.value);
  93. },
  94. child: Container(
  95. width: 328.w,
  96. height: 48.h,
  97. decoration: BoxDecoration(
  98. color: "#0279FB".color,
  99. borderRadius: BorderRadius.all(
  100. Radius.circular(10.r),
  101. ),
  102. ),
  103. child: Center(
  104. child: Row(
  105. mainAxisAlignment: MainAxisAlignment.center,
  106. children: [
  107. Assets.images.iconPrivacyPhotoDelete
  108. .image(width: 18.w, height: 18.h),
  109. SizedBox(
  110. width: 5.w,
  111. ),
  112. Obx(() {
  113. if (controller.imageList.isEmpty) {
  114. return SizedBox.shrink();
  115. }
  116. return Text(
  117. controller.formatFileSize(controller
  118. .imageList[controller
  119. .currentImageIndex.value]
  120. .size ??
  121. 0),
  122. style: TextStyle(
  123. color: Colors.white,
  124. fontSize: 16.sp,
  125. fontWeight: FontWeight.w500,
  126. ),
  127. );
  128. }),
  129. ],
  130. ),
  131. ),
  132. ),
  133. ),
  134. ),
  135. ],
  136. ),
  137. ),
  138. ],
  139. ),
  140. ),
  141. IgnorePointer(
  142. child: Assets.images.bgHome.image(
  143. width: 360.w,
  144. ),
  145. ),
  146. ],
  147. );
  148. }
  149. // 轮播图组件
  150. Widget _buildImageCarousel() {
  151. return Obx(() {
  152. if (controller.imageList.isEmpty) {
  153. return SizedBox.shrink();
  154. }
  155. return SizedBox(
  156. height: 492.h,
  157. width: ScreenUtil().screenWidth,
  158. child: PageView.builder(
  159. controller: PageController(
  160. viewportFraction: 1, // 显示部分下一张图片
  161. initialPage: controller.currentImageIndex.value,
  162. ),
  163. onPageChanged: (index) {
  164. controller.currentImageIndex.value = index;
  165. PhotoManager.clearFileCache();
  166. },
  167. itemCount: controller.imageList.length,
  168. itemBuilder: (context, index) {
  169. final asset = controller.imageList[index];
  170. return AnimatedPadding(
  171. duration: Duration(milliseconds: 300),
  172. padding: EdgeInsets.symmetric(
  173. horizontal: 0.w,
  174. vertical:
  175. controller.currentImageIndex.value == index ? 0 : 20.h,
  176. ),
  177. child: GestureDetector(
  178. // onTap: () => _showImageDetail(asset),
  179. child: Container(
  180. decoration: BoxDecoration(
  181. borderRadius: BorderRadius.circular(12.r),
  182. boxShadow: [
  183. BoxShadow(
  184. color: Colors.black.withOpacity(0.2),
  185. blurRadius: 8,
  186. offset: Offset(0, 4),
  187. ),
  188. ],
  189. ),
  190. child: ClipRRect(
  191. child: FutureBuilder<File?>(
  192. key: ValueKey(asset.id),
  193. future:
  194. ImageUtil.getImageFile(controller.type.value, asset),
  195. builder: (context, snapshot) {
  196. if (snapshot.hasData && snapshot.data != null) {
  197. return InteractiveViewer(
  198. minScale: 0.5,
  199. maxScale: 3.0,
  200. child: Image.file(
  201. snapshot.data!,
  202. fit: BoxFit.fitHeight,
  203. width: double.infinity,
  204. height: 400,
  205. filterQuality: FilterQuality.high,
  206. ),
  207. );
  208. }
  209. return Container(
  210. color: Colors.grey[800],
  211. child: Icon(Icons.error, color: Colors.white60),
  212. );
  213. },
  214. ),
  215. ),
  216. ),
  217. ),
  218. );
  219. },
  220. ),
  221. );
  222. });
  223. }
  224. }