Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: color seed setting not working #516

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MyApp extends StatelessWidget {
listenable: RNodes.app,
builder: (context, _) {
if (!Stores.setting.useSystemPrimaryColor.fetch()) {
UIs.colorSeed = Color(Stores.setting.primaryColor.fetch());
UIs.colorSeed = Color(Stores.setting.colorSeed.fetch());
return _buildApp(
context,
light: ThemeData(
Expand Down Expand Up @@ -88,6 +88,7 @@ class MyApp extends StatelessWidget {
context.setLibL10n();
final appL10n = AppLocalizations.of(context);
if (appL10n != null) l10n = appL10n;
UIs.primaryColor = Theme.of(context).colorScheme.primary;

final intros = _IntroPage.builders;
if (intros.isNotEmpty) {
Expand Down
3 changes: 2 additions & 1 deletion lib/data/store/setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class SettingStore extends PersistentStore {
1.0,
);

late final primaryColor = property(
/// The seed of color scheme
late final colorSeed = property(
'primaryColor',
4287106639,
);
Expand Down
1 change: 1 addition & 0 deletions lib/view/page/backup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class BackupPage extends StatelessWidget {
padding: const EdgeInsets.all(13),
children: [
_buildTip(),
CenterGreyTitle(libL10n.sync),
if (isMacOS || isIOS) _buildIcloud(context),
_buildWebdav(context),
_buildFile(context),
Expand Down
2 changes: 1 addition & 1 deletion lib/view/page/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class _ContainerPageState extends State<ContainerPage> {
final host = Stores.container.fetch(id);
final ctrl = TextEditingController(text: host);
await context.showRoundDialog(
title: 'DOCKER_HOST',
title: libL10n.edit,
child: Input(
maxLines: 2,
controller: ctrl,
Expand Down
6 changes: 4 additions & 2 deletions lib/view/page/process.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ class _ProcessPageState extends State<ProcessPage> {
'${l10n.stop} ${l10n.process}(${proc.pid})',
)),
actions: Btn.ok(onTap: (c) async {
await _client?.run('kill ${proc.pid}');
await _refresh();
context.pop();
await context.showLoadingDialog(fn: () async {
await _client?.run('kill ${proc.pid}');
await _refresh();
});
}).toList,
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/view/page/server/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ class _ServerPageState extends State<ServerPage>
borderRadius: BorderRadius.circular(7),
onTap: onTap,
child: wrapped,
).paddingOnly(left: 10);
).paddingOnly(left: 5);
}

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

// Widget _buildLaunchPage() {
Expand Down
13 changes: 4 additions & 9 deletions lib/view/page/ssh/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,10 @@ class _SSHTabPageState extends State<SSHTabPage>
return AlertDialog(
title: Text(libL10n.attention),
content: Text('${libL10n.close} SSH ${l10n.conn}($name) ?'),
actions: [
Btn.ok(
onTap: (c) => context.pop(true),
red: true,
),
Btn.cancel(
onTap: (c) => context.pop(false),
),
],
actions: Btn.ok(
onTap: (c) => context.pop(true),
red: true,
).toList,
);
},
);
Expand Down
4 changes: 2 additions & 2 deletions lib/view/page/storage/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
title: libL10n.delete,
child: Text(libL10n.askContinue('${libL10n.delete} $fileName')),
actions: Btn.ok(
onTap: (c) {
onTap: (c) async {
context.pop();
try {
file.deleteSync(recursive: true);
await file.delete(recursive: true);
} catch (e) {
context.showSnackBar('${libL10n.fail}:\n$e');
return;
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.0.109"
resolved-ref: "27266fdd805a5bb2a9c682ca70aaaef785e609b5"
ref: "v1.0.111"
resolved-ref: c220f27ce606e0a342cf9add6a90ce4c11844972
url: "https://github.com/lppcg/fl_lib"
source: git
version: "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies:
fl_lib:
git:
url: https://github.com/lppcg/fl_lib
ref: v1.0.109
ref: v1.0.111

dependency_overrides:
# dartssh2:
Expand Down