mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
new: set light/dark editor theme
This commit is contained in:
@@ -45,4 +45,5 @@ const defaultLaunchPageIdx = 0;
|
||||
|
||||
const defaultUpdateInterval = 3;
|
||||
|
||||
const defaultEditorTheme = 'monokai';
|
||||
const defaultEditorTheme = 'a11y-light';
|
||||
const defaultEditorDarkTheme = 'monokai';
|
||||
|
||||
@@ -10,7 +10,7 @@ const privateKeyMaxSize = 20 * 1024;
|
||||
const editorMaxSize = 1024 * 1024;
|
||||
|
||||
/// Max debug log lines
|
||||
const maxDebugLogLines = 377;
|
||||
const maxDebugLogLines = 100;
|
||||
|
||||
/// Method Channels
|
||||
const pkgName = 'tech.lolli.toolbox';
|
||||
|
||||
@@ -68,6 +68,9 @@ class SettingStore extends PersistentStore {
|
||||
// Editor theme
|
||||
StoreProperty<String> get editorTheme =>
|
||||
property('editorTheme', defaultValue: defaultEditorTheme);
|
||||
|
||||
StoreProperty<String> get editorDarkTheme =>
|
||||
property('editorDarkTheme', defaultValue: defaultEditorDarkTheme);
|
||||
|
||||
StoreProperty<bool> get fullScreen =>
|
||||
property('fullScreen', defaultValue: false);
|
||||
|
||||
@@ -353,7 +353,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildNetSpeedItem(NetSpeed ns, String device) {
|
||||
final width = (_media.size.width - 34 - 34) / 2.9;
|
||||
final width = (_media.size.width - 34 - 34) / 3;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
@@ -365,6 +365,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
device,
|
||||
style: textSize11,
|
||||
textScaleFactor: 1.0,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
@@ -43,6 +43,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
final _maxRetryKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
final _localeKey = GlobalKey<PopupMenuButtonState<String>>();
|
||||
final _editorThemeKey = GlobalKey<PopupMenuButtonState<String>>();
|
||||
final _editorDarkThemeKey = GlobalKey<PopupMenuButtonState<String>>();
|
||||
final _keyboardTypeKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
|
||||
late final SettingStore _setting;
|
||||
@@ -58,6 +59,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
final _fontSize = ValueNotifier(0.0);
|
||||
final _localeCode = ValueNotifier('');
|
||||
final _editorTheme = ValueNotifier('');
|
||||
final _editorDarkTheme = ValueNotifier('');
|
||||
final _keyboardType = ValueNotifier(0);
|
||||
|
||||
final _pushToken = ValueNotifier<String?>(null);
|
||||
@@ -82,6 +84,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_selectedColorValue.value = _setting.primaryColor.fetch()!;
|
||||
_fontSize.value = _setting.termFontSize.fetch()!;
|
||||
_editorTheme.value = _setting.editorTheme.fetch()!;
|
||||
_editorDarkTheme.value = _setting.editorDarkTheme.fetch()!;
|
||||
_keyboardType.value = _setting.keyboardType.fetch()!;
|
||||
}
|
||||
|
||||
@@ -176,6 +179,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
return Column(
|
||||
children: [
|
||||
_buildEditorTheme(),
|
||||
_buildEditorDarkTheme(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
@@ -651,7 +655,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
).toList();
|
||||
return ListTile(
|
||||
title: Text(_s.theme),
|
||||
title: Text(_s.light + _s.theme),
|
||||
trailing: ValueBuilder(
|
||||
listenable: _editorTheme,
|
||||
build: () => PopupMenuButton(
|
||||
@@ -674,6 +678,39 @@ class _SettingPageState extends State<SettingPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEditorDarkTheme() {
|
||||
final items = themeMap.keys.map(
|
||||
(key) {
|
||||
return PopupMenuItem<String>(
|
||||
value: key,
|
||||
child: Text(key),
|
||||
);
|
||||
},
|
||||
).toList();
|
||||
return ListTile(
|
||||
title: Text(_s.dark + _s.theme),
|
||||
trailing: ValueBuilder(
|
||||
listenable: _editorDarkTheme,
|
||||
build: () => PopupMenuButton(
|
||||
key: _editorDarkThemeKey,
|
||||
itemBuilder: (BuildContext context) => items,
|
||||
initialValue: _editorDarkTheme.value,
|
||||
onSelected: (String idx) {
|
||||
_editorDarkTheme.value = idx;
|
||||
_setting.editorDarkTheme.put(idx);
|
||||
},
|
||||
child: Text(
|
||||
_editorDarkTheme.value,
|
||||
style: textSize15,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
_editorDarkThemeKey.currentState?.showButtonMenu();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFullScreenSwitch() {
|
||||
return ListTile(
|
||||
title: Text(_s.fullScreen),
|
||||
|
||||
@@ -23,8 +23,8 @@ class UrlText extends StatelessWidget {
|
||||
this.style = _textStyle,
|
||||
}) : super(key: key);
|
||||
|
||||
List<InlineSpan> _getTextSpans(Color c) {
|
||||
List<InlineSpan> widgets = <InlineSpan>[];
|
||||
List<InlineSpan> getTextSpans(Color c) {
|
||||
final widgets = <InlineSpan>[];
|
||||
Iterable<Match> matches = _reg.allMatches(text);
|
||||
List<_ResultMatch> resultMatches = <_ResultMatch>[];
|
||||
int start = 0;
|
||||
@@ -33,24 +33,27 @@ class UrlText extends StatelessWidget {
|
||||
final group0 = match.group(0);
|
||||
if (group0 != null && group0.isNotEmpty) {
|
||||
if (start != match.start) {
|
||||
_ResultMatch result1 = _ResultMatch();
|
||||
result1.isUrl = false;
|
||||
result1.text = text.substring(start, match.start);
|
||||
_ResultMatch result1 = _ResultMatch(
|
||||
false,
|
||||
text.substring(start, match.start),
|
||||
);
|
||||
resultMatches.add(result1);
|
||||
}
|
||||
|
||||
_ResultMatch result2 = _ResultMatch();
|
||||
result2.isUrl = true;
|
||||
result2.text = match.group(0)!;
|
||||
_ResultMatch result2 = _ResultMatch(
|
||||
true,
|
||||
match.group(0)!,
|
||||
);
|
||||
resultMatches.add(result2);
|
||||
start = match.end;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < text.length) {
|
||||
_ResultMatch result1 = _ResultMatch();
|
||||
result1.isUrl = false;
|
||||
result1.text = text.substring(start);
|
||||
_ResultMatch result1 = _ResultMatch(
|
||||
false,
|
||||
text.substring(start),
|
||||
);
|
||||
resultMatches.add(result1);
|
||||
}
|
||||
|
||||
@@ -81,7 +84,7 @@ class UrlText extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return RichText(
|
||||
textAlign: textAlign ?? TextAlign.start,
|
||||
text: TextSpan(children: _getTextSpans(contentColor.resolve(context))),
|
||||
text: TextSpan(children: getTextSpans(contentColor.resolve(context))),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -99,6 +102,8 @@ class _LinkTextSpan extends TextSpan {
|
||||
}
|
||||
|
||||
class _ResultMatch {
|
||||
late bool isUrl;
|
||||
late String text;
|
||||
final bool isUrl;
|
||||
final String text;
|
||||
|
||||
_ResultMatch(this.isUrl, this.text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user