locations_photo_controller.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import 'dart:io';
  2. import 'package:clean/module/image_picker/image_picker_util.dart';
  3. import 'package:clean/module/locations_photo/locations_single_photo_view.dart';
  4. import 'package:clean/module/people_photo/photo_group.dart';
  5. import 'package:get/get.dart';
  6. import 'package:path_provider/path_provider.dart';
  7. import 'package:path/path.dart' as p;
  8. import 'package:wechat_assets_picker/wechat_assets_picker.dart';
  9. class LocationsPhotoController extends GetxController {
  10. final RxList<PhotoGroup> photoGroups = <PhotoGroup>[].obs;
  11. @override
  12. onInit() {
  13. super.onInit();
  14. loadLocationPhoto();
  15. }
  16. void loadLocationPhoto() {
  17. photoGroups.clear();
  18. if (ImagePickerUtil.locationPhotos.isEmpty) {
  19. print('locationPhotos.isEmpty');
  20. return;
  21. }
  22. if (ImagePickerUtil.locationPhotos.values.isNotEmpty) {
  23. print('locationPhotos.isNotEmpty ${ImagePickerUtil.locationPhotos.values}');
  24. for (var entry in ImagePickerUtil.locationPhotos.entries) {
  25. photoGroups.add(PhotoGroup(
  26. isSelected: false,
  27. images: entry.value,
  28. location: entry.key,
  29. ));
  30. }
  31. }
  32. }
  33. void clickPhotoGroup(PhotoGroup photoGroup) {
  34. print('clickPhotoGroup ${photoGroup.location}');
  35. LocationsSinglePhotoPage.start(photoGroup: photoGroup);
  36. }
  37. PhotoGroup getGroupByLocation(String? location) {
  38. return photoGroups.firstWhere((group) => group.location == location);
  39. }
  40. void restoreSelections() {
  41. }
  42. // PhotoGroup getGroupByImages(List<AssetEntity> images) {
  43. // final imageIds = images.map((img) => img.id).toSet();
  44. // return photoGroups.firstWhere((group) =>
  45. // group.images.every((image) => imageIds.contains(image.id))
  46. // );
  47. // }
  48. }