photo_info_view.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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:flutter/Material.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'package:get/get.dart';
  9. import 'package:wechat_assets_picker/wechat_assets_picker.dart';
  10. import '../../resource/assets.gen.dart';
  11. import '../../utils/image_util.dart';
  12. import 'dart:typed_data';
  13. class PhotoInfoPage extends BasePage<PhotoInfoController> {
  14. const PhotoInfoPage({super.key});
  15. @override
  16. bool statusBarDarkFont() => false;
  17. @override
  18. bool immersive() => true;
  19. @override
  20. Widget buildBody(BuildContext context) {
  21. return Stack(
  22. children: [
  23. SafeArea(
  24. child: Stack(
  25. children: [
  26. Column(
  27. // mainAxisAlignment: MainAxisAlignment.center,
  28. crossAxisAlignment: CrossAxisAlignment.start,
  29. children: [
  30. Container(
  31. margin: EdgeInsets.only(left: 16.w, top: 14.h),
  32. child: GestureDetector(
  33. onTap: () {
  34. Get.back();
  35. },
  36. child: Assets.images.iconCommonBack
  37. .image(width: 28.w, height: 28.w),
  38. ),
  39. ),
  40. Container(
  41. margin: EdgeInsets.only(left: 16.w, top: 12.h),
  42. child: Obx(() {
  43. if (controller.imageList.isEmpty) {
  44. return SizedBox.shrink();
  45. }
  46. return Text(
  47. controller.imageList[controller.currentImageIndex.value]
  48. .dateTitle ??
  49. "",
  50. style: TextStyle(
  51. color: Colors.white,
  52. fontWeight: FontWeight.w500,
  53. fontSize: 24.sp,
  54. ),
  55. );
  56. }),
  57. ),
  58. SizedBox(
  59. height: 20.h,
  60. ),
  61. _buildImageCarousel(),
  62. ],
  63. ),
  64. Positioned(
  65. left: 0,
  66. right: 0,
  67. bottom: 0,
  68. child: Column(
  69. crossAxisAlignment: CrossAxisAlignment.start,
  70. children: [
  71. Container(
  72. margin: EdgeInsets.only(left: 18.w),
  73. child: Obx(() {
  74. return Column(
  75. crossAxisAlignment: CrossAxisAlignment.start,
  76. children: [
  77. Text(
  78. "Analysis Results",
  79. style: TextStyle(
  80. color: Colors.white,
  81. fontWeight: FontWeight.w900,
  82. fontSize: 16.sp,
  83. ),
  84. ),
  85. Visibility(
  86. visible: controller.createTime.value.isNotEmpty,
  87. child: Column(
  88. children: [
  89. SizedBox(
  90. height: 20.h,
  91. ),
  92. Text(
  93. controller.createTime.value,
  94. style: TextStyle(
  95. color: Colors.white,
  96. fontWeight: FontWeight.w500,
  97. fontSize: 13.sp,
  98. ),
  99. ),
  100. ],
  101. ),
  102. ),
  103. Visibility(
  104. visible: controller.fileName.value.isNotEmpty,
  105. child: Column(
  106. children: [
  107. SizedBox(
  108. height: 12.h,
  109. ),
  110. Text(
  111. controller.fileName.value,
  112. style: TextStyle(
  113. color: Colors.white,
  114. fontWeight: FontWeight.w500,
  115. fontSize: 13.sp,
  116. ),
  117. ),
  118. ],
  119. ),
  120. ),
  121. Visibility(
  122. visible: controller.model.value.isNotEmpty,
  123. child: Column(
  124. children: [
  125. SizedBox(
  126. height: 12.h,
  127. ),
  128. Text(
  129. controller.model.value,
  130. style: TextStyle(
  131. color: Colors.white,
  132. fontWeight: FontWeight.w500,
  133. fontSize: 13.sp,
  134. ),
  135. ),
  136. ],
  137. ),
  138. ),
  139. Visibility(
  140. visible: controller.focalLength.value.isNotEmpty,
  141. child: Column(
  142. children: [
  143. SizedBox(
  144. height: 12.h,
  145. ),
  146. Text(
  147. controller.focalLength.value,
  148. style: TextStyle(
  149. color: Colors.white,
  150. fontWeight: FontWeight.w500,
  151. fontSize: 13.sp,
  152. ),
  153. ),
  154. ],
  155. ),
  156. ),
  157. Visibility(
  158. visible: controller.size.value.isNotEmpty,
  159. child: Column(
  160. children: [
  161. SizedBox(
  162. height: 12.h,
  163. ),
  164. Text(
  165. controller.size.value,
  166. style: TextStyle(
  167. color: Colors.white,
  168. fontWeight: FontWeight.w500,
  169. fontSize: 13.sp,
  170. ),
  171. ),
  172. ],
  173. ),
  174. ),
  175. Visibility(
  176. visible: controller.iso.value.isNotEmpty,
  177. child: Column(
  178. children: [
  179. SizedBox(
  180. height: 12.h,
  181. ),
  182. Text(
  183. controller.iso.value,
  184. style: TextStyle(
  185. color: Colors.white,
  186. fontWeight: FontWeight.w500,
  187. fontSize: 13.sp,
  188. ),
  189. ),
  190. ],
  191. ),
  192. ),
  193. Visibility(
  194. visible: controller.address.value.isNotEmpty,
  195. child: Column(
  196. children: [
  197. SizedBox(
  198. height: 12.h,
  199. ),
  200. Text(
  201. controller.address.value,
  202. style: TextStyle(
  203. color: Colors.white,
  204. fontWeight: FontWeight.w500,
  205. fontSize: 13.sp,
  206. ),
  207. ),
  208. ],
  209. ),
  210. ),
  211. SizedBox(height: 32.h,),
  212. ],
  213. );
  214. }),
  215. ),
  216. Center(
  217. child: GestureDetector(
  218. onTap: () {
  219. controller.deleteBtnClick(
  220. controller.imageList[
  221. controller.currentImageIndex.value],
  222. controller.currentImageIndex.value);
  223. },
  224. child: Container(
  225. width: 328.w,
  226. height: 48.h,
  227. decoration: BoxDecoration(
  228. color: "#0279FB".color,
  229. borderRadius: BorderRadius.all(
  230. Radius.circular(10.r),
  231. ),
  232. ),
  233. child: Center(
  234. child: Row(
  235. mainAxisAlignment: MainAxisAlignment.center,
  236. children: [
  237. Assets.images.iconPrivacyPhotoDelete
  238. .image(width: 18.w, height: 18.h),
  239. SizedBox(
  240. width: 5.w,
  241. ),
  242. Obx(() {
  243. if (controller.imageList.isEmpty) {
  244. return SizedBox.shrink();
  245. }
  246. return Text(
  247. controller.formatFileSize(controller
  248. .imageList[controller
  249. .currentImageIndex.value]
  250. .size ??
  251. 0),
  252. style: TextStyle(
  253. color: Colors.white,
  254. fontSize: 16.sp,
  255. fontWeight: FontWeight.w500,
  256. ),
  257. );
  258. }),
  259. ],
  260. ),
  261. ),
  262. ),
  263. ),
  264. ),
  265. ],
  266. ),
  267. ),
  268. ],
  269. ),
  270. ),
  271. IgnorePointer(
  272. child: Assets.images.bgHome.image(
  273. width: 360.w,
  274. ),
  275. ),
  276. ],
  277. );
  278. }
  279. // 轮播图组件
  280. Widget _buildImageCarousel() {
  281. return Obx(() {
  282. if (controller.imageList.isEmpty) {
  283. return SizedBox.shrink();
  284. }
  285. return SizedBox(
  286. height: 492.h,
  287. width: ScreenUtil().screenWidth,
  288. child: PageView.builder(
  289. controller: PageController(
  290. viewportFraction: 1, // 显示部分下一张图片
  291. initialPage: controller.currentImageIndex.value,
  292. ),
  293. onPageChanged: (index) {
  294. controller.currentImageIndex.value = index;
  295. controller.loadPhotoInfo();
  296. PhotoManager.clearFileCache();
  297. },
  298. itemCount: controller.imageList.length,
  299. itemBuilder: (context, index) {
  300. final asset = controller.imageList[index];
  301. return AnimatedPadding(
  302. duration: Duration(milliseconds: 300),
  303. padding: EdgeInsets.symmetric(
  304. horizontal: 0.w,
  305. vertical:
  306. controller.currentImageIndex.value == index ? 0 : 20.h,
  307. ),
  308. child: GestureDetector(
  309. // onTap: () => _showImageDetail(asset),
  310. child: Container(
  311. decoration: BoxDecoration(
  312. borderRadius: BorderRadius.circular(12.r),
  313. boxShadow: [
  314. BoxShadow(
  315. color: Colors.black.withOpacity(0.2),
  316. blurRadius: 8,
  317. offset: Offset(0, 4),
  318. ),
  319. ],
  320. ),
  321. child: ClipRRect(
  322. child: FutureBuilder<File?>(
  323. key: ValueKey(asset.id),
  324. future:
  325. ImageUtil.getImageFile(controller.type.value, asset),
  326. builder: (context, snapshot) {
  327. if (snapshot.hasData && snapshot.data != null) {
  328. return InteractiveViewer(
  329. minScale: 0.5,
  330. maxScale: 3.0,
  331. child: Image.file(
  332. snapshot.data!,
  333. fit: BoxFit.fitHeight,
  334. width: double.infinity,
  335. height: 400,
  336. filterQuality: FilterQuality.high,
  337. ),
  338. );
  339. }
  340. return Container(
  341. color: Colors.grey[800],
  342. child: Icon(Icons.error, color: Colors.white60),
  343. );
  344. },
  345. ),
  346. ),
  347. ),
  348. ),
  349. );
  350. },
  351. ),
  352. );
  353. });
  354. }
  355. }