|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:io';
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:clean/base/base_page.dart';
|
|
import 'package:clean/base/base_page.dart';
|
|
|
|
|
+import 'package:clean/module/image_picker/image_picker_util.dart';
|
|
|
import 'package:clean/module/people_photo/people_photo_controller.dart';
|
|
import 'package:clean/module/people_photo/people_photo_controller.dart';
|
|
|
import 'package:clean/resource/assets.gen.dart';
|
|
import 'package:clean/resource/assets.gen.dart';
|
|
|
import 'package:clean/router/app_pages.dart';
|
|
import 'package:clean/router/app_pages.dart';
|
|
@@ -14,7 +15,6 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
const PeoplePhotoPage({super.key});
|
|
const PeoplePhotoPage({super.key});
|
|
|
|
|
|
|
|
static start() {
|
|
static start() {
|
|
|
- Get.put((PeoplePhotoController()));
|
|
|
|
|
Get.toNamed(RoutePath.peoplePhoto, arguments: {});
|
|
Get.toNamed(RoutePath.peoplePhoto, arguments: {});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -45,14 +45,15 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
|
children: [
|
|
children: [
|
|
|
...controller.photoGroups.map((group) => Column(
|
|
...controller.photoGroups.map((group) => Column(
|
|
|
- children: [
|
|
|
|
|
- _buildPhotoGroup(
|
|
|
|
|
- title: group.title,
|
|
|
|
|
- imageCount: group.imageCount,
|
|
|
|
|
- ),
|
|
|
|
|
- SizedBox(height: 15.h),
|
|
|
|
|
- ],
|
|
|
|
|
- ))
|
|
|
|
|
|
|
+ children: [
|
|
|
|
|
+ _buildPhotoGroup(
|
|
|
|
|
+ images: group.images,
|
|
|
|
|
+ title: group.title,
|
|
|
|
|
+ imageCount: group.imageCount,
|
|
|
|
|
+ ),
|
|
|
|
|
+ SizedBox(height: 15.h),
|
|
|
|
|
+ ],
|
|
|
|
|
+ ))
|
|
|
],
|
|
],
|
|
|
);
|
|
);
|
|
|
}),
|
|
}),
|
|
@@ -119,27 +120,17 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
child: Row(
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: [
|
|
children: [
|
|
|
- Obx(() => 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,
|
|
|
|
|
- ),
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- )
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ Obx(() {
|
|
|
|
|
+ return Text(
|
|
|
|
|
+ '${controller.selectedFileCount.value} files selected (${controller.selectedFilesSize.value.toStringAsFixed(1)} KB)',
|
|
|
|
|
+ textAlign: TextAlign.center,
|
|
|
|
|
+ style: TextStyle(
|
|
|
|
|
+ color: Colors.white.withOpacity(0.9),
|
|
|
|
|
+ fontSize: 13.sp,
|
|
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+ }),
|
|
|
Container(
|
|
Container(
|
|
|
width: 108.w,
|
|
width: 108.w,
|
|
|
height: 38.h,
|
|
height: 38.h,
|
|
@@ -174,6 +165,7 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Widget _buildPhotoGroup({
|
|
Widget _buildPhotoGroup({
|
|
|
|
|
+ required List<AssetEntity> images,
|
|
|
required String title,
|
|
required String title,
|
|
|
required int imageCount,
|
|
required int imageCount,
|
|
|
}) {
|
|
}) {
|
|
@@ -181,7 +173,7 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
|
|
margin: EdgeInsets.only(top: 14.h),
|
|
margin: EdgeInsets.only(top: 14.h),
|
|
|
width: 328.w,
|
|
width: 328.w,
|
|
|
- height: 230.h,
|
|
|
|
|
|
|
+ height: imageCount < 5 ? 160.h : 230.h,
|
|
|
decoration: ShapeDecoration(
|
|
decoration: ShapeDecoration(
|
|
|
color: Colors.white.withValues(alpha: 0.12),
|
|
color: Colors.white.withValues(alpha: 0.12),
|
|
|
shape: RoundedRectangleBorder(
|
|
shape: RoundedRectangleBorder(
|
|
@@ -204,63 +196,68 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
GestureDetector(
|
|
GestureDetector(
|
|
|
- onTap: () => controller.toggleGroupSelection(title),
|
|
|
|
|
|
|
+ onTap: () => controller.toggleGroupSelection(images),
|
|
|
child: Obx(() => Text(
|
|
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.getGroupByImages(images).isSelected.value
|
|
|
|
|
+ ? 'Deselect All'
|
|
|
|
|
+ : 'Select All',
|
|
|
|
|
+ style: TextStyle(
|
|
|
|
|
+ color: Colors.white.withValues(alpha: 0.7),
|
|
|
|
|
+ fontSize: 14.sp,
|
|
|
|
|
+ fontWeight: FontWeight.w400,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )),
|
|
|
),
|
|
),
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
SizedBox(
|
|
SizedBox(
|
|
|
- height: imageCount <= 8 ? null : 148.w,
|
|
|
|
|
|
|
+ height: imageCount < 3
|
|
|
|
|
+ ? 70.h
|
|
|
|
|
+ : imageCount <= 8
|
|
|
|
|
+ ? null
|
|
|
|
|
+ : 148.h,
|
|
|
child: imageCount <= 8
|
|
child: imageCount <= 8
|
|
|
? GridView.builder(
|
|
? GridView.builder(
|
|
|
- shrinkWrap: true,
|
|
|
|
|
- physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
- crossAxisCount: 4,
|
|
|
|
|
- mainAxisSpacing: 8.w,
|
|
|
|
|
- crossAxisSpacing: 8.h,
|
|
|
|
|
- ),
|
|
|
|
|
- itemCount: imageCount,
|
|
|
|
|
- itemBuilder: _buildPhotoItem(title),
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ shrinkWrap: true,
|
|
|
|
|
+ physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
+ crossAxisCount: 4,
|
|
|
|
|
+ mainAxisSpacing: 8.w,
|
|
|
|
|
+ crossAxisSpacing: 8.h,
|
|
|
|
|
+ ),
|
|
|
|
|
+ itemCount: imageCount,
|
|
|
|
|
+ itemBuilder: _buildPhotoItem(images),
|
|
|
|
|
+ )
|
|
|
: GridView.builder(
|
|
: GridView.builder(
|
|
|
- scrollDirection: Axis.horizontal,
|
|
|
|
|
- physics: BouncingScrollPhysics(),
|
|
|
|
|
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
- crossAxisCount: 2,
|
|
|
|
|
- mainAxisSpacing: 8.w,
|
|
|
|
|
- crossAxisSpacing: 8.h,
|
|
|
|
|
- childAspectRatio: 1,
|
|
|
|
|
- ),
|
|
|
|
|
- itemCount: imageCount,
|
|
|
|
|
- itemBuilder: _buildPhotoItem(title),
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ scrollDirection: Axis.horizontal,
|
|
|
|
|
+ physics: BouncingScrollPhysics(),
|
|
|
|
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
+ crossAxisCount: 2,
|
|
|
|
|
+ mainAxisSpacing: 8.w,
|
|
|
|
|
+ crossAxisSpacing: 8.h,
|
|
|
|
|
+ childAspectRatio: 1,
|
|
|
|
|
+ ),
|
|
|
|
|
+ itemCount: imageCount,
|
|
|
|
|
+ itemBuilder: _buildPhotoItem(images),
|
|
|
|
|
+ ),
|
|
|
),
|
|
),
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Widget Function(BuildContext, int) _buildPhotoItem(String title) =>
|
|
|
|
|
- (context, index) {
|
|
|
|
|
- final group =
|
|
|
|
|
- controller.photoGroups.firstWhere((group) => group.title == title);
|
|
|
|
|
|
|
+ Widget Function(BuildContext, int) _buildPhotoItem(
|
|
|
|
|
+ List<AssetEntity> images) =>
|
|
|
|
|
+ (context, index) {
|
|
|
|
|
+ final group = controller.getGroupByImages(images);
|
|
|
|
|
+
|
|
|
final assetEntity = group.images[index];
|
|
final assetEntity = group.images[index];
|
|
|
|
|
|
|
|
return GestureDetector(
|
|
return GestureDetector(
|
|
|
- onTap: () => controller.toggleImageSelection(title, index),
|
|
|
|
|
|
|
+ onTap: () {
|
|
|
|
|
+ controller.clickImage(images, index);
|
|
|
|
|
+ print("点击图片");
|
|
|
|
|
+ },
|
|
|
child: Obx(() {
|
|
child: Obx(() {
|
|
|
final isSelected = group.selectedImages[index];
|
|
final isSelected = group.selectedImages[index];
|
|
|
return Stack(
|
|
return Stack(
|
|
@@ -269,34 +266,41 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
|
|
|
width: 70.w,
|
|
width: 70.w,
|
|
|
height: 70.w,
|
|
height: 70.w,
|
|
|
decoration: ShapeDecoration(
|
|
decoration: ShapeDecoration(
|
|
|
- color: Colors.white.withOpacity(0.12),
|
|
|
|
|
|
|
+ color: Colors.white.withValues(alpha: 0.12),
|
|
|
shape: RoundedRectangleBorder(
|
|
shape: RoundedRectangleBorder(
|
|
|
borderRadius: BorderRadius.circular(9.27.sp),
|
|
borderRadius: BorderRadius.circular(9.27.sp),
|
|
|
),
|
|
),
|
|
|
image: DecorationImage(
|
|
image: DecorationImage(
|
|
|
- image: AssetEntityImageProvider(assetEntity),
|
|
|
|
|
|
|
+ image: AssetEntityImageProvider(
|
|
|
|
|
+ assetEntity,
|
|
|
|
|
+ isOriginal: false,
|
|
|
|
|
+ ),
|
|
|
fit: BoxFit.cover,
|
|
fit: BoxFit.cover,
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
Positioned(
|
|
Positioned(
|
|
|
- right: 6.w,
|
|
|
|
|
- bottom: 6.h,
|
|
|
|
|
- child: Container(
|
|
|
|
|
- child: isSelected
|
|
|
|
|
- ? Center(
|
|
|
|
|
- child: Assets.images.iconSelected.image(
|
|
|
|
|
- width: 20.w,
|
|
|
|
|
- height: 20.h,
|
|
|
|
|
|
|
+ right: 6.w,
|
|
|
|
|
+ bottom: 6.h,
|
|
|
|
|
+ child: GestureDetector(
|
|
|
|
|
+ onTap: () {
|
|
|
|
|
+ controller.toggleImageSelection(images, index);
|
|
|
|
|
+ },
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ child: isSelected
|
|
|
|
|
+ ? Center(
|
|
|
|
|
+ child: Assets.images.iconSelected.image(
|
|
|
|
|
+ width: 20.w,
|
|
|
|
|
+ height: 20.h,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+ : Center(
|
|
|
|
|
+ child: Assets.images.iconUnselected.image(
|
|
|
|
|
+ width: 20.w,
|
|
|
|
|
+ height: 20.h,
|
|
|
|
|
+ )),
|
|
|
),
|
|
),
|
|
|
- )
|
|
|
|
|
- : Center(
|
|
|
|
|
- child: Assets.images.iconUnselected.image(
|
|
|
|
|
- width: 20.w,
|
|
|
|
|
- height: 20.h,
|
|
|
|
|
- )),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ )),
|
|
|
],
|
|
],
|
|
|
);
|
|
);
|
|
|
}),
|
|
}),
|