photo_info_view.dart 18 KB

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