more refactors
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/domain/models/app_setting.model.dart';
|
||||
import 'package:immich_mobile/domain/services/app_setting.service.dart';
|
||||
import 'package:immich_mobile/presentation/theme/app_theme.dart';
|
||||
|
||||
class AppThemeProvider extends ValueNotifier<AppTheme> {
|
||||
final AppSettingService _appSettings;
|
||||
late final StreamSubscription _appSettingSubscription;
|
||||
|
||||
AppThemeProvider({required AppSettingService settingsService})
|
||||
: _appSettings = settingsService,
|
||||
super(AppTheme.blue) {
|
||||
_appSettingSubscription = _appSettings
|
||||
.watch(AppSetting.appTheme)
|
||||
.listen((theme) => value = theme);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_appSettingSubscription.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,26 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/api/server_api.interface.dart';
|
||||
import 'package:immich_mobile/domain/models/server-info/server_feature_config.model.dart';
|
||||
import 'package:immich_mobile/domain/services/server_info.service.dart';
|
||||
|
||||
class ServerFeatureConfigProvider extends ValueNotifier<ServerFeatureConfig> {
|
||||
final ServerInfoService _serverInfoService;
|
||||
final IServerApiRepository _serverApiRepository;
|
||||
|
||||
ServerFeatureConfigProvider(this._serverInfoService)
|
||||
: super(const ServerFeatureConfig.reset());
|
||||
ServerFeatureConfigProvider({required IServerApiRepository serverApiRepo})
|
||||
: _serverApiRepository = serverApiRepo,
|
||||
super(const ServerFeatureConfig.initial());
|
||||
|
||||
Future<void> getFeatures() async =>
|
||||
await Future.wait([_getFeatures(), _getConfig()]);
|
||||
|
||||
Future<void> _getFeatures() async {
|
||||
final features = await _serverInfoService.getServerFeatures();
|
||||
final features = await _serverApiRepository.getServerFeatures();
|
||||
if (features != null) {
|
||||
value = value.copyWith(features: features);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getConfig() async {
|
||||
final config = await _serverInfoService.getServerConfig();
|
||||
final config = await _serverApiRepository.getServerConfig();
|
||||
if (config != null) {
|
||||
value = value.copyWith(config: config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user