kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add color blindness setting to the RP Settings providers
rodzic
b11e3b9ca9
commit
235b2fb3b8
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:color_blindness/color_blindness.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
|
@ -198,3 +199,35 @@ class FriendicaApiTimeoutSetting extends _$FriendicaApiTimeoutSetting {
|
|||
state = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class ColorBlindnessTestingModeSetting
|
||||
extends _$ColorBlindnessTestingModeSetting {
|
||||
static const _colorBlindnessTestingModeKey = 'ColorBlindnessTestingMode';
|
||||
|
||||
@override
|
||||
ColorBlindnessType build() {
|
||||
ref.watch(sharedPreferencesProvider);
|
||||
return _colorBlindnessTypeFromPrefs();
|
||||
}
|
||||
|
||||
set value(ColorBlindnessType value) {
|
||||
ref
|
||||
.read(sharedPreferencesProvider)
|
||||
.setString(_colorBlindnessTestingModeKey, value.name);
|
||||
state = value;
|
||||
}
|
||||
|
||||
ColorBlindnessType _colorBlindnessTypeFromPrefs() {
|
||||
final cbString = ref
|
||||
.read(sharedPreferencesProvider)
|
||||
.getString(_colorBlindnessTestingModeKey);
|
||||
if (cbString?.isEmpty ?? true) {
|
||||
return ColorBlindnessType.none;
|
||||
}
|
||||
return ColorBlindnessType.values.firstWhere(
|
||||
(c) => c.name == cbString,
|
||||
orElse: () => ColorBlindnessType.none,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,5 +139,22 @@ final friendicaApiTimeoutSettingProvider =
|
|||
);
|
||||
|
||||
typedef _$FriendicaApiTimeoutSetting = Notifier<Duration>;
|
||||
String _$colorBlindnessTestingModeSettingHash() =>
|
||||
r'8e1d45036fdf1ce7408dcded71c591ee3d7a1e26';
|
||||
|
||||
/// See also [ColorBlindnessTestingModeSetting].
|
||||
@ProviderFor(ColorBlindnessTestingModeSetting)
|
||||
final colorBlindnessTestingModeSettingProvider = NotifierProvider<
|
||||
ColorBlindnessTestingModeSetting, ColorBlindnessType>.internal(
|
||||
ColorBlindnessTestingModeSetting.new,
|
||||
name: r'colorBlindnessTestingModeSettingProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$colorBlindnessTestingModeSettingHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$ColorBlindnessTestingModeSetting = Notifier<ColorBlindnessType>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue