fix(mobile): correct local asset dimensions

We are constraining the size of videos so that they play nicely with
hero animations, and don't stretch in weird ways. This however caused a
regression as we are not account for local assets on Android which have
un-oriented dimensions.
This commit is contained in:
Thomas Way
2026-03-04 01:23:37 +00:00
parent 56f14162f6
commit a42a7049d2

View File

@@ -6,6 +6,7 @@ import 'package:flutter/gestures.dart' show Drag, kTouchSlop;
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
import 'package:immich_mobile/extensions/platform_extensions.dart';
import 'package:immich_mobile/domain/models/events.model.dart';
import 'package:immich_mobile/domain/utils/event_stream.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart';
@@ -274,13 +275,25 @@ class _AssetPageState extends ConsumerState<AssetPage> {
});
}
static bool _isFlipped(BaseAsset asset) =>
asset is LocalAsset && CurrentPlatform.isAndroid && (asset.orientation == 90 || asset.orientation == 270);
static Size? _assetSize(BaseAsset asset) {
if (asset.width == null || asset.height == null) return null;
final w = asset.width!.toDouble();
final h = asset.height!.toDouble();
return _isFlipped(asset) ? Size(h, w) : Size(w, h);
}
double _getImageHeight(double maxWidth, double maxHeight, BaseAsset? asset) {
final sb = _viewController?.scaleBoundaries;
if (sb != null) return sb.childSize.height * sb.initialScale;
if (asset == null || asset.width == null || asset.height == null) return maxHeight;
final size = asset != null ? _assetSize(asset) : null;
if (size == null) return maxHeight;
final r = asset.width! / asset.height!;
final r = size.width / size.height;
return math.min(maxWidth / r, maxHeight);
}
@@ -329,9 +342,7 @@ class _AssetPageState extends ConsumerState<AssetPage> {
return PhotoView.customChild(
key: Key(asset.heroTag),
childSize: asset.width != null && asset.height != null
? Size(asset.width!.toDouble(), asset.height!.toDouble())
: null,
childSize: _assetSize(asset),
onDragStart: _onDragStart,
onDragUpdate: _onDragUpdate,
onDragEnd: _onDragEnd,