photo_info_view.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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:clean/utils/file_utils.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. import '../../resource/assets.gen.dart';
  12. import '../../utils/image_util.dart';
  13. import 'dart:typed_data';
  14. class PhotoInfoPage extends BasePage<PhotoInfoController> {
  15. const PhotoInfoPage({super.key});
  16. @override
  17. bool statusBarDarkFont() => false;
  18. @override
  19. bool immersive() => true;
  20. @override
  21. Widget buildBody(BuildContext context) {
  22. return Stack(
  23. children: [
  24. SafeArea(
  25. child: Stack(
  26. children: [
  27. Column(
  28. // mainAxisAlignment: MainAxisAlignment.center,
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: [
  31. Container(
  32. margin: EdgeInsets.only(left: 16.w, top: 14.h),
  33. child: GestureDetector(
  34. onTap: () {
  35. Get.back();
  36. },
  37. child: Assets.images.iconCommonBack
  38. .image(width: 28.w, height: 28.w),
  39. ),
  40. ),
  41. Container(
  42. margin: EdgeInsets.only(left: 16.w, top: 12.h),
  43. child: Obx(() {
  44. if (controller.imageList.isEmpty) {
  45. return SizedBox.shrink();
  46. }
  47. return Text(
  48. controller.imageList[controller.currentImageIndex.value]
  49. .dateTitle ??
  50. "",
  51. style: TextStyle(
  52. color: Colors.white,
  53. fontWeight: FontWeight.w500,
  54. fontSize: 24.sp,
  55. ),
  56. );
  57. }),
  58. ),
  59. SizedBox(
  60. height: 20.h,
  61. ),
  62. _buildImageCarousel(),
  63. ],
  64. ),
  65. Visibility(
  66. visible: controller.type.value == FileType.analysis,
  67. child: Positioned(
  68. left: 0,
  69. right: 0,
  70. bottom: 0,
  71. child: Column(
  72. crossAxisAlignment: CrossAxisAlignment.start,
  73. children: [
  74. Container(
  75. margin: EdgeInsets.only(left: 18.w),
  76. child: Obx(() {
  77. return Column(
  78. crossAxisAlignment: CrossAxisAlignment.start,
  79. children: [
  80. Text(
  81. "Analysis Results",
  82. style: TextStyle(
  83. color: Colors.white,
  84. fontWeight: FontWeight.w900,
  85. fontSize: 16.sp,
  86. ),
  87. ),
  88. Visibility(
  89. visible: controller.createTime.value.isNotEmpty,
  90. child: Column(
  91. children: [
  92. SizedBox(
  93. height: 20.h,
  94. ),
  95. Text(
  96. controller.createTime.value,
  97. style: TextStyle(
  98. color: Colors.white,
  99. fontWeight: FontWeight.w500,
  100. fontSize: 13.sp,
  101. ),
  102. ),
  103. ],
  104. ),
  105. ),
  106. Visibility(
  107. visible: controller.fileName.value.isNotEmpty,
  108. child: Column(
  109. children: [
  110. SizedBox(
  111. height: 12.h,
  112. ),
  113. Text(
  114. controller.fileName.value,
  115. style: TextStyle(
  116. color: Colors.white,
  117. fontWeight: FontWeight.w500,
  118. fontSize: 13.sp,
  119. ),
  120. ),
  121. ],
  122. ),
  123. ),
  124. Visibility(
  125. visible: controller.model.value.isNotEmpty,
  126. child: Column(
  127. children: [
  128. SizedBox(
  129. height: 12.h,
  130. ),
  131. Text(
  132. controller.model.value,
  133. style: TextStyle(
  134. color: Colors.white,
  135. fontWeight: FontWeight.w500,
  136. fontSize: 13.sp,
  137. ),
  138. ),
  139. ],
  140. ),
  141. ),
  142. Visibility(
  143. visible: controller.focalLength.value.isNotEmpty,
  144. child: Column(
  145. children: [
  146. SizedBox(
  147. height: 12.h,
  148. ),
  149. Text(
  150. controller.focalLength.value,
  151. style: TextStyle(
  152. color: Colors.white,
  153. fontWeight: FontWeight.w500,
  154. fontSize: 13.sp,
  155. ),
  156. ),
  157. ],
  158. ),
  159. ),
  160. Visibility(
  161. visible: controller.size.value.isNotEmpty,
  162. child: Column(
  163. children: [
  164. SizedBox(
  165. height: 12.h,
  166. ),
  167. Text(
  168. controller.size.value,
  169. style: TextStyle(
  170. color: Colors.white,
  171. fontWeight: FontWeight.w500,
  172. fontSize: 13.sp,
  173. ),
  174. ),
  175. ],
  176. ),
  177. ),
  178. Visibility(
  179. visible: controller.iso.value.isNotEmpty,
  180. child: Column(
  181. children: [
  182. SizedBox(
  183. height: 12.h,
  184. ),
  185. Text(
  186. controller.iso.value,
  187. style: TextStyle(
  188. color: Colors.white,
  189. fontWeight: FontWeight.w500,
  190. fontSize: 13.sp,
  191. ),
  192. ),
  193. ],
  194. ),
  195. ),
  196. Visibility(
  197. visible: controller.address.value.isNotEmpty,
  198. child: Column(
  199. children: [
  200. SizedBox(
  201. height: 12.h,
  202. ),
  203. Text(
  204. controller.address.value,
  205. style: TextStyle(
  206. color: Colors.white,
  207. fontWeight: FontWeight.w500,
  208. fontSize: 13.sp,
  209. ),
  210. ),
  211. ],
  212. ),
  213. ),
  214. SizedBox(height: 32.h,),
  215. ],
  216. );
  217. }),
  218. ),
  219. Center(
  220. child: GestureDetector(
  221. onTap: () {
  222. controller.deleteBtnClick(
  223. controller.imageList[
  224. controller.currentImageIndex.value],
  225. controller.currentImageIndex.value);
  226. },
  227. child: Container(
  228. width: 328.w,
  229. height: 48.h,
  230. decoration: BoxDecoration(
  231. color: "#0279FB".color,
  232. borderRadius: BorderRadius.all(
  233. Radius.circular(10.r),
  234. ),
  235. ),
  236. child: Center(
  237. child: Row(
  238. mainAxisAlignment: MainAxisAlignment.center,
  239. children: [
  240. Assets.images.iconPrivacyPhotoDelete
  241. .image(width: 18.w, height: 18.h),
  242. SizedBox(
  243. width: 5.w,
  244. ),
  245. Obx(() {
  246. if (controller.imageList.isEmpty) {
  247. return SizedBox.shrink();
  248. }
  249. return Text(
  250. controller.formatFileSize(controller
  251. .imageList[controller
  252. .currentImageIndex.value]
  253. .size ??
  254. 0),
  255. style: TextStyle(
  256. color: Colors.white,
  257. fontSize: 16.sp,
  258. fontWeight: FontWeight.w500,
  259. ),
  260. );
  261. }),
  262. ],
  263. ),
  264. ),
  265. ),
  266. ),
  267. ),
  268. ],
  269. ),
  270. ),
  271. ),
  272. ],
  273. ),
  274. ),
  275. IgnorePointer(
  276. child: Assets.images.bgHome.image(
  277. width: 360.w,
  278. ),
  279. ),
  280. ],
  281. );
  282. }
  283. // 轮播图组件
  284. Widget _buildImageCarousel() {
  285. return Obx(() {
  286. if (controller.imageList.isEmpty) {
  287. return SizedBox.shrink();
  288. }
  289. return SizedBox(
  290. height: 492.h,
  291. width: ScreenUtil().screenWidth,
  292. child: PageView.builder(
  293. controller: PageController(
  294. viewportFraction: 1, // 显示部分下一张图片
  295. initialPage: controller.currentImageIndex.value,
  296. ),
  297. onPageChanged: (index) {
  298. controller.currentImageIndex.value = index;
  299. controller.loadPhotoInfo();
  300. PhotoManager.clearFileCache();
  301. },
  302. itemCount: controller.imageList.length,
  303. itemBuilder: (context, index) {
  304. final asset = controller.imageList[index];
  305. return AnimatedPadding(
  306. duration: Duration(milliseconds: 300),
  307. padding: EdgeInsets.symmetric(
  308. horizontal: 0.w,
  309. vertical:
  310. controller.currentImageIndex.value == index ? 0 : 20.h,
  311. ),
  312. child: GestureDetector(
  313. // onTap: () => _showImageDetail(asset),
  314. child: Container(
  315. decoration: BoxDecoration(
  316. borderRadius: BorderRadius.circular(12.r),
  317. boxShadow: [
  318. BoxShadow(
  319. color: Colors.black.withOpacity(0.2),
  320. blurRadius: 8,
  321. offset: Offset(0, 4),
  322. ),
  323. ],
  324. ),
  325. child: ClipRRect(
  326. child: FutureBuilder<File?>(
  327. key: ValueKey(asset.id),
  328. future:
  329. ImageUtil.getImageFile(controller.type.value, asset),
  330. builder: (context, snapshot) {
  331. if (snapshot.hasData && snapshot.data != null) {
  332. return InteractiveViewer(
  333. minScale: 0.5,
  334. maxScale: 3.0,
  335. child: Image.file(
  336. snapshot.data!,
  337. fit: BoxFit.fitHeight,
  338. width: double.infinity,
  339. height: 400,
  340. filterQuality: FilterQuality.high,
  341. ),
  342. );
  343. }
  344. return Container(
  345. color: Colors.grey[800],
  346. child: Icon(Icons.error, color: Colors.white60),
  347. );
  348. },
  349. ),
  350. ),
  351. ),
  352. ),
  353. );
  354. },
  355. ),
  356. );
  357. });
  358. }
  359. }