86 lines
2.0 KiB
Dart
Raw Normal View History

part of '../../photo_gallery.dart';
2020-08-14 18:07:27 +08:00
/// A album in the gallery.
@immutable
class Album {
/// A unique identifier for the album.
final String id;
/// The [MediumType] of the album.
2021-03-18 12:00:31 +00:00
final MediumType? mediumType;
2020-08-14 18:07:27 +08:00
/// The sort direction is newest or not
final bool newest;
2020-08-14 18:07:27 +08:00
/// The name of the album.
2021-10-20 21:27:32 +08:00
final String? name;
2020-08-14 18:07:27 +08:00
/// The total number of media in the album.
final int count;
/// Indicates whether this album contains all media.
bool get isAllAlbum => id == "__ALL__";
/// Creates a album from platform channel protocol.
Album.fromJson(dynamic json, this.mediumType, this.newest)
2020-08-14 18:07:27 +08:00
: id = json['id'],
name = json['name'],
2023-06-12 00:59:30 +08:00
count = json['count'] ?? 0;
2020-08-14 18:07:27 +08:00
/// list media in the album.
///
/// Pagination can be controlled out of [skip] (defaults to `0`) and
/// [take] (defaults to `<total>`).
Future<MediaPage> listMedia({
2021-03-18 12:00:31 +00:00
int? skip,
int? take,
bool? lightWeight,
2020-08-14 18:07:27 +08:00
}) {
return PhotoGallery._listMedia(
album: this,
skip: skip,
take: take,
lightWeight: lightWeight,
2020-08-14 18:07:27 +08:00
);
}
/// Get thumbnail data for this album.
///
/// It will display the lastly taken medium thumbnail.
Future<List<int>> getThumbnail({
2021-03-18 12:00:31 +00:00
int? width,
int? height,
bool? highQuality = false,
2020-08-14 18:07:27 +08:00
}) {
return PhotoGallery.getAlbumThumbnail(
albumId: id,
mediumType: mediumType,
2020-08-14 18:07:27 +08:00
width: width,
height: height,
highQuality: highQuality,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Album &&
runtimeType == other.runtimeType &&
id == other.id &&
mediumType == other.mediumType &&
name == other.name &&
count == other.count;
@override
int get hashCode =>
id.hashCode ^ mediumType.hashCode ^ name.hashCode ^ count.hashCode;
@override
String toString() {
return 'Album{id: $id, '
'mediumType: $mediumType, '
'name: $name, '
'count: $count}';
}
}