photo_info_view.dart 18 KB

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