Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Better align widget

laurenspriem48e9032ac187
diff --git a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
index 9c09a126b3..8be39494a0 100644
--- a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
@@ -52,23 +52,13 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
late final mlDataDB = MLDataDB.instance;
try {
if (file.uploadedFileID == null) {
- return [
- ChipButtonWidget(
- S.of(context).fileNotUploadedYet,
- noChips: true,
- ),
- ];
+ return [const NoFaceChipButtonWidget(NoFacesReason.fileNotUploaded)];
}
final List<Face>? faces =
await mlDataDB.getFacesForGivenFileID(file.uploadedFileID!);
if (faces == null) {
- return [
- ChipButtonWidget(
- S.of(context).imageNotAnalyzed,
- noChips: true,
- ),
- ];
+ return [const NoFaceChipButtonWidget(NoFacesReason.fileNotAnalyzed)];
}
// Remove faces with low scores
@@ -88,12 +78,7 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
}
if (faces.isEmpty) {
- return [
- ChipButtonWidget(
- S.of(context).noFacesFound,
- noChips: true,
- ),
- ];
+ return [const NoFaceChipButtonWidget(NoFacesReason.noFacesFound)];
}
final faceIdsToClusterIds = await mlDataDB
@@ -182,3 +167,43 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
}
}
}
+
+enum NoFacesReason {
+ fileNotUploaded,
+ fileNotAnalyzed,
+ noFacesFound,
+}
+
+String getNoFaceReasonText(
+ BuildContext context,
+ NoFacesReason reason,
+) {
+ switch (reason) {
+ case NoFacesReason.fileNotUploaded:
+ return S.of(context).fileNotUploadedYet;
+ case NoFacesReason.fileNotAnalyzed:
+ return S.of(context).imageNotAnalyzed;
+ case NoFacesReason.noFacesFound:
+ return S.of(context).noFacesFound;
+ }
+}
+
+class NoFaceChipButtonWidget extends StatelessWidget {
+ final NoFacesReason reason;
+
+ const NoFaceChipButtonWidget(
+ this.reason, {
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ return Padding(
+ padding: const EdgeInsets.only(top: 5),
+ child: ChipButtonWidget(
+ getNoFaceReasonText(context, reason),
+ noChips: true,
+ ),
+ );
+ }
+}