mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(mobile): configure detail viewer asset loading (#1044)
This commit is contained in:
parent
da87b1256c
commit
424b11cf50
12 changed files with 138 additions and 131 deletions
|
|
@ -1,14 +1,30 @@
|
|||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/modules/settings/ui/image_viewer_quality_setting/three_stage_loading.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
||||
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
||||
import 'package:immich_mobile/modules/settings/ui/common.dart';
|
||||
|
||||
class ImageViewerQualitySetting extends StatelessWidget {
|
||||
class ImageViewerQualitySetting extends HookConsumerWidget {
|
||||
const ImageViewerQualitySetting({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final settings = ref.watch(appSettingsServiceProvider);
|
||||
final isPreview = useState(AppSettingsEnum.loadPreview.defaultValue);
|
||||
final isOriginal = useState(AppSettingsEnum.loadOriginal.defaultValue);
|
||||
|
||||
useEffect(
|
||||
() {
|
||||
isPreview.value = settings.getSetting(AppSettingsEnum.loadPreview);
|
||||
isOriginal.value = settings.getSetting(AppSettingsEnum.loadOriginal);
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
||||
return ExpansionTile(
|
||||
textColor: Theme.of(context).primaryColor,
|
||||
title: const Text(
|
||||
|
|
@ -23,8 +39,27 @@ class ImageViewerQualitySetting extends StatelessWidget {
|
|||
fontSize: 13,
|
||||
),
|
||||
).tr(),
|
||||
children: const [
|
||||
ThreeStageLoading(),
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text('setting_image_viewer_help').tr(),
|
||||
dense: true,
|
||||
),
|
||||
buildSwitchListTile(
|
||||
context,
|
||||
settings,
|
||||
isPreview,
|
||||
AppSettingsEnum.loadPreview,
|
||||
title: "setting_image_viewer_preview_title".tr(),
|
||||
subtitle: "setting_image_viewer_preview_subtitle".tr(),
|
||||
),
|
||||
buildSwitchListTile(
|
||||
context,
|
||||
settings,
|
||||
isOriginal,
|
||||
AppSettingsEnum.loadOriginal,
|
||||
title: "setting_image_viewer_original_title".tr(),
|
||||
subtitle: "setting_image_viewer_original_subtitle".tr(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
||||
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
||||
|
||||
class ThreeStageLoading extends HookConsumerWidget {
|
||||
const ThreeStageLoading({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final appSettingService = ref.watch(appSettingsServiceProvider);
|
||||
|
||||
final isEnable = useState(false);
|
||||
|
||||
useEffect(
|
||||
() {
|
||||
var isThreeStageLoadingEnable =
|
||||
appSettingService.getSetting(AppSettingsEnum.threeStageLoading);
|
||||
|
||||
isEnable.value = isThreeStageLoadingEnable;
|
||||
return null;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
void onSwitchChanged(bool switchValue) {
|
||||
appSettingService.setSetting(
|
||||
AppSettingsEnum.threeStageLoading,
|
||||
switchValue,
|
||||
);
|
||||
isEnable.value = switchValue;
|
||||
}
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
title: const Text(
|
||||
"theme_setting_three_stage_loading_title",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
).tr(),
|
||||
subtitle: const Text(
|
||||
"theme_setting_three_stage_loading_subtitle",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
).tr(),
|
||||
value: isEnable.value,
|
||||
onChanged: onSwitchChanged,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue