1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00
immich/mobile/lib/models/asset_selection_state.dart

57 lines
1.6 KiB
Dart
Raw Normal View History

import 'package:immich_mobile/entities/asset.entity.dart';
2023-10-22 02:38:07 +00:00
class AssetSelectionState {
2023-10-22 02:38:07 +00:00
final bool hasRemote;
final bool hasLocal;
final bool hasMerged;
final int selectedCount;
2023-10-22 02:38:07 +00:00
const AssetSelectionState({
2023-10-22 02:38:07 +00:00
this.hasRemote = false,
this.hasLocal = false,
this.hasMerged = false,
this.selectedCount = 0,
2023-10-22 02:38:07 +00:00
});
AssetSelectionState copyWith({
2023-10-22 02:38:07 +00:00
bool? hasRemote,
bool? hasLocal,
bool? hasMerged,
int? selectedCount,
2023-10-22 02:38:07 +00:00
}) {
return AssetSelectionState(
2023-10-22 02:38:07 +00:00
hasRemote: hasRemote ?? this.hasRemote,
hasLocal: hasLocal ?? this.hasLocal,
hasMerged: hasMerged ?? this.hasMerged,
selectedCount: selectedCount ?? this.selectedCount,
2023-10-22 02:38:07 +00:00
);
}
AssetSelectionState.fromSelection(Set<Asset> selection)
2023-10-22 02:38:07 +00:00
: hasLocal = selection.any((e) => e.storage == AssetState.local),
hasMerged = selection.any((e) => e.storage == AssetState.merged),
hasRemote = selection.any((e) => e.storage == AssetState.remote),
selectedCount = selection.length;
2023-10-22 02:38:07 +00:00
@override
String toString() =>
'SelectionAssetState(hasRemote: $hasRemote, hasMerged: $hasMerged, hasMerged: $hasMerged, selectedCount: $selectedCount)';
2023-10-22 02:38:07 +00:00
@override
bool operator ==(covariant AssetSelectionState other) {
2023-10-22 02:38:07 +00:00
if (identical(this, other)) return true;
return other.hasRemote == hasRemote &&
other.hasLocal == hasLocal &&
other.hasMerged == hasMerged &&
other.selectedCount == selectedCount;
2023-10-22 02:38:07 +00:00
}
@override
int get hashCode =>
hasRemote.hashCode ^
hasLocal.hashCode ^
hasMerged.hashCode ^
selectedCount.hashCode;
2023-10-22 02:38:07 +00:00
}