mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
xfer
This commit is contained in:
parent
411705283d
commit
e369d6091a
@ -118,8 +118,14 @@
|
||||
"grim": "Grim",
|
||||
"contrast": "Contrast"
|
||||
},
|
||||
"brightness": {
|
||||
"system": "System",
|
||||
"light": "Light",
|
||||
"dark": "Dark"
|
||||
},
|
||||
"settings_page": {
|
||||
"titlebar": "Settings",
|
||||
"color_theme": "Color Theme"
|
||||
"color_theme": "Color Theme",
|
||||
"brightness_mode": "Brightness Mode"
|
||||
}
|
||||
}
|
@ -27,24 +27,23 @@ class SettingsPage extends ConsumerStatefulWidget {
|
||||
class SettingsPageState extends ConsumerState<SettingsPage> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
late bool isInAsyncCall = false;
|
||||
ThemeService? themeService;
|
||||
ThemePreferences? themePreferences;
|
||||
// ThemePreferences? themePreferences;
|
||||
static const String formFieldTheme = 'theme';
|
||||
static const String formFieldBrightness = 'brightness';
|
||||
// static const String formFieldTitle = 'title';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await ref.read(windowControlProvider.notifier).changeWindowSetup(
|
||||
TitleBarStyle.normal, OrientationCapability.normal);
|
||||
final tsinst = await ThemeService.instance;
|
||||
setState(() {
|
||||
themeService = tsinst;
|
||||
themePreferences = tsinst.load();
|
||||
});
|
||||
});
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
// await ref.read(windowControlProvider.notifier).changeWindowSetup(
|
||||
// TitleBarStyle.normal, OrientationCapability.normal);
|
||||
// final tsinst = await ThemeService.instance;
|
||||
// setState(() {
|
||||
// themePreferences = tsinst.load();
|
||||
// });
|
||||
// });
|
||||
}
|
||||
|
||||
List<DropdownMenuItem<dynamic>> _getThemeDropdownItems() {
|
||||
@ -69,10 +68,28 @@ class SettingsPageState extends ConsumerState<SettingsPage> {
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<DropdownMenuItem<dynamic>> _getBrightnessDropdownItems() {
|
||||
const brightnessPrefs = BrightnessPreference.values;
|
||||
final brightnessNames = {
|
||||
BrightnessPreference.system: translate('brightness.system'),
|
||||
BrightnessPreference.light: translate('brightness.light'),
|
||||
BrightnessPreference.dark: translate('brightness.dark')
|
||||
};
|
||||
|
||||
return brightnessPrefs
|
||||
.map(
|
||||
(e) => DropdownMenuItem(value: e, child: Text(brightnessNames[e]!)))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.watch(windowControlProvider);
|
||||
final themeService = ref.watch(themeServiceProvider).asData();
|
||||
final themeService = ref.watch(themeServiceProvider).valueOrNull;
|
||||
if (themeService == null) {
|
||||
return waitingPage(context);
|
||||
}
|
||||
final themePreferences = themeService.load();
|
||||
|
||||
return ThemeSwitchingArea(
|
||||
child: Scaffold(
|
||||
@ -83,8 +100,8 @@ class SettingsPageState extends ConsumerState<SettingsPage> {
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => context.pop<void>(),
|
||||
),
|
||||
actions: const <Widget>[
|
||||
SignalStrengthMeterWidget(),
|
||||
actions: <Widget>[
|
||||
const SignalStrengthMeterWidget().paddingLTRB(16, 0, 16, 0),
|
||||
]),
|
||||
|
||||
body: FormBuilder(
|
||||
@ -97,69 +114,31 @@ class SettingsPageState extends ConsumerState<SettingsPage> {
|
||||
decoration: InputDecoration(
|
||||
label: Text(translate('settings_page.color_theme'))),
|
||||
items: _getThemeDropdownItems(),
|
||||
initialValue: themePreferences?.colorPreference,
|
||||
initialValue: themePreferences.colorPreference,
|
||||
onChanged: (value) async {
|
||||
final tprefs = themePreferences;
|
||||
if (tprefs != null) {
|
||||
final newPrefs = tprefs.copyWith(
|
||||
colorPreference: value as ColorPreference);
|
||||
final tservice = themeService;
|
||||
if (tservice != null) {
|
||||
await tservice.save(newPrefs);
|
||||
switcher.changeTheme(theme: tservice.get(newPrefs));
|
||||
}
|
||||
setState(() {
|
||||
themePreferences = newPrefs;
|
||||
});
|
||||
}
|
||||
}))
|
||||
|
||||
// Text(translate('settings_page.header'))
|
||||
// .textStyle(context.headlineSmall)
|
||||
// .paddingSymmetric(vertical: 16),
|
||||
// FormBuilderTextField(
|
||||
// autofocus: true,
|
||||
// name: formFieldName,
|
||||
// decoration:
|
||||
// InputDecoration(hintText: translate('account.form_name')),
|
||||
// maxLength: 64,
|
||||
// // The validator receives the text that the user has entered.
|
||||
// validator: FormBuilderValidators.compose([
|
||||
// FormBuilderValidators.required(),
|
||||
// ]),
|
||||
// ),
|
||||
// FormBuilderTextField(
|
||||
// name: formFieldTitle,
|
||||
// maxLength: 64,
|
||||
// decoration:
|
||||
// InputDecoration(hintText: translate('account.form_title')),
|
||||
// ),
|
||||
// Row(children: [
|
||||
// const Spacer(),
|
||||
// Text(translate('new_account_page.instructions'))
|
||||
// .toCenter()
|
||||
// .flexible(flex: 6),
|
||||
// const Spacer(),
|
||||
// ]).paddingSymmetric(vertical: 4),
|
||||
// ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// if (_formKey.currentState?.saveAndValidate() ?? false) {
|
||||
// setState(() {
|
||||
// isInAsyncCall = true;
|
||||
// });
|
||||
// try {
|
||||
// await onSubmit(_formKey);
|
||||
// } finally {
|
||||
// if (mounted) {
|
||||
// setState(() {
|
||||
// isInAsyncCall = false;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// child: Text(translate('new_account_page.create')),
|
||||
// ).paddingSymmetric(vertical: 4).alignAtCenterRight(),
|
||||
final newPrefs = themePreferences.copyWith(
|
||||
colorPreference: value as ColorPreference);
|
||||
await themeService.save(newPrefs);
|
||||
switcher.changeTheme(theme: themeService.get(newPrefs));
|
||||
ref.invalidate(themeServiceProvider);
|
||||
setState(() {});
|
||||
})),
|
||||
ThemeSwitcher.withTheme(
|
||||
builder: (_, switcher, theme) => FormBuilderDropdown(
|
||||
name: formFieldBrightness,
|
||||
decoration: InputDecoration(
|
||||
label:
|
||||
Text(translate('settings_page.brightness_mode'))),
|
||||
items: _getBrightnessDropdownItems(),
|
||||
initialValue: themePreferences.brightnessPreference,
|
||||
onChanged: (value) async {
|
||||
final newPrefs = themePreferences.copyWith(
|
||||
brightnessPreference: value as BrightnessPreference);
|
||||
await themeService.save(newPrefs);
|
||||
switcher.changeTheme(theme: themeService.get(newPrefs));
|
||||
ref.invalidate(themeServiceProvider);
|
||||
setState(() {});
|
||||
})),
|
||||
],
|
||||
),
|
||||
).paddingSymmetric(horizontal: 24, vertical: 8),
|
||||
|
@ -203,7 +203,8 @@ class ThemeService {
|
||||
ThemePreferences? themePreferences;
|
||||
if (themePreferencesJson != null) {
|
||||
try {
|
||||
themePreferences = ThemePreferences.fromJson(themePreferencesJson);
|
||||
themePreferences =
|
||||
ThemePreferences.fromJson(jsonDecode(themePreferencesJson));
|
||||
// ignore: avoid_catches_without_on_clauses
|
||||
} catch (_) {
|
||||
// ignore
|
||||
@ -273,4 +274,5 @@ class ThemeService {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<ThemeService> themeService() => ThemeService.instance;
|
||||
FutureOr<ThemeService> themeService(ThemeServiceRef ref) async =>
|
||||
await ThemeService.instance;
|
||||
|
@ -6,7 +6,7 @@ part of 'theme_service.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$themeServiceHash() => r'a319ae893d3b5cf5718a0c1a21c22bd073f5fd34';
|
||||
String _$themeServiceHash() => r'87dbacb9df4923f507fb01e486b91d73a3fcef9c';
|
||||
|
||||
/// See also [themeService].
|
||||
@ProviderFor(themeService)
|
||||
|
@ -23,9 +23,11 @@ Future<VeilidConfig> getVeilidChatConfig() async {
|
||||
config = config.copyWith(
|
||||
network: config.network.copyWith(
|
||||
dht: config.network.dht.copyWith(
|
||||
getValueCount: 2,
|
||||
//getValueCount: 2,
|
||||
getValueFanout: 8,
|
||||
getValueTimeoutMs: 5000,
|
||||
setValueCount: 2,
|
||||
//setValueCount: 2,
|
||||
setValueFanout: 10,
|
||||
setValueTimeoutMs: 5000)));
|
||||
|
||||
return config;
|
||||
|
@ -208,7 +208,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 1300;
|
||||
LastUpgradeCheck = 1430;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
33CC10EC2044A3C60003C045 = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1300"
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
36
pubspec.lock
36
pubspec.lock
@ -277,10 +277,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
||||
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.1"
|
||||
version: "1.17.2"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -673,10 +673,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6
|
||||
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.18.0"
|
||||
version: "0.18.1"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -745,18 +745,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.15"
|
||||
version: "0.12.16"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
version: "0.5.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1182,10 +1182,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
version: "1.10.0"
|
||||
split_view:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1294,10 +1294,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
|
||||
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
version: "0.6.0"
|
||||
timing:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1440,7 +1440,7 @@ packages:
|
||||
path: "../veilid/veilid-flutter"
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.1.7"
|
||||
version: "0.1.10"
|
||||
visibility_detector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1457,6 +1457,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.4-beta"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1506,5 +1514,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.0.5 <4.0.0"
|
||||
dart: ">=3.1.0-185.0.dev <4.0.0"
|
||||
flutter: ">=3.10.6"
|
||||
|
Loading…
Reference in New Issue
Block a user