import 'dart:io'; import 'package:clean/module/image_picker/image_picker_util.dart'; import 'package:clean/module/locations_photo/locations_single_photo_view.dart'; import 'package:clean/module/people_photo/photo_group.dart'; import 'package:get/get.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart' as p; import 'package:wechat_assets_picker/wechat_assets_picker.dart'; class LocationsPhotoController extends GetxController { final RxList photoGroups = [].obs; @override onInit() { super.onInit(); loadLocationPhoto(); } void loadLocationPhoto() { photoGroups.clear(); RxMap> locationPhotos = ImagePickerUtil.locationPhotos; if (locationPhotos.isNotEmpty) { for (var entry in locationPhotos.entries) { photoGroups.add(PhotoGroup( title: 'photo: ${entry.value.length}', imageCount: entry.value.length, isSelected: false, images: entry.value, location: entry.key, )); } } } void clickPhotoGroup(PhotoGroup photoGroup) { print('clickPhotoGroup ${photoGroup.location}'); LocationsSinglePhotoPage.start(photoGroup: photoGroup); } PhotoGroup getGroupByLocation(String? location) { return photoGroups.firstWhere((group) => group.location == location); } // PhotoGroup getGroupByImages(List images) { // final imageIds = images.map((img) => img.id).toSet(); // return photoGroups.firstWhere((group) => // group.images.every((image) => imageIds.contains(image.id)) // ); // } }