nc-photos/app/lib/entity/person/content_provider/face_recognition.dart
2023-07-22 22:27:54 +08:00

55 lines
1.2 KiB
Dart

import 'dart:math' as math;
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:nc_photos/account.dart';
import 'package:nc_photos/api/api_util.dart' as api_util;
import 'package:nc_photos/entity/face_recognition_person.dart';
import 'package:nc_photos/entity/person.dart';
import 'package:to_string/to_string.dart';
part 'face_recognition.g.dart';
@toString
class PersonFaceRecognitionProvider
with EquatableMixin
implements PersonContentProvider {
const PersonFaceRecognitionProvider({
required this.account,
required this.person,
});
@override
String toString() => _$toString();
@override
String get fourCc => "FACR";
@override
String get id => person.name;
@override
int? get count => person.count;
@override
String? getCoverUrl(
int width,
int height, {
bool? isKeepAspectRatio,
}) {
return api_util.getFacePreviewUrl(
account,
person.thumbFaceId,
size: math.max(width, height),
);
}
@override
Matrix4? getCoverTransform(int viewportSize, int width, int height) => null;
@override
List<Object?> get props => [account, person];
final Account account;
final FaceRecognitionPerson person;
}