|
|
@@ -0,0 +1,191 @@
|
|
|
+import 'dart:io';
|
|
|
+
|
|
|
+import 'package:clean/base/base_page.dart';
|
|
|
+import 'package:clean/module/image_picker/image_picker_util.dart';
|
|
|
+import 'package:clean/module/photo_info/photo_info_controller.dart';
|
|
|
+import 'package:clean/utils/expand.dart';
|
|
|
+import 'package:flutter/Material.dart';
|
|
|
+import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
+import 'package:get/get.dart';
|
|
|
+import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
|
|
+import '../../resource/assets.gen.dart';
|
|
|
+import '../../utils/image_util.dart';
|
|
|
+import 'dart:typed_data';
|
|
|
+
|
|
|
+class PhotoInfoPage extends BasePage<PhotoInfoController> {
|
|
|
+ const PhotoInfoPage({super.key});
|
|
|
+
|
|
|
+ @override
|
|
|
+ bool statusBarDarkFont() => false;
|
|
|
+
|
|
|
+ @override
|
|
|
+ bool immersive() => true;
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget buildBody(BuildContext context) {
|
|
|
+ return Stack(
|
|
|
+ children: [
|
|
|
+ SafeArea(
|
|
|
+ child: Column(
|
|
|
+ // mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 16.w, top: 14.h),
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ Get.back();
|
|
|
+ },
|
|
|
+ child: Assets.images.iconCommonBack
|
|
|
+ .image(width: 28.w, height: 28.w),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 16.w, top: 12.h),
|
|
|
+ child: Text(
|
|
|
+ controller.imageList[controller.currentImageIndex.value]
|
|
|
+ .dateTitle ?? "",
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ fontSize: 24.sp,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ SizedBox(height: 20.h,),
|
|
|
+ _buildImageCarousel(),
|
|
|
+ Spacer(),
|
|
|
+ Center(
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ controller.deleteBtnClick(controller.imageList[controller
|
|
|
+ .currentImageIndex.value], controller.currentImageIndex.value);
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ width: 328.w,
|
|
|
+ height: 48.h,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: "#0279FB".color,
|
|
|
+ borderRadius: BorderRadius.all(
|
|
|
+ Radius.circular(10.r),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ child: Center(
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Assets.images.iconPrivacyPhotoDelete
|
|
|
+ .image(width: 18.w, height: 18.h),
|
|
|
+ SizedBox(
|
|
|
+ width: 5.w,
|
|
|
+ ),
|
|
|
+ Obx(() {
|
|
|
+ if (controller.imageList.isEmpty) return SizedBox.shrink();
|
|
|
+ return Text(
|
|
|
+ controller.formatFileSize(
|
|
|
+ controller.imageList[controller
|
|
|
+ .currentImageIndex.value].size ?? 0),
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 16.sp,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ IgnorePointer(
|
|
|
+ child: Assets.images.bgHome.image(
|
|
|
+ width: 360.w,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 轮播图组件
|
|
|
+ Widget _buildImageCarousel() {
|
|
|
+ return Obx(() {
|
|
|
+ if (controller.imageList.isEmpty) {
|
|
|
+ return SizedBox.shrink();
|
|
|
+ }
|
|
|
+
|
|
|
+ return SizedBox(
|
|
|
+ height: 492.h,
|
|
|
+ width: ScreenUtil().screenWidth,
|
|
|
+ child: PageView.builder(
|
|
|
+ controller: PageController(
|
|
|
+ viewportFraction: 1, // 显示部分下一张图片
|
|
|
+ initialPage: controller.currentImageIndex.value,
|
|
|
+ ),
|
|
|
+ onPageChanged: (index) {
|
|
|
+ controller.currentImageIndex.value = index;
|
|
|
+ PhotoManager.clearFileCache();
|
|
|
+ },
|
|
|
+ itemCount: controller.imageList.length,
|
|
|
+ itemBuilder: (context, index) {
|
|
|
+ final asset = controller.imageList[index];
|
|
|
+ return
|
|
|
+ AnimatedPadding(
|
|
|
+ duration: Duration(milliseconds: 300),
|
|
|
+ padding: EdgeInsets.symmetric(
|
|
|
+ horizontal: 0.w,
|
|
|
+ vertical:
|
|
|
+ controller.currentImageIndex.value == index ? 0 : 20.h,
|
|
|
+ ),
|
|
|
+ child:
|
|
|
+ GestureDetector(
|
|
|
+ // onTap: () => _showImageDetail(asset),
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(12.r),
|
|
|
+ boxShadow: [
|
|
|
+ BoxShadow(
|
|
|
+ color: Colors.black.withOpacity(0.2),
|
|
|
+ blurRadius: 8,
|
|
|
+ offset: Offset(0, 4),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ child: ClipRRect(
|
|
|
+ child: FutureBuilder<File?>(
|
|
|
+ key: ValueKey(asset.id),
|
|
|
+ future: ImageUtil.getImageFile(asset),
|
|
|
+ builder: (context, snapshot) {
|
|
|
+ if (snapshot.hasData && snapshot.data != null) {
|
|
|
+ return InteractiveViewer(
|
|
|
+ minScale: 0.5,
|
|
|
+ maxScale: 3.0,
|
|
|
+ child: Image.file(
|
|
|
+ snapshot.data!,
|
|
|
+ fit: BoxFit.fill,
|
|
|
+ width: double.infinity,
|
|
|
+ height: double.infinity,
|
|
|
+ filterQuality: FilterQuality.high,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return Container(
|
|
|
+ color: Colors.grey[800],
|
|
|
+ child: Icon(Icons.error, color: Colors.white60),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|