mirror of
https://github.com/immich-app/immich.git
synced 2024-12-20 00:38:24 +02:00
b05132a01a
* refactor: server info model to use data classes instead of dtos * mobile: add return types and refactor private variables in map / stack --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
60 lines
2.0 KiB
Dart
60 lines
2.0 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/modules/map/models/map_state.model.dart';
|
|
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
|
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
|
|
|
class MapStateNotifier extends StateNotifier<MapState> {
|
|
MapStateNotifier(this._appSettingsProvider)
|
|
: super(
|
|
MapState(
|
|
isDarkTheme: _appSettingsProvider
|
|
.getSetting<bool>(AppSettingsEnum.mapThemeMode),
|
|
showFavoriteOnly: _appSettingsProvider
|
|
.getSetting<bool>(AppSettingsEnum.mapShowFavoriteOnly),
|
|
includeArchived: _appSettingsProvider
|
|
.getSetting<bool>(AppSettingsEnum.mapIncludeArchived),
|
|
relativeTime: _appSettingsProvider
|
|
.getSetting<int>(AppSettingsEnum.mapRelativeDate),
|
|
),
|
|
);
|
|
|
|
final AppSettingsService _appSettingsProvider;
|
|
|
|
void switchTheme(bool isDarkTheme) {
|
|
_appSettingsProvider.setSetting(
|
|
AppSettingsEnum.mapThemeMode,
|
|
isDarkTheme,
|
|
);
|
|
state = state.copyWith(isDarkTheme: isDarkTheme);
|
|
}
|
|
|
|
void switchFavoriteOnly(bool isFavoriteOnly) {
|
|
_appSettingsProvider.setSetting(
|
|
AppSettingsEnum.mapShowFavoriteOnly,
|
|
isFavoriteOnly,
|
|
);
|
|
state = state.copyWith(showFavoriteOnly: isFavoriteOnly);
|
|
}
|
|
|
|
void switchIncludeArchived(bool isIncludeArchived) {
|
|
_appSettingsProvider.setSetting(
|
|
AppSettingsEnum.mapIncludeArchived,
|
|
isIncludeArchived,
|
|
);
|
|
state = state.copyWith(includeArchived: isIncludeArchived);
|
|
}
|
|
|
|
void setRelativeTime(int relativeTime) {
|
|
_appSettingsProvider.setSetting(
|
|
AppSettingsEnum.mapRelativeDate,
|
|
relativeTime,
|
|
);
|
|
state = state.copyWith(relativeTime: relativeTime);
|
|
}
|
|
}
|
|
|
|
final mapStateNotifier =
|
|
StateNotifierProvider<MapStateNotifier, MapState>((ref) {
|
|
return MapStateNotifier(ref.watch(appSettingsServiceProvider));
|
|
});
|