1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

feat(mobile): clear local storage option (#4635)

* feat(mobile): clear local storage option

* en json
This commit is contained in:
Alex 2023-10-25 09:53:16 -05:00 committed by GitHub
parent e47a11b8ba
commit aefd052888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 101 additions and 15 deletions

View File

@ -361,6 +361,8 @@
"version_announcement_overlay_text_3": " and ensure your docker-compose and .env setup is up-to-date to prevent any misconfigurations, especially if you use WatchTower or any mechanism that handles updating your server application automatically.",
"version_announcement_overlay_title": "New Server Version Available \uD83C\uDF89",
"viewer_remove_from_stack": "Remove from Stack",
"viewer_stack_use_as_main_asset": "Use as Main Asset",
"viewer_unstack": "Un-Stack"
}
"viewer_unstack": "Un-Stack",
"cache_settings_tile_title": "Local Storage",
"cache_settings_tile_subtitle": "Control the local storage behaviour",
"viewer_stack_use_as_main_asset": "Use as Main Asset"
}

View File

@ -0,0 +1,71 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart' show useEffect, useState;
import 'package:immich_mobile/modules/backup/models/duplicated_asset.model.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/providers/db.provider.dart';
class LocalStorageSettings extends HookConsumerWidget {
const LocalStorageSettings({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final isarDb = ref.watch(dbProvider);
final cacheItemCount = useState(0);
useEffect(
() {
cacheItemCount.value = isarDb.duplicatedAssets.countSync();
return null;
},
[],
);
void clearCache() {
isarDb.writeTxnSync(() => isarDb.duplicatedAssets.clearSync());
cacheItemCount.value = isarDb.duplicatedAssets.countSync();
}
return ExpansionTile(
textColor: Theme.of(context).primaryColor,
title: const Text(
"cache_settings_tile_title",
style: TextStyle(
fontWeight: FontWeight.bold,
),
).tr(),
subtitle: const Text(
"cache_settings_tile_subtitle",
style: TextStyle(
fontSize: 13,
),
).tr(),
children: [
ListTile(
title: Text(
"Duplicated Assets (${cacheItemCount.value})",
style: Theme.of(context)
.textTheme
.labelLarge
?.copyWith(fontWeight: FontWeight.bold),
).tr(),
subtitle: const Text(
"Photos and videos that are black listed by the app",
style: TextStyle(
fontSize: 13,
),
).tr(),
trailing: TextButton(
onPressed: cacheItemCount.value > 0 ? clearCache : null,
child: Text(
"CLEAR",
style: TextStyle(
fontSize: 12,
color: cacheItemCount.value > 0 ? Colors.red : Colors.grey,
fontWeight: FontWeight.bold,
),
).tr(),
),
),
],
);
}
}

View File

@ -82,23 +82,33 @@ class NotificationSetting extends HookConsumerWidget {
if (!hasPermission)
ListTile(
leading: const Icon(Icons.notifications_outlined),
title: const Text('notification_permission_list_tile_title').tr(),
title: Text(
'notification_permission_list_tile_title',
style: Theme.of(context)
.textTheme
.labelLarge
?.copyWith(fontWeight: FontWeight.bold),
).tr(),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('notification_permission_list_tile_content').tr(),
Text(
'notification_permission_list_tile_content',
style: Theme.of(context).textTheme.labelMedium,
).tr(),
const SizedBox(height: 8),
ElevatedButton(
onPressed: ()
=> ref.watch(notificationPermissionProvider.notifier)
.requestNotificationPermission().then((permission) {
if (permission == PermissionStatus.permanentlyDenied) {
showPermissionsDialog();
}
onPressed: () => ref
.watch(notificationPermissionProvider.notifier)
.requestNotificationPermission()
.then((permission) {
if (permission == PermissionStatus.permanentlyDenied) {
showPermissionsDialog();
}
}),
child:
const Text('notification_permission_list_tile_enable_button')
.tr(),
child: const Text(
'notification_permission_list_tile_enable_button',
).tr(),
),
],
),
@ -130,7 +140,8 @@ class NotificationSetting extends HookConsumerWidget {
).tr(args: [formattedValue]),
subtitle: Slider(
value: sliderValue.value,
onChanged: !hasPermission ? null : (double v) => sliderValue.value = v,
onChanged:
!hasPermission ? null : (double v) => sliderValue.value = v,
onChangeEnd: (double v) => appSettingService.setSetting(
AppSettingsEnum.uploadErrorNotificationGracePeriod,
v.toInt(),

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/settings/ui/advanced_settings/advanced_settings.dart';
import 'package:immich_mobile/modules/settings/ui/asset_list_settings/asset_list_settings.dart';
import 'package:immich_mobile/modules/settings/ui/local_storage_settings/local_storage_settings.dart';
import 'package:immich_mobile/modules/settings/ui/image_viewer_quality_setting/image_viewer_quality_setting.dart';
import 'package:immich_mobile/modules/settings/ui/notification_setting/notification_setting.dart';
import 'package:immich_mobile/modules/settings/ui/theme_setting/theme_setting.dart';
@ -42,6 +43,7 @@ class SettingsPage extends HookConsumerWidget {
const AssetListSettings(),
const NotificationSetting(),
// const ExperimentalSettings(),
const LocalStorageSettings(),
const AdvancedSettings(),
],
).toList(),