2023-04-13 17:32:31 +02:00
|
|
|
import 'package:clock/clock.dart';
|
|
|
|
import 'package:copy_with/copy_with.dart';
|
2023-04-28 19:21:53 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/account.dart';
|
|
|
|
import 'package:nc_photos/api/api_util.dart' as api_util;
|
|
|
|
import 'package:nc_photos/entity/collection.dart';
|
2023-05-01 19:05:33 +02:00
|
|
|
import 'package:nc_photos/entity/collection/util.dart';
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/entity/collection_item/util.dart';
|
|
|
|
import 'package:nc_photos/entity/nc_album.dart';
|
|
|
|
import 'package:to_string/to_string.dart';
|
|
|
|
|
|
|
|
part 'nc_album.g.dart';
|
|
|
|
|
|
|
|
/// Album provided by our app
|
|
|
|
@genCopyWith
|
|
|
|
@toString
|
2023-04-28 19:21:53 +02:00
|
|
|
class CollectionNcAlbumProvider
|
|
|
|
with EquatableMixin
|
|
|
|
implements CollectionContentProvider {
|
2023-04-13 17:32:31 +02:00
|
|
|
const CollectionNcAlbumProvider({
|
|
|
|
required this.account,
|
|
|
|
required this.album,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => _$toString();
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get fourCc => "NC25";
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get id => album.path;
|
|
|
|
|
|
|
|
@override
|
|
|
|
int? get count => album.count;
|
|
|
|
|
|
|
|
@override
|
|
|
|
DateTime get lastModified => album.dateEnd ?? clock.now().toUtc();
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<CollectionCapability> get capabilities => [
|
|
|
|
CollectionCapability.manualItem,
|
|
|
|
CollectionCapability.rename,
|
2023-05-06 19:44:35 +02:00
|
|
|
// CollectionCapability.share,
|
2023-04-13 17:32:31 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
@override
|
|
|
|
CollectionItemSort get itemSort => CollectionItemSort.dateDescending;
|
|
|
|
|
2023-05-01 19:05:33 +02:00
|
|
|
@override
|
2023-05-06 19:44:35 +02:00
|
|
|
List<CollectionShare> get shares => album.collaborators
|
|
|
|
.map((c) => CollectionShare(
|
|
|
|
userId: c.id,
|
|
|
|
username: c.label,
|
|
|
|
))
|
|
|
|
.toList();
|
2023-05-01 19:05:33 +02:00
|
|
|
|
2023-04-13 17:32:31 +02:00
|
|
|
@override
|
2023-04-28 19:21:53 +02:00
|
|
|
String? getCoverUrl(
|
|
|
|
int width,
|
|
|
|
int height, {
|
|
|
|
bool? isKeepAspectRatio,
|
|
|
|
}) {
|
2023-04-13 17:32:31 +02:00
|
|
|
if (album.lastPhoto == null) {
|
|
|
|
return null;
|
|
|
|
} else {
|
2023-05-07 19:33:11 +02:00
|
|
|
return api_util.getPhotosApiFilePreviewUrlByFileId(
|
2023-04-13 17:32:31 +02:00
|
|
|
account,
|
|
|
|
album.lastPhoto!,
|
|
|
|
width: width,
|
|
|
|
height: height,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-28 19:21:53 +02:00
|
|
|
@override
|
|
|
|
List<Object?> get props => [account, album];
|
|
|
|
|
2023-04-13 17:32:31 +02:00
|
|
|
final Account account;
|
|
|
|
final NcAlbum album;
|
|
|
|
}
|