photo_info_view.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. shadows: [
  84. Shadow(
  85. color: Colors.black,
  86. blurRadius: 5.r,
  87. ),
  88. ],
  89. color: Colors.white,
  90. fontWeight: FontWeight.w900,
  91. fontSize: 16.sp,
  92. ),
  93. ),
  94. Visibility(
  95. visible: controller.createTime.value.isNotEmpty,
  96. child: Column(
  97. children: [
  98. SizedBox(
  99. height: 20.h,
  100. ),
  101. Text(
  102. controller.createTime.value,
  103. style: TextStyle(
  104. shadows: [
  105. Shadow(
  106. color: Colors.black,
  107. blurRadius: 5.r,
  108. ),
  109. ],
  110. color: Colors.white,
  111. fontWeight: FontWeight.w500,
  112. fontSize: 13.sp,
  113. ),
  114. ),
  115. ],
  116. ),
  117. ),
  118. Visibility(
  119. visible: controller.fileName.value.isNotEmpty,
  120. child: Column(
  121. children: [
  122. SizedBox(
  123. height: 12.h,
  124. ),
  125. Text(
  126. controller.fileName.value,
  127. style: TextStyle(
  128. shadows: [
  129. Shadow(
  130. color: Colors.black,
  131. blurRadius: 5.r,
  132. ),
  133. ],
  134. color: Colors.white,
  135. fontWeight: FontWeight.w500,
  136. fontSize: 13.sp,
  137. ),
  138. ),
  139. ],
  140. ),
  141. ),
  142. Visibility(
  143. visible: controller.model.value.isNotEmpty,
  144. child: Column(
  145. children: [
  146. SizedBox(
  147. height: 12.h,
  148. ),
  149. Text(
  150. controller.model.value,
  151. style: TextStyle(
  152. shadows: [
  153. Shadow(
  154. color: Colors.black,
  155. blurRadius: 5.r,
  156. ),
  157. ],
  158. color: Colors.white,
  159. fontWeight: FontWeight.w500,
  160. fontSize: 13.sp,
  161. ),
  162. ),
  163. ],
  164. ),
  165. ),
  166. Visibility(
  167. visible: controller.focalLength.value.isNotEmpty,
  168. child: Column(
  169. children: [
  170. SizedBox(
  171. height: 12.h,
  172. ),
  173. Text(
  174. controller.focalLength.value,
  175. style: TextStyle(
  176. shadows: [
  177. Shadow(
  178. color: Colors.black,
  179. blurRadius: 5.r,
  180. ),
  181. ],
  182. color: Colors.white,
  183. fontWeight: FontWeight.w500,
  184. fontSize: 13.sp,
  185. ),
  186. ),
  187. ],
  188. ),
  189. ),
  190. Visibility(
  191. visible: controller.size.value.isNotEmpty,
  192. child: Column(
  193. children: [
  194. SizedBox(
  195. height: 12.h,
  196. ),
  197. Text(
  198. controller.size.value,
  199. style: TextStyle(
  200. shadows: [
  201. Shadow(
  202. color: Colors.black,
  203. blurRadius: 5.r,
  204. ),
  205. ],
  206. color: Colors.white,
  207. fontWeight: FontWeight.w500,
  208. fontSize: 13.sp,
  209. ),
  210. ),
  211. ],
  212. ),
  213. ),
  214. Visibility(
  215. visible: controller.iso.value.isNotEmpty,
  216. child: Column(
  217. children: [
  218. SizedBox(
  219. height: 12.h,
  220. ),
  221. Text(
  222. controller.iso.value,
  223. style: TextStyle(
  224. shadows: [
  225. Shadow(
  226. color: Colors.black,
  227. blurRadius: 5.r,
  228. ),
  229. ],
  230. color: Colors.white,
  231. fontWeight: FontWeight.w500,
  232. fontSize: 13.sp,
  233. ),
  234. ),
  235. ],
  236. ),
  237. ),
  238. Visibility(
  239. visible: controller.address.value.isNotEmpty,
  240. child: Column(
  241. children: [
  242. SizedBox(
  243. height: 12.h,
  244. ),
  245. Text(
  246. controller.address.value,
  247. style: TextStyle(
  248. shadows: [
  249. Shadow(
  250. color: Colors.black,
  251. blurRadius: 5.r,
  252. ),
  253. ],
  254. color: Colors.white,
  255. fontWeight: FontWeight.w500,
  256. fontSize: 13.sp,
  257. ),
  258. ),
  259. ],
  260. ),
  261. ),
  262. SizedBox(height: 32.h,),
  263. ],
  264. );
  265. }),
  266. ),
  267. Center(
  268. child: GestureDetector(
  269. onTap: () {
  270. controller.deleteBtnClick(
  271. controller.imageList[
  272. controller.currentImageIndex.value],
  273. controller.currentImageIndex.value);
  274. },
  275. child: Container(
  276. width: 328.w,
  277. height: 48.h,
  278. decoration: BoxDecoration(
  279. color: "#0279FB".color,
  280. borderRadius: BorderRadius.all(
  281. Radius.circular(10.r),
  282. ),
  283. ),
  284. child: Center(
  285. child: Row(
  286. mainAxisAlignment: MainAxisAlignment.center,
  287. children: [
  288. Assets.images.iconPrivacyPhotoDelete
  289. .image(width: 18.w, height: 18.h),
  290. SizedBox(
  291. width: 5.w,
  292. ),
  293. Obx(() {
  294. if (controller.imageList.isEmpty) {
  295. return SizedBox.shrink();
  296. }
  297. return Text(
  298. controller.formatFileSize(controller
  299. .imageList[controller
  300. .currentImageIndex.value]
  301. .size ??
  302. 0),
  303. style: TextStyle(
  304. color: Colors.white,
  305. fontSize: 16.sp,
  306. fontWeight: FontWeight.w500,
  307. ),
  308. );
  309. }),
  310. ],
  311. ),
  312. ),
  313. ),
  314. ),
  315. ),
  316. ],
  317. ),
  318. ),
  319. ),
  320. ],
  321. ),
  322. ),
  323. IgnorePointer(
  324. child: Assets.images.bgHome.image(
  325. width: 360.w,
  326. ),
  327. ),
  328. ],
  329. );
  330. }
  331. // 轮播图组件
  332. Widget _buildImageCarousel() {
  333. return Obx(() {
  334. if (controller.imageList.isEmpty) {
  335. return SizedBox.shrink();
  336. }
  337. return SizedBox(
  338. height: 492.h,
  339. width: ScreenUtil().screenWidth,
  340. child: PageView.builder(
  341. controller: PageController(
  342. viewportFraction: 1, // 显示部分下一张图片
  343. initialPage: controller.currentImageIndex.value,
  344. ),
  345. onPageChanged: (index) {
  346. controller.currentImageIndex.value = index;
  347. controller.loadPhotoInfo();
  348. PhotoManager.clearFileCache();
  349. },
  350. itemCount: controller.imageList.length,
  351. itemBuilder: (context, index) {
  352. final asset = controller.imageList[index];
  353. return AnimatedPadding(
  354. duration: Duration(milliseconds: 300),
  355. padding: EdgeInsets.symmetric(
  356. horizontal: 0.w,
  357. vertical:
  358. controller.currentImageIndex.value == index ? 0 : 20.h,
  359. ),
  360. child: GestureDetector(
  361. // onTap: () => _showImageDetail(asset),
  362. child: Container(
  363. decoration: BoxDecoration(
  364. borderRadius: BorderRadius.circular(12.r),
  365. boxShadow: [
  366. BoxShadow(
  367. color: Colors.black.withOpacity(0.2),
  368. blurRadius: 8,
  369. offset: Offset(0, 4),
  370. ),
  371. ],
  372. ),
  373. child: ClipRRect(
  374. child: FutureBuilder<File?>(
  375. key: ValueKey(asset.id),
  376. future:
  377. ImageUtil.getImageFile(controller.type.value, asset),
  378. builder: (context, snapshot) {
  379. if (snapshot.hasData && snapshot.data != null) {
  380. return InteractiveViewer(
  381. minScale: 0.5,
  382. maxScale: 3.0,
  383. child: Image.file(
  384. snapshot.data!,
  385. fit: BoxFit.fitHeight,
  386. width: double.infinity,
  387. height: 400,
  388. filterQuality: FilterQuality.high,
  389. ),
  390. );
  391. }
  392. return Container(
  393. color: Colors.grey[800],
  394. child: Icon(Icons.error, color: Colors.white60),
  395. );
  396. },
  397. ),
  398. ),
  399. ),
  400. ),
  401. );
  402. },
  403. ),
  404. );
  405. });
  406. }
  407. }