photo_info_view.dart 18 KB

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