refactor: theme provider to generator
This commit is contained in:
parent
966b38b99f
commit
85841e3349
15 changed files with 107 additions and 90 deletions
|
@ -1,21 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:immich_mobile/shared/providers/immich_loading_overlay.provider.dart';
|
|
||||||
|
|
||||||
extension LoadingOverlay on WidgetRef {
|
|
||||||
ValueNotifier<bool> useProcessingOverlay() {
|
|
||||||
final result = useState(false);
|
|
||||||
final immichOverlayController =
|
|
||||||
read(immichLoadingOverlayController.notifier);
|
|
||||||
useValueChanged(
|
|
||||||
result.value,
|
|
||||||
(_, __) => result.value
|
|
||||||
? WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) => immichOverlayController.show())
|
|
||||||
: WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) => immichOverlayController.hide()),
|
|
||||||
);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
|
import 'package:immich_mobile/shared/providers/theme.provider.dart';
|
||||||
import 'package:timezone/data/latest.dart';
|
import 'package:timezone/data/latest.dart';
|
||||||
import 'package:immich_mobile/constants/locales.dart';
|
import 'package:immich_mobile/constants/locales.dart';
|
||||||
import 'package:immich_mobile/modules/backup/background_service/background.service.dart';
|
import 'package:immich_mobile/modules/backup/background_service/background.service.dart';
|
||||||
|
|
|
@ -51,7 +51,7 @@ class ActivitiesPage extends HookConsumerWidget {
|
||||||
|
|
||||||
buildTitleWithTimestamp(Activity activity, {bool leftAlign = true}) {
|
buildTitleWithTimestamp(Activity activity, {bool leftAlign = true}) {
|
||||||
final textStyle = context.textTheme.bodyMedium?.copyWith(
|
final textStyle = context.textTheme.bodyMedium?.copyWith(
|
||||||
color: context.textTheme.bodyMedium?.color?.withOpacity(0.6));
|
color: context.textTheme.bodyMedium?.color?.withOpacity(0.6),);
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: leftAlign
|
mainAxisAlignment: leftAlign
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/widgetref_extensions.dart';
|
|
||||||
import 'package:immich_mobile/modules/activities/providers/activity.provider.dart';
|
import 'package:immich_mobile/modules/activities/providers/activity.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/providers/album_detail.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/album_detail.provider.dart';
|
||||||
|
@ -15,6 +14,7 @@ import 'package:immich_mobile/routing/router.dart';
|
||||||
import 'package:immich_mobile/shared/models/album.dart';
|
import 'package:immich_mobile/shared/models/album.dart';
|
||||||
import 'package:immich_mobile/shared/models/asset.dart';
|
import 'package:immich_mobile/shared/models/asset.dart';
|
||||||
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
||||||
|
import 'package:immich_mobile/shared/views/immich_loading_overlay.dart';
|
||||||
|
|
||||||
class AlbumViewerAppbar extends HookConsumerWidget
|
class AlbumViewerAppbar extends HookConsumerWidget
|
||||||
implements PreferredSizeWidget {
|
implements PreferredSizeWidget {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/color_extensions.dart';
|
import 'package:immich_mobile/extensions/color_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/widgetref_extensions.dart';
|
|
||||||
import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart';
|
||||||
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
|
@ -13,6 +12,7 @@ import 'package:immich_mobile/shared/models/album.dart';
|
||||||
import 'package:immich_mobile/shared/models/user.dart';
|
import 'package:immich_mobile/shared/models/user.dart';
|
||||||
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
||||||
import 'package:immich_mobile/shared/ui/user_circle_avatar.dart';
|
import 'package:immich_mobile/shared/ui/user_circle_avatar.dart';
|
||||||
|
import 'package:immich_mobile/shared/views/immich_loading_overlay.dart';
|
||||||
|
|
||||||
class AlbumOptionsPage extends HookConsumerWidget {
|
class AlbumOptionsPage extends HookConsumerWidget {
|
||||||
final Album album;
|
final Album album;
|
||||||
|
@ -27,7 +27,6 @@ class AlbumOptionsPage extends HookConsumerWidget {
|
||||||
final activityEnabled = useState(album.activityEnabled);
|
final activityEnabled = useState(album.activityEnabled);
|
||||||
final isProcessing = useProcessingOverlay();
|
final isProcessing = useProcessingOverlay();
|
||||||
final isOwner = owner?.id == userId;
|
final isOwner = owner?.id == userId;
|
||||||
final immichOverlayController = ref.useProcessingOverlay();
|
|
||||||
|
|
||||||
void showErrorMessage() {
|
void showErrorMessage() {
|
||||||
context.pop();
|
context.pop();
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/widgetref_extensions.dart';
|
|
||||||
import 'package:immich_mobile/modules/album/models/asset_selection_page_result.model.dart';
|
import 'package:immich_mobile/modules/album/models/asset_selection_page_result.model.dart';
|
||||||
import 'package:immich_mobile/modules/album/providers/album_detail.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/album_detail.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
||||||
|
@ -20,6 +19,7 @@ import 'package:immich_mobile/shared/models/album.dart';
|
||||||
import 'package:immich_mobile/shared/models/asset.dart';
|
import 'package:immich_mobile/shared/models/asset.dart';
|
||||||
import 'package:immich_mobile/shared/providers/asset.provider.dart';
|
import 'package:immich_mobile/shared/providers/asset.provider.dart';
|
||||||
import 'package:immich_mobile/shared/ui/user_circle_avatar.dart';
|
import 'package:immich_mobile/shared/ui/user_circle_avatar.dart';
|
||||||
|
import 'package:immich_mobile/shared/views/immich_loading_overlay.dart';
|
||||||
|
|
||||||
class AlbumViewerPage extends HookConsumerWidget {
|
class AlbumViewerPage extends HookConsumerWidget {
|
||||||
final int albumId;
|
final int albumId;
|
||||||
|
|
|
@ -135,47 +135,45 @@ class LibraryPage extends HookConsumerWidget {
|
||||||
Widget buildCreateAlbumButton() {
|
Widget buildCreateAlbumButton() {
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
var cardSize = constraints.maxWidth;
|
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () =>
|
||||||
(context).autoPush(CreateAlbumRoute(isSharedAlbum: false));
|
context.autoPush(CreateAlbumRoute(isSharedAlbum: false)),
|
||||||
},
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.only(bottom: 32),
|
||||||
padding: const EdgeInsets.only(bottom: 32),
|
child: Column(
|
||||||
child: Column(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: Container(
|
||||||
child: Container(
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: context.themeData.cardColor,
|
||||||
color: context.themeData.cardColor,
|
borderRadius:
|
||||||
borderRadius:
|
const BorderRadius.all(Radius.circular(20)),
|
||||||
const BorderRadius.all(Radius.circular(20)),
|
),
|
||||||
),
|
child: Center(
|
||||||
child: Center(
|
child: Icon(
|
||||||
child: Icon(
|
Icons.add_rounded,
|
||||||
Icons.add_rounded,
|
size: 28,
|
||||||
size: 28,
|
color: context.primaryColor,
|
||||||
color: context.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.only(
|
Padding(
|
||||||
top: 8.0,
|
padding: const EdgeInsets.only(
|
||||||
bottom: 16,
|
top: 8.0,
|
||||||
),
|
bottom: 16,
|
||||||
child: Text(
|
|
||||||
'library_page_new_album',
|
|
||||||
style: context.textTheme.labelLarge,
|
|
||||||
).tr(),
|
|
||||||
),
|
),
|
||||||
],
|
child: Text(
|
||||||
),
|
'library_page_new_album',
|
||||||
));
|
style: context.textTheme.labelLarge,
|
||||||
|
).tr(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/widgetref_extensions.dart';
|
|
||||||
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/providers/album_detail.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/album_detail.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart';
|
import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart';
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.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/services/app_settings.service.dart';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.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/services/app_settings.service.dart';
|
||||||
import 'package:immich_mobile/utils/immich_app_theme.dart';
|
import 'package:immich_mobile/shared/providers/theme.provider.dart';
|
||||||
|
|
||||||
class ThemeSetting extends HookConsumerWidget {
|
class ThemeSetting extends HookConsumerWidget {
|
||||||
const ThemeSetting({
|
const ThemeSetting({
|
||||||
|
@ -47,20 +47,26 @@ class ThemeSetting extends HookConsumerWidget {
|
||||||
|
|
||||||
if (isSystem) {
|
if (isSystem) {
|
||||||
currentTheme.value = ThemeMode.system;
|
currentTheme.value = ThemeMode.system;
|
||||||
ref.watch(immichThemeProvider.notifier).state = ThemeMode.system;
|
ref
|
||||||
|
.watch(immichThemeProvider.notifier)
|
||||||
|
.updateTheme(ThemeMode.system);
|
||||||
ref
|
ref
|
||||||
.watch(appSettingsServiceProvider)
|
.watch(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.themeMode, "system");
|
.setSetting(AppSettingsEnum.themeMode, "system");
|
||||||
} else {
|
} else {
|
||||||
if (currentSystemBrightness == Brightness.light) {
|
if (currentSystemBrightness == Brightness.light) {
|
||||||
currentTheme.value = ThemeMode.light;
|
currentTheme.value = ThemeMode.light;
|
||||||
ref.watch(immichThemeProvider.notifier).state = ThemeMode.light;
|
ref
|
||||||
|
.watch(immichThemeProvider.notifier)
|
||||||
|
.updateTheme(ThemeMode.light);
|
||||||
ref
|
ref
|
||||||
.watch(appSettingsServiceProvider)
|
.watch(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.themeMode, "light");
|
.setSetting(AppSettingsEnum.themeMode, "light");
|
||||||
} else if (currentSystemBrightness == Brightness.dark) {
|
} else if (currentSystemBrightness == Brightness.dark) {
|
||||||
currentTheme.value = ThemeMode.dark;
|
currentTheme.value = ThemeMode.dark;
|
||||||
ref.watch(immichThemeProvider.notifier).state = ThemeMode.dark;
|
ref
|
||||||
|
.watch(immichThemeProvider.notifier)
|
||||||
|
.updateTheme(ThemeMode.dark);
|
||||||
ref
|
ref
|
||||||
.watch(appSettingsServiceProvider)
|
.watch(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.themeMode, "dark");
|
.setSetting(AppSettingsEnum.themeMode, "dark");
|
||||||
|
@ -78,12 +84,16 @@ class ThemeSetting extends HookConsumerWidget {
|
||||||
value: ref.watch(immichThemeProvider) == ThemeMode.dark,
|
value: ref.watch(immichThemeProvider) == ThemeMode.dark,
|
||||||
onChanged: (bool isDark) {
|
onChanged: (bool isDark) {
|
||||||
if (isDark) {
|
if (isDark) {
|
||||||
ref.watch(immichThemeProvider.notifier).state = ThemeMode.dark;
|
ref
|
||||||
|
.watch(immichThemeProvider.notifier)
|
||||||
|
.updateTheme(ThemeMode.dark);
|
||||||
ref
|
ref
|
||||||
.watch(appSettingsServiceProvider)
|
.watch(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.themeMode, "dark");
|
.setSetting(AppSettingsEnum.themeMode, "dark");
|
||||||
} else {
|
} else {
|
||||||
ref.watch(immichThemeProvider.notifier).state = ThemeMode.light;
|
ref
|
||||||
|
.watch(immichThemeProvider.notifier)
|
||||||
|
.updateTheme(ThemeMode.light);
|
||||||
ref
|
ref
|
||||||
.watch(appSettingsServiceProvider)
|
.watch(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.themeMode, "light");
|
.setSetting(AppSettingsEnum.themeMode, "light");
|
||||||
|
|
|
@ -5,7 +5,6 @@ import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/widgetref_extensions.dart';
|
|
||||||
import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart';
|
import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart';
|
||||||
import 'package:immich_mobile/modules/home/ui/delete_dialog.dart';
|
import 'package:immich_mobile/modules/home/ui/delete_dialog.dart';
|
||||||
import 'package:immich_mobile/modules/trash/providers/trashed_asset.provider.dart';
|
import 'package:immich_mobile/modules/trash/providers/trashed_asset.provider.dart';
|
||||||
|
|
27
mobile/lib/shared/providers/theme.provider.dart
Normal file
27
mobile/lib/shared/providers/theme.provider.dart
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import 'package:flutter/material.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:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
part 'theme.provider.g.dart';
|
||||||
|
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
class ImmichTheme extends _$ImmichTheme {
|
||||||
|
@override
|
||||||
|
ThemeMode build() {
|
||||||
|
final themeMode = ref
|
||||||
|
.watch(appSettingsServiceProvider)
|
||||||
|
.getSetting(AppSettingsEnum.themeMode);
|
||||||
|
|
||||||
|
switch (themeMode) {
|
||||||
|
case "light":
|
||||||
|
return ThemeMode.light;
|
||||||
|
case "dark":
|
||||||
|
return ThemeMode.dark;
|
||||||
|
default:
|
||||||
|
return ThemeMode.system;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTheme(ThemeMode newMode) => state = newMode;
|
||||||
|
}
|
24
mobile/lib/shared/providers/theme.provider.g.dart
generated
Normal file
24
mobile/lib/shared/providers/theme.provider.g.dart
generated
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'theme.provider.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$immichThemeHash() => r'22952207d5d5e6289a8244589e703c816501d6e3';
|
||||||
|
|
||||||
|
/// See also [ImmichTheme].
|
||||||
|
@ProviderFor(ImmichTheme)
|
||||||
|
final immichThemeProvider = NotifierProvider<ImmichTheme, ThemeMode>.internal(
|
||||||
|
ImmichTheme.new,
|
||||||
|
name: r'immichThemeProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product') ? null : _$immichThemeHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef _$ImmichTheme = Notifier<ThemeMode>;
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/color_extensions.dart';
|
|
||||||
|
|
||||||
enum ToastType { info, success, error }
|
enum ToastType { info, success, error }
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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';
|
|
||||||
|
|
||||||
final immichThemeProvider = StateProvider<ThemeMode>((ref) {
|
|
||||||
var themeMode = ref
|
|
||||||
.watch(appSettingsServiceProvider)
|
|
||||||
.getSetting(AppSettingsEnum.themeMode);
|
|
||||||
|
|
||||||
debugPrint("Current themeMode $themeMode");
|
|
||||||
|
|
||||||
if (themeMode == "light") {
|
|
||||||
return ThemeMode.light;
|
|
||||||
} else if (themeMode == "dark") {
|
|
||||||
return ThemeMode.dark;
|
|
||||||
} else {
|
|
||||||
return ThemeMode.system;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ColorScheme _lightColorScheme = const ColorScheme(
|
ColorScheme _lightColorScheme = const ColorScheme(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
|
|
Loading…
Reference in a new issue