2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/entity/album/item.dart';
|
|
|
|
import 'package:nc_photos/entity/collection_item.dart';
|
|
|
|
import 'package:nc_photos/entity/file_descriptor.dart';
|
2024-10-30 17:30:12 +01:00
|
|
|
import 'package:np_gps_map/np_gps_map.dart';
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:to_string/to_string.dart';
|
|
|
|
|
|
|
|
part 'album_item_adapter.g.dart';
|
|
|
|
|
|
|
|
mixin AlbumAdaptedCollectionItem on CollectionItem {
|
|
|
|
static AlbumAdaptedCollectionItem fromItem(AlbumItem item) {
|
|
|
|
if (item is AlbumFileItem) {
|
|
|
|
return CollectionFileItemAlbumAdapter(item);
|
|
|
|
} else if (item is AlbumLabelItem) {
|
|
|
|
return CollectionLabelItemAlbumAdapter(item);
|
2024-10-30 17:30:12 +01:00
|
|
|
} else if (item is AlbumMapItem) {
|
|
|
|
return CollectionMapItemAlbumAdapter(item);
|
2023-04-13 17:32:31 +02:00
|
|
|
} else {
|
|
|
|
throw ArgumentError("Unknown type: ${item.runtimeType}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AlbumItem get albumItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@toString
|
|
|
|
class CollectionFileItemAlbumAdapter extends CollectionFileItem
|
|
|
|
with AlbumAdaptedCollectionItem {
|
|
|
|
const CollectionFileItemAlbumAdapter(this.item);
|
|
|
|
|
2024-02-16 18:57:48 +01:00
|
|
|
@override
|
|
|
|
CollectionFileItemAlbumAdapter copyWith({
|
|
|
|
FileDescriptor? file,
|
|
|
|
}) {
|
|
|
|
return CollectionFileItemAlbumAdapter(item.copyWith(
|
|
|
|
file: file,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2023-04-13 17:32:31 +02:00
|
|
|
@override
|
|
|
|
String toString() => _$toString();
|
|
|
|
|
|
|
|
@override
|
|
|
|
FileDescriptor get file => item.file;
|
|
|
|
|
|
|
|
@override
|
|
|
|
AlbumItem get albumItem => item;
|
|
|
|
|
|
|
|
final AlbumFileItem item;
|
|
|
|
}
|
|
|
|
|
|
|
|
@toString
|
|
|
|
class CollectionLabelItemAlbumAdapter extends CollectionLabelItem
|
|
|
|
with AlbumAdaptedCollectionItem {
|
|
|
|
const CollectionLabelItemAlbumAdapter(this.item);
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => _$toString();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Object get id => item.addedAt;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get text => item.text;
|
|
|
|
|
|
|
|
@override
|
|
|
|
AlbumItem get albumItem => item;
|
|
|
|
|
|
|
|
final AlbumLabelItem item;
|
|
|
|
}
|
2024-10-30 17:30:12 +01:00
|
|
|
|
|
|
|
@toString
|
|
|
|
class CollectionMapItemAlbumAdapter extends CollectionMapItem
|
|
|
|
with AlbumAdaptedCollectionItem {
|
|
|
|
const CollectionMapItemAlbumAdapter(this.item);
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => _$toString();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Object get id => item.addedAt;
|
|
|
|
|
|
|
|
@override
|
|
|
|
CameraPosition get location => item.location;
|
|
|
|
|
|
|
|
@override
|
|
|
|
AlbumItem get albumItem => item;
|
|
|
|
|
|
|
|
final AlbumMapItem item;
|
|
|
|
}
|