| 123456789101112131415161718192021222324252627282930313233343536 |
- import 'package:intl/intl.dart';
- import 'package:get/get.dart';
- import '../people_photo/photo_group.dart';
- class CalendarState {
- static final RxList<PhotoGroup> monthlyAlbums = <PhotoGroup>[].obs;
- // 格式化月份
- static String formatMonth(String month) {
- try {
- DateTime date = DateFormat('yyyy-MM').parse(month);
- return DateFormat('MMM , yyyy').format(date); // 转换为 "Nov, 2024" 格式
- } catch (e) {
- return month; // 如果解析失败,返回原始字符串
- }
- }
- static String formatDuration(int seconds) {
- int minutes = seconds ~/ 60;
- int secs = seconds % 60;
- return '${minutes.toString().padLeft(2, '0')}:${secs.toString().padLeft(2, '0')}';
- }
- static void removePhotosData(Set<String> selectedPhotosIds) {
- monthlyAlbums.removeWhere((album) {
- album.images
- .removeWhere((element) => selectedPhotosIds.contains(element.id));
- album.selectedPhotosIds
- .removeWhere((element) => selectedPhotosIds.contains(element));
- // 如果images为空,删除该 album
- return album.images.isEmpty;
- });
- }
- }
|