mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
feat: separate ssh term theme setting (#305)
This commit is contained in:
@@ -63,7 +63,6 @@ extension DialogX on BuildContext {
|
||||
Future<String?> showPwdDialog({
|
||||
String? user,
|
||||
required String hostId,
|
||||
void Function()? onCorrectPwd,
|
||||
}) async {
|
||||
if (!mounted) return null;
|
||||
return await showRoundDialog<String>(
|
||||
|
||||
@@ -259,6 +259,10 @@ class SettingStore extends PersistentStore {
|
||||
/// Used for [DialogX.showPwdDialog]
|
||||
late final rememberPwdInMem = property('rememberPwdInMem', true);
|
||||
|
||||
/// SSH Term Theme
|
||||
/// 0: follow app theme, 1: light, 2: dark
|
||||
late final termTheme = property('termTheme', 0);
|
||||
|
||||
// Never show these settings for users
|
||||
//
|
||||
// ------BEGIN------
|
||||
|
||||
@@ -170,6 +170,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildSSH() {
|
||||
return Column(
|
||||
children: [
|
||||
_buildTermTheme(),
|
||||
_buildFont(),
|
||||
_buildTermFontSize(),
|
||||
_buildTermCursor(),
|
||||
@@ -1090,4 +1091,40 @@ class _SettingPageState extends State<SettingPage> {
|
||||
trailing: StoreSwitch(prop: _setting.rememberPwdInMem),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTermTheme() {
|
||||
String index2Str(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return l10n.system;
|
||||
case 1:
|
||||
return l10n.light;
|
||||
case 2:
|
||||
return l10n.dark;
|
||||
default:
|
||||
return l10n.error;
|
||||
}
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text(l10n.theme),
|
||||
trailing: ValueListenableBuilder(
|
||||
valueListenable: _setting.termTheme.listenable(),
|
||||
builder: (_, val, __) => Text(
|
||||
index2Str(val),
|
||||
style: UIs.text15,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final selected = await context.showPickSingleDialog(
|
||||
items: List.generate(3, (index) => index),
|
||||
name: (p0) => index2Str(p0),
|
||||
initial: _setting.termTheme.fetch(),
|
||||
);
|
||||
if (selected != null) {
|
||||
_setting.termTheme.put(selected);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,11 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
super.didChangeDependencies();
|
||||
_isDark = context.isDark;
|
||||
_media = MediaQuery.of(context);
|
||||
_terminalTheme = _isDark ? TerminalThemes.dark : TerminalThemes.light;
|
||||
_terminalTheme = switch (Stores.setting.termTheme.fetch()) {
|
||||
1 => TerminalThemes.light,
|
||||
2 => TerminalThemes.dark,
|
||||
_ => _isDark ? TerminalThemes.dark : TerminalThemes.light,
|
||||
};
|
||||
|
||||
// Because the virtual keyboard only displayed on mobile devices
|
||||
if (isMobile || isDebuggingMobileLayoutOnDesktop) {
|
||||
|
||||
Reference in New Issue
Block a user