
import 'package:clean/base/base_controller.dart';
import 'package:clean/base/base_photo_controller.dart';
import 'package:clean/data/bean/photos_type.dart';
import 'package:clean/module/image_picker/image_picker_util.dart';
import 'package:clean/module/locations_photo/locations_photo_controller.dart';
import 'package:clean/module/people_photo/photo_group.dart';
import 'package:clean/module/photo_preview/photo_preview_view.dart';
import 'package:clean/utils/toast_util.dart';
import 'package:get/get.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

class LocationsSinglePhotoController extends BasePhotoController {


  late PhotoGroup photoGroup;

  @override
  void onInit() {
    print('LocationsSinglePhotoController onInit');
    _getArgs();
    super.onInit();
  }

  // 获取传递的参数
  void _getArgs() {
    final parameters = Get.arguments;
    photoGroup = parameters?['PhotoGroup'] as PhotoGroup;
  }

  // // 通过位置获取照片组
  // PhotoGroup getGroupByLocation(String? location) {
  //   return photoGroups.firstWhere((group) => group.location == location);
  // }


  // 获取对应的 PhotosType
  @override
  PhotosType getPhotosType() {
    return PhotosType.locationPhotos;
  }



  @override
  void loadPhotos() {
    photoGroups.clear();
    if (photoGroup.images.isNotEmpty) {
      photoGroups.add(photoGroup);
    }
    selectedPhotosIds.assignAll(ImagePickerUtil.selectedLocationPhotosIds);
  }

  void clickBack() {
    print('LocationsSinglePhotoController clickBack selectedPhotosIds $selectedPhotosIds');
    updateSelections(selectedPhotosIds); // 恢复选中状态
    Get.back();
  }
}