mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
refactor aspect ratio calculation
This commit is contained in:
parent
bef9a1eae7
commit
de61abb3aa
1 changed files with 18 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
@ -16,7 +17,6 @@ import 'package:immich_mobile/utils/hooks/interval_hook.dart';
|
||||||
import 'package:immich_mobile/widgets/asset_viewer/custom_video_player_controls.dart';
|
import 'package:immich_mobile/widgets/asset_viewer/custom_video_player_controls.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:native_video_player/native_video_player.dart';
|
import 'package:native_video_player/native_video_player.dart';
|
||||||
import 'package:photo_manager/photo_manager.dart';
|
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||||
|
|
||||||
class NativeVideoViewerPage extends HookConsumerWidget {
|
class NativeVideoViewerPage extends HookConsumerWidget {
|
||||||
|
@ -53,7 +53,12 @@ class NativeVideoViewerPage extends HookConsumerWidget {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AssetEntity.fromId(asset.localId!);
|
final local = asset.local;
|
||||||
|
if (local == null || local.orientation > 0) {
|
||||||
|
return Future.value(local);
|
||||||
|
}
|
||||||
|
|
||||||
|
return local.obtainForNewProperties();
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<double?> calculateAspectRatio() async {
|
Future<double?> calculateAspectRatio() async {
|
||||||
|
@ -67,11 +72,18 @@ class NativeVideoViewerPage extends HookConsumerWidget {
|
||||||
if (asset.exifInfo != null) {
|
if (asset.exifInfo != null) {
|
||||||
orientatedWidth = asset.orientatedWidth?.toDouble();
|
orientatedWidth = asset.orientatedWidth?.toDouble();
|
||||||
orientatedHeight = asset.orientatedHeight?.toDouble();
|
orientatedHeight = asset.orientatedHeight?.toDouble();
|
||||||
} else if (localEntity != null) {
|
}
|
||||||
|
|
||||||
|
if (orientatedWidth == null && localEntity != null) {
|
||||||
final entity = await localEntity;
|
final entity = await localEntity;
|
||||||
orientatedWidth = entity?.orientatedWidth.toDouble();
|
if (entity != null) {
|
||||||
orientatedHeight = entity?.orientatedHeight.toDouble();
|
asset.local = entity;
|
||||||
} else {
|
orientatedWidth = entity.orientatedWidth.toDouble();
|
||||||
|
orientatedHeight = entity.orientatedHeight.toDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orientatedWidth == null) {
|
||||||
final entity = await ref.read(assetServiceProvider).loadExif(asset);
|
final entity = await ref.read(assetServiceProvider).loadExif(asset);
|
||||||
orientatedWidth = entity.orientatedWidth?.toDouble();
|
orientatedWidth = entity.orientatedWidth?.toDouble();
|
||||||
orientatedHeight = entity.orientatedHeight?.toDouble();
|
orientatedHeight = entity.orientatedHeight?.toDouble();
|
||||||
|
|
Loading…
Reference in a new issue