bug: color seed setting not working (#516)

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-08-03 23:17:18 +08:00
committed by GitHub
parent 9db04a60c2
commit ea7c8caf14
11 changed files with 32 additions and 31 deletions

View File

@@ -22,7 +22,7 @@ class MyApp extends StatelessWidget {
listenable: RNodes.app, listenable: RNodes.app,
builder: (context, _) { builder: (context, _) {
if (!Stores.setting.useSystemPrimaryColor.fetch()) { if (!Stores.setting.useSystemPrimaryColor.fetch()) {
UIs.colorSeed = Color(Stores.setting.primaryColor.fetch()); UIs.colorSeed = Color(Stores.setting.colorSeed.fetch());
return _buildApp( return _buildApp(
context, context,
light: ThemeData( light: ThemeData(
@@ -88,6 +88,7 @@ class MyApp extends StatelessWidget {
context.setLibL10n(); context.setLibL10n();
final appL10n = AppLocalizations.of(context); final appL10n = AppLocalizations.of(context);
if (appL10n != null) l10n = appL10n; if (appL10n != null) l10n = appL10n;
UIs.primaryColor = Theme.of(context).colorScheme.primary;
final intros = _IntroPage.builders; final intros = _IntroPage.builders;
if (intros.isNotEmpty) { if (intros.isNotEmpty) {

View File

@@ -55,7 +55,8 @@ class SettingStore extends PersistentStore {
1.0, 1.0,
); );
late final primaryColor = property( /// The seed of color scheme
late final colorSeed = property(
'primaryColor', 'primaryColor',
4287106639, 4287106639,
); );

View File

@@ -34,6 +34,7 @@ class BackupPage extends StatelessWidget {
padding: const EdgeInsets.all(13), padding: const EdgeInsets.all(13),
children: [ children: [
_buildTip(), _buildTip(),
CenterGreyTitle(libL10n.sync),
if (isMacOS || isIOS) _buildIcloud(context), if (isMacOS || isIOS) _buildIcloud(context),
_buildWebdav(context), _buildWebdav(context),
_buildFile(context), _buildFile(context),

View File

@@ -413,7 +413,7 @@ class _ContainerPageState extends State<ContainerPage> {
final host = Stores.container.fetch(id); final host = Stores.container.fetch(id);
final ctrl = TextEditingController(text: host); final ctrl = TextEditingController(text: host);
await context.showRoundDialog( await context.showRoundDialog(
title: 'DOCKER_HOST', title: libL10n.edit,
child: Input( child: Input(
maxLines: 2, maxLines: 2,
controller: ctrl, controller: ctrl,

View File

@@ -159,9 +159,11 @@ class _ProcessPageState extends State<ProcessPage> {
'${l10n.stop} ${l10n.process}(${proc.pid})', '${l10n.stop} ${l10n.process}(${proc.pid})',
)), )),
actions: Btn.ok(onTap: (c) async { actions: Btn.ok(onTap: (c) async {
await _client?.run('kill ${proc.pid}');
await _refresh();
context.pop(); context.pop();
await context.showLoadingDialog(fn: () async {
await _client?.run('kill ${proc.pid}');
await _refresh();
});
}).toList, }).toList,
); );
}, },

View File

@@ -529,7 +529,7 @@ class _ServerPageState extends State<ServerPage>
borderRadius: BorderRadius.circular(7), borderRadius: BorderRadius.circular(7),
onTap: onTap, onTap: onTap,
child: wrapped, child: wrapped,
).paddingOnly(left: 10); ).paddingOnly(left: 5);
} }
Widget _buildTopRightText(Server s) { Widget _buildTopRightText(Server s) {

View File

@@ -38,9 +38,10 @@ class _SettingPageState extends State<SettingPage> {
onPressed: () => context.showRoundDialog( onPressed: () => context.showRoundDialog(
title: libL10n.attention, title: libL10n.attention,
child: SimpleMarkdown( child: SimpleMarkdown(
data: libL10n.askContinue( data: libL10n.askContinue(
'${libL10n.delete} **${libL10n.all}** ${l10n.setting}', '${libL10n.delete} **${libL10n.all}** ${l10n.setting}',
)), ),
),
actions: Btn.ok( actions: Btn.ok(
onTap: (c) { onTap: (c) {
context.pop(); context.pop();
@@ -223,8 +224,11 @@ class _SettingPageState extends State<SettingPage> {
return ListTile( return ListTile(
leading: const Icon(Icons.colorize), leading: const Icon(Icons.colorize),
title: Text(l10n.primaryColorSeed), title: Text(l10n.primaryColorSeed),
trailing: ClipOval( trailing: _setting.colorSeed.listenable().listenVal(
child: Container(color: UIs.primaryColor, height: 27, width: 27), (val) {
final c = Color(val);
return ClipOval(child: Container(color: c, height: 27, width: 27));
},
), ),
onTap: () async { onTap: () async {
final ctrl = TextEditingController(text: UIs.primaryColor.toHex); final ctrl = TextEditingController(text: UIs.primaryColor.toHex);
@@ -252,7 +256,7 @@ class _SettingPageState extends State<SettingPage> {
suggestion: false, suggestion: false,
), ),
ColorPicker( ColorPicker(
color: Color(_setting.primaryColor.fetch()), color: Color(_setting.colorSeed.fetch()),
onColorChanged: (c) => ctrl.text = c.toHex, onColorChanged: (c) => ctrl.text = c.toHex,
) )
]); ]);
@@ -274,13 +278,10 @@ class _SettingPageState extends State<SettingPage> {
context.showSnackBar(libL10n.fail); context.showSnackBar(libL10n.fail);
return; return;
} }
// Change [primaryColor] first, then change [_selectedColorValue],
// So the [ValueBuilder] will be triggered with the new value
UIs.colorSeed = color; UIs.colorSeed = color;
_setting.primaryColor.put(color.value); _setting.colorSeed.put(color.value);
context.pop(); context.pop();
context.pop(); Future.delayed(Durations.medium1, RNodes.app.notify);
RNodes.app.notify();
} }
// Widget _buildLaunchPage() { // Widget _buildLaunchPage() {

View File

@@ -73,15 +73,10 @@ class _SSHTabPageState extends State<SSHTabPage>
return AlertDialog( return AlertDialog(
title: Text(libL10n.attention), title: Text(libL10n.attention),
content: Text('${libL10n.close} SSH ${l10n.conn}($name) ?'), content: Text('${libL10n.close} SSH ${l10n.conn}($name) ?'),
actions: [ actions: Btn.ok(
Btn.ok( onTap: (c) => context.pop(true),
onTap: (c) => context.pop(true), red: true,
red: true, ).toList,
),
Btn.cancel(
onTap: (c) => context.pop(false),
),
],
); );
}, },
); );

View File

@@ -350,10 +350,10 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
title: libL10n.delete, title: libL10n.delete,
child: Text(libL10n.askContinue('${libL10n.delete} $fileName')), child: Text(libL10n.askContinue('${libL10n.delete} $fileName')),
actions: Btn.ok( actions: Btn.ok(
onTap: (c) { onTap: (c) async {
context.pop(); context.pop();
try { try {
file.deleteSync(recursive: true); await file.delete(recursive: true);
} catch (e) { } catch (e) {
context.showSnackBar('${libL10n.fail}:\n$e'); context.showSnackBar('${libL10n.fail}:\n$e');
return; return;

View File

@@ -385,8 +385,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "v1.0.109" ref: "v1.0.111"
resolved-ref: "27266fdd805a5bb2a9c682ca70aaaef785e609b5" resolved-ref: c220f27ce606e0a342cf9add6a90ce4c11844972
url: "https://github.com/lppcg/fl_lib" url: "https://github.com/lppcg/fl_lib"
source: git source: git
version: "0.0.1" version: "0.0.1"

View File

@@ -61,7 +61,7 @@ dependencies:
fl_lib: fl_lib:
git: git:
url: https://github.com/lppcg/fl_lib url: https://github.com/lppcg/fl_lib
ref: v1.0.109 ref: v1.0.111
dependency_overrides: dependency_overrides:
# dartssh2: # dartssh2: