feat(mobile): configure detail viewer asset loading (#1044)

This commit is contained in:
Fynn Petersen-Frey 2022-12-02 21:55:10 +01:00 committed by GitHub
parent da87b1256c
commit 424b11cf50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 138 additions and 131 deletions

View file

@ -128,7 +128,7 @@ class _RemotePhotoViewState extends State<RemotePhotoView> {
}),
);
if (widget.threeStageLoading) {
if (widget.loadPreview) {
_previewProvider = _authorizedImageProvider(
getThumbnailUrl(widget.asset.remote!, type: ThumbnailFormat.JPEG),
"${widget.asset.id}_previewStage",
@ -140,15 +140,17 @@ class _RemotePhotoViewState extends State<RemotePhotoView> {
);
}
_fullProvider = _authorizedImageProvider(
getImageUrl(widget.asset.remote!),
"${widget.asset.id}_fullStage",
);
_fullProvider.resolve(const ImageConfiguration()).addListener(
ImageStreamListener((ImageInfo imageInfo, _) {
_performStateTransition(_RemoteImageStatus.full, _fullProvider);
}),
);
if (widget.loadOriginal) {
_fullProvider = _authorizedImageProvider(
getImageUrl(widget.asset.remote!),
"${widget.asset.id}_fullStage",
);
_fullProvider.resolve(const ImageConfiguration()).addListener(
ImageStreamListener((ImageInfo imageInfo, _) {
_performStateTransition(_RemoteImageStatus.full, _fullProvider);
}),
);
}
}
@override
@ -178,7 +180,8 @@ class RemotePhotoView extends StatefulWidget {
Key? key,
required this.asset,
required this.authToken,
required this.threeStageLoading,
required this.loadPreview,
required this.loadOriginal,
required this.isZoomedFunction,
required this.isZoomedListener,
required this.onSwipeDown,
@ -187,7 +190,8 @@ class RemotePhotoView extends StatefulWidget {
final Asset asset;
final String authToken;
final bool threeStageLoading;
final bool loadPreview;
final bool loadOriginal;
final void Function() onSwipeDown;
final void Function() onSwipeUp;
final void Function() isZoomedFunction;

View file

@ -31,8 +31,9 @@ class GalleryViewerPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final Box<dynamic> box = Hive.box(userInfoBox);
final appSettingService = ref.watch(appSettingsServiceProvider);
final threeStageLoading = useState(false);
final settings = ref.watch(appSettingsServiceProvider);
final isLoadPreview = useState(AppSettingsEnum.loadPreview.defaultValue);
final isLoadOriginal = useState(AppSettingsEnum.loadOriginal.defaultValue);
final isZoomed = useState<bool>(false);
final indexOfAsset = useState(assetList.indexOf(asset));
final isPlayingMotionVideo = useState(false);
@ -43,8 +44,10 @@ class GalleryViewerPage extends HookConsumerWidget {
useEffect(
() {
threeStageLoading.value = appSettingService
.getSetting<bool>(AppSettingsEnum.threeStageLoading);
isLoadPreview.value =
settings.getSetting<bool>(AppSettingsEnum.loadPreview);
isLoadOriginal.value =
settings.getSetting<bool>(AppSettingsEnum.loadOriginal);
isPlayingMotionVideo.value = false;
return null;
},
@ -140,7 +143,8 @@ class GalleryViewerPage extends HookConsumerWidget {
isZoomedListener: isZoomedListener,
asset: assetList[index],
heroTag: assetList[index].id,
threeStageLoading: threeStageLoading.value,
loadPreview: isLoadPreview.value,
loadOriginal: isLoadOriginal.value,
);
}
} else {

View file

@ -17,7 +17,8 @@ class ImageViewerPage extends HookConsumerWidget {
final String authToken;
final ValueNotifier<bool> isZoomedListener;
final void Function() isZoomedFunction;
final bool threeStageLoading;
final bool loadPreview;
final bool loadOriginal;
ImageViewerPage({
Key? key,
@ -26,7 +27,8 @@ class ImageViewerPage extends HookConsumerWidget {
required this.authToken,
required this.isZoomedFunction,
required this.isZoomedListener,
required this.threeStageLoading,
required this.loadPreview,
required this.loadOriginal,
}) : super(key: key);
Asset? assetDetail;
@ -74,7 +76,8 @@ class ImageViewerPage extends HookConsumerWidget {
child: RemotePhotoView(
asset: asset,
authToken: authToken,
threeStageLoading: threeStageLoading,
loadPreview: loadPreview,
loadOriginal: loadOriginal,
isZoomedFunction: isZoomedFunction,
isZoomedListener: isZoomedListener,
onSwipeDown: () => AutoRouter.of(context).pop(),