|
|
@@ -7,6 +7,7 @@ import 'package:clean/router/app_pages.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';
|
|
|
|
|
|
class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
const SimilarPhotoPage({super.key});
|
|
|
@@ -36,15 +37,14 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
|
children: [
|
|
|
...controller.photoGroups.map((group) => Column(
|
|
|
- children: [
|
|
|
- _buildPhotoGroup(
|
|
|
- title: group.title,
|
|
|
- imageCount: group.imageCount,
|
|
|
-
|
|
|
- ),
|
|
|
- SizedBox(height: 15.h),
|
|
|
- ],
|
|
|
- ))
|
|
|
+ children: [
|
|
|
+ _buildPhotoGroup(
|
|
|
+ title: group.title,
|
|
|
+ imageCount: group.imageCount,
|
|
|
+ ),
|
|
|
+ SizedBox(height: 15.h),
|
|
|
+ ],
|
|
|
+ ))
|
|
|
],
|
|
|
);
|
|
|
}),
|
|
|
@@ -110,15 +110,28 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: [
|
|
|
- Obx(() => Text(
|
|
|
- '${controller.selectedFileCount} files selected (${controller.selectedFilesSize.toStringAsFixed(1)} KB)',
|
|
|
- textAlign: TextAlign.center,
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white.withValues(alpha: 0.9),
|
|
|
- fontSize: 13.sp,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- ),
|
|
|
- )),
|
|
|
+ Obx(() {
|
|
|
+ return FutureBuilder<double>(
|
|
|
+ future: controller.getSelectedFilesSize(),
|
|
|
+ builder: (context, snapshot) {
|
|
|
+ if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
+ return CircularProgressIndicator();
|
|
|
+ } else if (snapshot.hasError) {
|
|
|
+ return Text('Error: ${snapshot.error}');
|
|
|
+ } else {
|
|
|
+ return Text(
|
|
|
+ '${controller.selectedFileCount} files selected (${snapshot.data?.toStringAsFixed(1)} KB)',
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white.withValues(alpha: 0.9),
|
|
|
+ fontSize: 13.sp,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }),
|
|
|
Container(
|
|
|
width: 108.w,
|
|
|
height: 38.h,
|
|
|
@@ -155,7 +168,6 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
Widget _buildPhotoGroup({
|
|
|
required String title,
|
|
|
required int imageCount,
|
|
|
-
|
|
|
}) {
|
|
|
return Container(
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
|
|
@@ -185,24 +197,23 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
fontWeight: FontWeight.w500,
|
|
|
),
|
|
|
),
|
|
|
-
|
|
|
],
|
|
|
),
|
|
|
GestureDetector(
|
|
|
onTap: () => controller.toggleGroupSelection(title),
|
|
|
child: Obx(() => Text(
|
|
|
- controller.photoGroups
|
|
|
- .firstWhere((g) => g.title == title)
|
|
|
- .isSelected
|
|
|
- .value
|
|
|
- ? 'Deselect All'
|
|
|
- : 'Select All',
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white.withValues(alpha: 0.7),
|
|
|
- fontSize: 14.sp,
|
|
|
- fontWeight: FontWeight.w400,
|
|
|
- ),
|
|
|
- )),
|
|
|
+ controller.photoGroups
|
|
|
+ .firstWhere((g) => g.title == title)
|
|
|
+ .isSelected
|
|
|
+ .value
|
|
|
+ ? 'Deselect All'
|
|
|
+ : 'Select All',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white.withValues(alpha: 0.7),
|
|
|
+ fontSize: 14.sp,
|
|
|
+ fontWeight: FontWeight.w400,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
@@ -226,12 +237,13 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
children: [
|
|
|
Container(
|
|
|
decoration: ShapeDecoration(
|
|
|
- color: Colors.white.withValues(alpha: 0.12),
|
|
|
+ color: Colors.white.withOpacity(0.12),
|
|
|
shape: RoundedRectangleBorder(
|
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
|
),
|
|
|
image: DecorationImage(
|
|
|
- image: FileImage(File(group.images[0])),
|
|
|
+ image:
|
|
|
+ AssetEntityImageProvider(group.images[0]),
|
|
|
fit: BoxFit.cover,
|
|
|
),
|
|
|
),
|
|
|
@@ -240,7 +252,6 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
left: 8.w,
|
|
|
top: 8.h,
|
|
|
child: Container(
|
|
|
-
|
|
|
width: 108.w,
|
|
|
height: 26.h,
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
@@ -251,12 +262,12 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
color: Colors.black.withValues(alpha: 0.74),
|
|
|
shape: RoundedRectangleBorder(
|
|
|
borderRadius:
|
|
|
- BorderRadius.circular(14.21.r),
|
|
|
+ BorderRadius.circular(14.21.r),
|
|
|
),
|
|
|
),
|
|
|
child: Row(
|
|
|
mainAxisAlignment:
|
|
|
- MainAxisAlignment.spaceAround,
|
|
|
+ MainAxisAlignment.spaceAround,
|
|
|
children: [
|
|
|
Assets.images.iconSimilarBest.image(
|
|
|
width: 11.37.w,
|
|
|
@@ -281,18 +292,18 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
child: Container(
|
|
|
child: group.selectedImages[0]
|
|
|
? Center(
|
|
|
- child: Assets.images.iconSelected.image(
|
|
|
- width: 16.w,
|
|
|
- height: 16.h,
|
|
|
- ),
|
|
|
- )
|
|
|
+ child: Assets.images.iconSelected.image(
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.h,
|
|
|
+ ),
|
|
|
+ )
|
|
|
: Center(
|
|
|
- child:
|
|
|
- Assets.images.iconUnselected.image(
|
|
|
- width: 16.w,
|
|
|
- height: 16.h,
|
|
|
- ),
|
|
|
- ),
|
|
|
+ child:
|
|
|
+ Assets.images.iconUnselected.image(
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.h,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
],
|
|
|
@@ -313,7 +324,7 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
crossAxisSpacing: 8.w,
|
|
|
children: List.generate(
|
|
|
min(4, imageCount - 1 - gridIndex * 4),
|
|
|
- (index) {
|
|
|
+ (index) {
|
|
|
final realIndex = gridIndex * 4 + index + 1;
|
|
|
return GestureDetector(
|
|
|
onTap: () => controller.toggleImageSelection(
|
|
|
@@ -328,8 +339,8 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
|
),
|
|
|
image: DecorationImage(
|
|
|
- image: FileImage(
|
|
|
- File(group.images[realIndex])),
|
|
|
+ image: AssetEntityImageProvider(
|
|
|
+ group.images[realIndex]),
|
|
|
fit: BoxFit.cover,
|
|
|
),
|
|
|
),
|
|
|
@@ -340,25 +351,25 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
bottom: 4.h,
|
|
|
child: Obx(() {
|
|
|
final isSelected =
|
|
|
- group.selectedImages[realIndex];
|
|
|
+ group.selectedImages[realIndex];
|
|
|
return Container(
|
|
|
child: isSelected
|
|
|
? Center(
|
|
|
- child: Assets
|
|
|
- .images.iconSelected
|
|
|
- .image(
|
|
|
- width: 16.w,
|
|
|
- height: 16.h,
|
|
|
- ),
|
|
|
- )
|
|
|
+ child: Assets
|
|
|
+ .images.iconSelected
|
|
|
+ .image(
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.h,
|
|
|
+ ),
|
|
|
+ )
|
|
|
: Center(
|
|
|
- child: Assets
|
|
|
- .images.iconUnselected
|
|
|
- .image(
|
|
|
- width: 16.w,
|
|
|
- height: 16.h,
|
|
|
- ),
|
|
|
- ),
|
|
|
+ child: Assets
|
|
|
+ .images.iconUnselected
|
|
|
+ .image(
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.h,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
);
|
|
|
}),
|
|
|
),
|
|
|
@@ -376,7 +387,6 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
),
|
|
|
),
|
|
|
Container(
|
|
|
-
|
|
|
width: 162.w,
|
|
|
height: 38.h,
|
|
|
decoration: ShapeDecoration(
|
|
|
@@ -385,17 +395,15 @@ class SimilarPhotoPage extends BasePage<SimilarPhotoController> {
|
|
|
borderRadius: BorderRadius.circular(10.r),
|
|
|
),
|
|
|
),
|
|
|
-
|
|
|
-
|
|
|
child: Center(
|
|
|
child: Obx(() => Text(
|
|
|
- 'Move ${controller.photoGroups.firstWhere((g) => g.title == title).selectedCount} to trash',
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontSize: 16.sp,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- ),
|
|
|
- )),
|
|
|
+ 'Move ${controller.photoGroups.firstWhere((g) => g.title == title).selectedCount} to trash',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 16.sp,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
),
|
|
|
),
|
|
|
],
|