nc-photos/app/lib/entity/favorite.dart

46 lines
909 B
Dart
Raw Normal View History

2022-01-25 11:08:13 +01:00
import 'package:equatable/equatable.dart';
import 'package:nc_photos/account.dart';
import 'package:nc_photos/entity/file.dart';
2022-12-08 16:39:13 +01:00
import 'package:to_string/to_string.dart';
2022-01-25 11:08:13 +01:00
2022-12-08 16:39:13 +01:00
part 'favorite.g.dart';
@toString
2022-01-25 11:08:13 +01:00
class Favorite with EquatableMixin {
const Favorite({
required this.fileId,
});
@override
2022-12-08 16:39:13 +01:00
String toString() => _$toString();
2022-01-25 11:08:13 +01:00
Favorite copyWith({
int? fileId,
}) =>
Favorite(
fileId: fileId ?? this.fileId,
);
2022-01-25 11:08:13 +01:00
@override
get props => [
fileId,
];
final int fileId;
}
class FavoriteRepo {
const FavoriteRepo(this.dataSrc);
/// See [FavoriteDataSource.list]
Future<List<Favorite>> list(Account account, File dir) =>
dataSrc.list(account, dir);
final FavoriteDataSource dataSrc;
}
abstract class FavoriteDataSource {
/// List all favorites for a user under [dir]
Future<List<Favorite>> list(Account account, File dir);
}