2023-07-03 19:23:42 +02:00
|
|
|
import 'package:copy_with/copy_with.dart';
|
2021-09-08 12:44:14 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
2022-12-08 16:39:13 +01:00
|
|
|
import 'package:to_string/to_string.dart';
|
2021-09-08 12:44:14 +02:00
|
|
|
|
2022-12-08 16:39:13 +01:00
|
|
|
part 'person.g.dart';
|
|
|
|
|
2023-07-03 19:23:42 +02:00
|
|
|
@genCopyWith
|
2022-12-08 16:39:13 +01:00
|
|
|
@toString
|
2021-09-08 12:44:14 +02:00
|
|
|
class Person with EquatableMixin {
|
2022-08-05 11:14:03 +02:00
|
|
|
const Person({
|
2021-09-10 19:10:26 +02:00
|
|
|
required this.name,
|
2023-07-03 19:23:42 +02:00
|
|
|
required this.contentProvider,
|
2021-09-08 12:44:14 +02:00
|
|
|
});
|
|
|
|
|
2021-09-10 19:10:26 +02:00
|
|
|
@override
|
2022-12-08 16:39:13 +01:00
|
|
|
String toString() => _$toString();
|
2021-09-10 19:10:26 +02:00
|
|
|
|
2023-07-03 19:23:42 +02:00
|
|
|
bool compareIdentity(Person other) => other.id == id;
|
|
|
|
|
|
|
|
int get identityHashCode => id.hashCode;
|
|
|
|
|
|
|
|
/// A unique id for each collection. The value is divided into two parts in
|
|
|
|
/// the format XXXX-YYY...YYY, where XXXX is a four-character code
|
|
|
|
/// representing the content provider type, and YYY is an implementation
|
|
|
|
/// detail of each providers
|
|
|
|
String get id => "${contentProvider.fourCc}-${contentProvider.id}";
|
|
|
|
|
|
|
|
/// See [PersonContentProvider.count]
|
|
|
|
int? get count => contentProvider.count;
|
|
|
|
|
|
|
|
/// See [PersonContentProvider.getCoverUrl]
|
|
|
|
String? getCoverUrl(
|
|
|
|
int width,
|
|
|
|
int height, {
|
|
|
|
bool? isKeepAspectRatio,
|
|
|
|
}) =>
|
|
|
|
contentProvider.getCoverUrl(
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
isKeepAspectRatio: isKeepAspectRatio,
|
|
|
|
);
|
|
|
|
|
2021-09-08 12:44:14 +02:00
|
|
|
@override
|
2023-07-03 19:23:42 +02:00
|
|
|
List<Object?> get props => [
|
2021-09-08 12:44:14 +02:00
|
|
|
name,
|
2023-07-03 19:23:42 +02:00
|
|
|
contentProvider,
|
2021-09-08 12:44:14 +02:00
|
|
|
];
|
|
|
|
|
2021-09-10 19:10:26 +02:00
|
|
|
final String name;
|
2023-07-03 19:23:42 +02:00
|
|
|
final PersonContentProvider contentProvider;
|
2021-09-08 12:44:14 +02:00
|
|
|
}
|
|
|
|
|
2023-07-03 19:23:42 +02:00
|
|
|
abstract class PersonContentProvider with EquatableMixin {
|
|
|
|
const PersonContentProvider();
|
2021-09-08 12:44:14 +02:00
|
|
|
|
2023-07-03 19:23:42 +02:00
|
|
|
/// Unique FourCC of this provider type
|
|
|
|
String get fourCc;
|
2021-09-08 12:44:14 +02:00
|
|
|
|
2023-07-03 19:23:42 +02:00
|
|
|
/// Return the unique id of this person
|
|
|
|
String get id;
|
2021-09-08 12:44:14 +02:00
|
|
|
|
2023-07-03 19:23:42 +02:00
|
|
|
/// Return the number of items in this person, or null if not supported
|
|
|
|
int? get count;
|
|
|
|
|
|
|
|
/// Return the URL of the cover image if available
|
|
|
|
///
|
|
|
|
/// The [width] and [height] are provided as a hint only, implementations are
|
|
|
|
/// free to ignore them if it's not supported
|
|
|
|
///
|
|
|
|
/// [isKeepAspectRatio] is only a hint and implementations may ignore it
|
|
|
|
String? getCoverUrl(
|
|
|
|
int width,
|
|
|
|
int height, {
|
|
|
|
bool? isKeepAspectRatio,
|
|
|
|
});
|
2021-09-08 12:44:14 +02:00
|
|
|
}
|