| 12345678910111213141516171819202122232425262728 |
- // 创建一个共享状态类
- import 'package:get/get_rx/src/rx_types/rx_types.dart';
- import 'package:intl/intl.dart';
- import '../../model/asset_info.dart';
- class PrivacyState {
- static RxList<AssetInfo> imageList = <AssetInfo>[].obs;
- static RxMap<String, List<AssetInfo>> assetsByMonth = <String, List<AssetInfo>>{}.obs;
- // 删除图片
- static void removeAsset(String assetId) {
- imageList.removeWhere((asset) => asset.id == assetId);
- updateMonthlyAssets();
- }
- // 更新月份分组
- static void updateMonthlyAssets() {
- assetsByMonth.clear();
- for (var asset in imageList) {
- final month = DateFormat('yyyy-MM').format(asset.createDateTime);
- if (!assetsByMonth.containsKey(month)) {
- assetsByMonth[month] = [];
- }
- assetsByMonth[month]!.add(asset);
- }
- }
- }
|