mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 13:25:10 +01:00
opt.: global server logo url & new {BRIGHT} param
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/listx.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/data/model/app/server_detail_card.dart';
|
||||
import 'package:toolbox/data/model/app/shell_func.dart';
|
||||
import 'package:toolbox/data/model/server/battery.dart';
|
||||
@@ -104,7 +105,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
|
||||
Widget _buildMainPage(Server si) {
|
||||
final buildFuncs = !Stores.setting.moveOutServerTabFuncBtns.fetch();
|
||||
final logoUrl = si.spi.custom?.logoUrl;
|
||||
final logoUrl = si.spi.custom?.logoUrl ??
|
||||
Stores.setting.serverLogoUrl.fetch().selfIfNotNullEmpty;
|
||||
final buildLogo = logoUrl != null;
|
||||
final children = [
|
||||
if (buildLogo)
|
||||
@@ -149,7 +151,9 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
|
||||
Widget _buildLogo(String logoUrl, Dist? dist) {
|
||||
if (dist != null) {
|
||||
logoUrl = logoUrl.replaceFirst('{DIST}', dist.name);
|
||||
logoUrl = logoUrl
|
||||
.replaceFirst('{DIST}', dist.name)
|
||||
.replaceFirst('{BRIGHT}', context.isDark ? 'dark' : 'light');
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||
|
||||
@@ -151,6 +151,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildServer() {
|
||||
return Column(
|
||||
children: [
|
||||
_buildServerLogoUrl(),
|
||||
_buildServerFuncBtns(),
|
||||
_buildNetViewType(),
|
||||
_buildServerSeq(),
|
||||
@@ -1147,4 +1148,50 @@ class _SettingPageState extends State<SettingPage> {
|
||||
trailing: StoreSwitch(prop: _setting.sshWakeLock),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildServerLogoUrl() {
|
||||
void onSave(String url) {
|
||||
if (url.isEmpty || !url.startsWith('http')) {
|
||||
context.showRoundDialog(
|
||||
title: Text(l10n.failed),
|
||||
child: Text('${l10n.invalid} URL'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
_setting.serverLogoUrl.put(url);
|
||||
context.pop();
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text('Logo ${l10n.addr}'),
|
||||
subtitle: SimpleMarkdown(data: '${l10n.view} ${l10n.doc}'),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: () {
|
||||
final ctrl =
|
||||
TextEditingController(text: _setting.serverLogoUrl.fetch());
|
||||
context.showRoundDialog(
|
||||
title: Text('Logo ${l10n.addr}'),
|
||||
child: Input(
|
||||
controller: ctrl,
|
||||
autoFocus: true,
|
||||
hint: 'https://example.com/logo.png',
|
||||
icon: Icons.link,
|
||||
onSubmitted: onSave,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => onSave(ctrl.text),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user