diff --git a/mobile/lib/infrastructure/utils/exif.converter.dart b/mobile/lib/infrastructure/utils/exif.converter.dart index d47c9cc97..1dda910de 100644 --- a/mobile/lib/infrastructure/utils/exif.converter.dart +++ b/mobile/lib/infrastructure/utils/exif.converter.dart @@ -11,16 +11,16 @@ abstract final class ExifDtoConverter { timeZone: dto.timeZone.orElse(null), dateTimeOriginal: dto.dateTimeOriginal.orElse(null), isFlipped: isOrientationFlipped(dto.orientation.orElse(null)), - latitude: dto.latitude.orElse(null)?.toDouble(), - longitude: dto.longitude.orElse(null)?.toDouble(), + latitude: dto.latitude.orElse(null), + longitude: dto.longitude.orElse(null), city: dto.city.orElse(null), state: dto.state.orElse(null), country: dto.country.orElse(null), make: dto.make.orElse(null), model: dto.model.orElse(null), lens: dto.lensModel.orElse(null), - f: dto.fNumber.orElse(null)?.toDouble(), - mm: dto.focalLength.orElse(null)?.toDouble(), + f: dto.fNumber.orElse(null), + mm: dto.focalLength.orElse(null), iso: dto.iso.orElse(null), exposureSeconds: exposureTimeToSeconds(dto.exposureTime.orElse(null)), ); diff --git a/mobile/lib/presentation/pages/edit/editor.provider.dart b/mobile/lib/presentation/pages/edit/editor.provider.dart index 8f3c22f3d..adb2f3412 100644 --- a/mobile/lib/presentation/pages/edit/editor.provider.dart +++ b/mobile/lib/presentation/pages/edit/editor.provider.dart @@ -43,7 +43,7 @@ class EditorProvider extends Notifier { flipVertical: transform.mirrorVertical, ); - _animateRotation(transform.rotation.toInt(), duration: Duration.zero); + _animateRotation(transform.rotation, duration: Duration.zero); } void _animateRotation(int angle, {Duration duration = const Duration(milliseconds: 300)}) { diff --git a/mobile/lib/utils/editor.utils.dart b/mobile/lib/utils/editor.utils.dart index c3440cce1..fc5cbf79a 100644 --- a/mobile/lib/utils/editor.utils.dart +++ b/mobile/lib/utils/editor.utils.dart @@ -45,7 +45,7 @@ bool isCloseToZero(double value, [double epsilon = 1e-15]) { return value.abs() < epsilon; } -typedef NormalizedTransform = ({double rotation, bool mirrorHorizontal, bool mirrorVertical}); +typedef NormalizedTransform = ({int rotation, bool mirrorHorizontal, bool mirrorVertical}); NormalizedTransform normalizeTransformEdits(List edits) { final matrix = buildAffineFromEdits(edits); @@ -55,11 +55,10 @@ NormalizedTransform normalizeTransformEdits(List edits) { final double c = matrix.c; final double d = matrix.d; - final rotation = ((isCloseToZero(a) ? asin(c) : acos(a)) * 180) / pi; + final degrees = ((isCloseToZero(a) ? asin(c) : acos(a)) * 180) / pi; - return ( - rotation: rotation < 0 ? 360 + rotation : rotation, - mirrorHorizontal: false, - mirrorVertical: isCloseToZero(a) ? b == c : a == -d, - ); + // We only allow 90 degree increments + final quarterTurns = (degrees / 90).round() % 4; + + return (rotation: quarterTurns * 90, mirrorHorizontal: false, mirrorVertical: isCloseToZero(a) ? b == c : a == -d); }