import 'package:get/get.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

class PhotoGroup {

  final String title;
  //照片组的总数。
  final int imageCount;
  // 照片组是否被全选中
  final RxBool isSelected;
  // 照片组的列表。
  final List<AssetEntity> images;
  //单个照片是否被选中
  final RxList<bool> selectedImages;

  // 选中的照片数量
  int get selectedCount => selectedImages.where((selected) => selected).length;

  PhotoGroup({
    required this.title,
    required this.imageCount,
    required bool isSelected,
    required this.images,
  })  : isSelected = isSelected.obs,
        selectedImages = List.generate(imageCount, (_) => isSelected).obs;

  void toggleSelectAll(bool value) {
    isSelected.value = value;
    selectedImages.assignAll(List.generate(images.length, (_) => value));
  }
}
