π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Refactor
ashilkn731610ed94ed
diff --git a/mobile/lib/ui/viewer/file_details/face_widget.dart b/mobile/lib/ui/viewer/file_details/face_widget.dartindex 3f09ffd986..4357cec76c 100644--- a/mobile/lib/ui/viewer/file_details/face_widget.dart+++ b/mobile/lib/ui/viewer/file_details/face_widget.dart@@ -264,12 +264,9 @@ class _FaceWidgetState extends State<FaceWidget> {},child: Column(children: [- SizedBox(- height: 60,- child: CroppedFaceImageView(- enteFile: widget.file,- face: widget.face,- ),+ CroppedFaceImageView(+ enteFile: widget.file,+ face: widget.face,),const SizedBox(height: 8),if (widget.person != null)diff --git a/mobile/lib/ui/viewer/people/cropped_face_image_view.dart b/mobile/lib/ui/viewer/people/cropped_face_image_view.dartindex 3a9053d317..9f1717707c 100644--- a/mobile/lib/ui/viewer/people/cropped_face_image_view.dart+++ b/mobile/lib/ui/viewer/people/cropped_face_image_view.dart@@ -33,48 +33,48 @@ class CroppedFaceImageView extends StatelessWidget {@overrideWidget build(BuildContext context) {- return FutureBuilder(- future: getImage(),- builder: (context, snapshot) {- if (snapshot.hasData) {- final double imageAspectRatio = enteFile.width / enteFile.height;- final Image image = snapshot.data!;-- const double viewWidth = 60;- const double viewHeight = 60;-- final faceBox = face.detection.box;-- final double relativeFaceCenterX = faceBox.xMin + faceBox.width / 2;- final double relativeFaceCenterY = faceBox.yMin + faceBox.height / 2;-- const double desiredFaceHeightRelativeToWidget = 8 / 10;- final double scale =- (1 / faceBox.height) * desiredFaceHeightRelativeToWidget;-- const double widgetCenterX = viewWidth / 2;- const double widgetCenterY = viewHeight / 2;-- const double widgetAspectRatio = viewWidth / viewHeight;- final double imageToWidgetRatio =- imageAspectRatio / widgetAspectRatio;-- double offsetX =- (widgetCenterX - relativeFaceCenterX * viewWidth) * scale;- double offsetY =- (widgetCenterY - relativeFaceCenterY * viewHeight) * scale;-- if (imageAspectRatio < widgetAspectRatio) {- // Landscape Image: Adjust offsetX more conservatively- offsetX = offsetX * imageToWidgetRatio;- } else {- // Portrait Image: Adjust offsetY more conservatively- offsetY = offsetY / imageToWidgetRatio;- }- return SizedBox(- width: viewWidth,- height: viewHeight,- child: ClipRRect(+ const double viewWidth = 60;+ const double viewHeight = 60;+ return SizedBox(+ width: viewWidth,+ height: viewHeight,+ child: FutureBuilder(+ future: getImage(),+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ final double imageAspectRatio = enteFile.width / enteFile.height;+ final Image image = snapshot.data!;++ final faceBox = face.detection.box;++ final double relativeFaceCenterX = faceBox.xMin + faceBox.width / 2;+ final double relativeFaceCenterY =+ faceBox.yMin + faceBox.height / 2;++ const double desiredFaceHeightRelativeToWidget = 8 / 10;+ final double scale =+ (1 / faceBox.height) * desiredFaceHeightRelativeToWidget;++ const double widgetCenterX = viewWidth / 2;+ const double widgetCenterY = viewHeight / 2;++ const double widgetAspectRatio = viewWidth / viewHeight;+ final double imageToWidgetRatio =+ imageAspectRatio / widgetAspectRatio;++ double offsetX =+ (widgetCenterX - relativeFaceCenterX * viewWidth) * scale;+ double offsetY =+ (widgetCenterY - relativeFaceCenterY * viewHeight) * scale;++ if (imageAspectRatio < widgetAspectRatio) {+ // Landscape Image: Adjust offsetX more conservatively+ offsetX = offsetX * imageToWidgetRatio;+ } else {+ // Portrait Image: Adjust offsetY more conservatively+ offsetY = offsetY / imageToWidgetRatio;+ }+ return ClipRRect(borderRadius: const BorderRadius.all(Radius.elliptical(16, 12)),child: Transform.translate(offset: Offset(@@ -86,17 +86,17 @@ class CroppedFaceImageView extends StatelessWidget {child: image,),),- ),- );- } else {- if (snapshot.hasError) {- log('Error getting cover face for person: ${snapshot.error}');+ );+ } else {+ if (snapshot.hasError) {+ log('Error getting cover face for person: ${snapshot.error}');+ }+ return ThumbnailWidget(+ enteFile,+ );}- return ThumbnailWidget(- enteFile,- );- }- },+ },+ ),);}