photo_info_view.dart 18 KB

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