mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 21:34:45 +01:00
opt.
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/model/server/private_key_info.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/res/build_data.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:toolbox/view/page/backup.dart';
|
||||
@@ -154,8 +155,11 @@ class AppRoutes {
|
||||
return AppRoutes(
|
||||
DebugPage(
|
||||
key: key,
|
||||
notifier: Pros.debug.widgets,
|
||||
onClear: Pros.debug.clear,
|
||||
args: DebugPageArgs(
|
||||
notifier: Pros.debug.widgets,
|
||||
onClear: Pros.debug.clear,
|
||||
title: 'Logs(${BuildData.build})',
|
||||
),
|
||||
),
|
||||
'debug',
|
||||
);
|
||||
|
||||
@@ -130,12 +130,7 @@ final class PveLxc extends PveResIface implements PveCtrlIface {
|
||||
@override
|
||||
String get summary {
|
||||
if (available) {
|
||||
return uptime.secondsToDuration().toAgoStr(
|
||||
day: l10n.day,
|
||||
hour: l10n.hour,
|
||||
minute: l10n.minute,
|
||||
second: l10n.second,
|
||||
);
|
||||
return uptime.secondsToDuration().toAgoStr;
|
||||
}
|
||||
return l10n.stopped;
|
||||
}
|
||||
@@ -213,12 +208,7 @@ final class PveQemu extends PveResIface implements PveCtrlIface {
|
||||
@override
|
||||
String get summary {
|
||||
if (available) {
|
||||
return uptime.secondsToDuration().toAgoStr(
|
||||
day: l10n.day,
|
||||
hour: l10n.hour,
|
||||
minute: l10n.minute,
|
||||
second: l10n.second,
|
||||
);
|
||||
return uptime.secondsToDuration().toAgoStr;
|
||||
}
|
||||
return l10n.stopped;
|
||||
}
|
||||
@@ -268,12 +258,7 @@ final class PveNode extends PveResIface {
|
||||
|
||||
String get topRight {
|
||||
if (isRunning) {
|
||||
return uptime.secondsToDuration().toAgoStr(
|
||||
day: l10n.day,
|
||||
hour: l10n.hour,
|
||||
minute: l10n.minute,
|
||||
second: l10n.second,
|
||||
);
|
||||
return uptime.secondsToDuration().toAgoStr;
|
||||
}
|
||||
return l10n.stopped;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ final class WakeOnLanCfg {
|
||||
return (err, valid);
|
||||
}
|
||||
|
||||
Future<void> wake() async {
|
||||
Future<void> wake() {
|
||||
if (!validate().$2) {
|
||||
throw Exception('Invalid WakeOnLanCfg');
|
||||
}
|
||||
@@ -48,7 +48,7 @@ final class WakeOnLanCfg {
|
||||
final mac_ = MACAddress(mac);
|
||||
final pwd_ = pwd != null ? SecureONPassword(pwd!) : null;
|
||||
final obj = WakeOnLAN(ip_, mac_, password: pwd_);
|
||||
await obj.wake(
|
||||
return obj.wake(
|
||||
repeat: 3,
|
||||
repeatDelay: const Duration(milliseconds: 500),
|
||||
);
|
||||
|
||||
@@ -283,7 +283,7 @@ class ServerProvider extends ChangeNotifier {
|
||||
// message: 'Wake on lan failed: $e',
|
||||
// );
|
||||
// _setServerState(s, ServerConn.failed);
|
||||
// Loggers.app.warning('Wake on lan failed', e);
|
||||
Loggers.app.warning('Wake on lan failed', e);
|
||||
// return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 908;
|
||||
static const int build = 909;
|
||||
static const String engine = "3.22.0";
|
||||
static const String buildAt = "2024-05-22 22:25:06";
|
||||
static const int modifications = 4;
|
||||
static const String buildAt = "2024-05-23 00:45:04";
|
||||
static const int modifications = 11;
|
||||
static const int script = 48;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import 'package:toolbox/data/res/store.dart';
|
||||
import '../../data/model/container/ps.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/provider/container.dart';
|
||||
import '../widget/popup_menu.dart';
|
||||
import '../widget/two_line_text.dart';
|
||||
|
||||
class ContainerPage extends StatefulWidget {
|
||||
@@ -260,8 +259,9 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
|
||||
Widget _buildMoreBtn(ContainerPs dItem) {
|
||||
return PopupMenu(
|
||||
items: ContainerMenu.items(dItem.running),
|
||||
builder: (e) => PopMenu.build(e, e.icon, e.toStr),
|
||||
items: ContainerMenu.items(dItem.running)
|
||||
.map((e) => PopMenu.build(e, e.icon, e.toStr))
|
||||
.toList(),
|
||||
onSelected: (item) => _onTapMoreBtn(item, dItem),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -341,7 +341,6 @@ ${GithubIds.participants.map((e) => '[$e](${e.url})').join(' ')}
|
||||
build: BuildData.build,
|
||||
url: '${Urls.cdnBase}/update.json',
|
||||
context: context,
|
||||
updateL10n: l10n.update,
|
||||
);
|
||||
}
|
||||
HomeWidgetMC.update();
|
||||
|
||||
@@ -77,7 +77,6 @@ final class _WearHomeState extends State<WearHome> with AfterLayoutMixin {
|
||||
build: BuildData.build,
|
||||
url: '${Urls.cdnBase}/update.json',
|
||||
context: context,
|
||||
updateL10n: l10n.update,
|
||||
);
|
||||
}
|
||||
await Pros.server.load();
|
||||
|
||||
@@ -255,9 +255,6 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
onChanged: (p0) => _tags = p0,
|
||||
allTags: [...Pros.server.tags.value],
|
||||
onRenameTag: Pros.server.renameTag,
|
||||
renameL10n: l10n.rename,
|
||||
tagL10n: l10n.tag,
|
||||
addL10n: l10n.add,
|
||||
),
|
||||
ListTile(
|
||||
title: Text(l10n.autoConnect),
|
||||
|
||||
@@ -214,7 +214,6 @@ class _ServerPageState extends State<ServerPage>
|
||||
_tag = p0;
|
||||
}),
|
||||
initTag: _tag,
|
||||
allL10n: l10n.all,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
build: BuildData.build,
|
||||
url: Urls.updateCfg,
|
||||
force: BuildMode.isDebug,
|
||||
updateL10n: l10n.update,
|
||||
),
|
||||
),
|
||||
trailing: StoreSwitch(prop: _setting.autoCheckAppUpdate),
|
||||
|
||||
@@ -136,9 +136,6 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
onRenameTag: (old, n) => setState(() {
|
||||
Pros.snippet.renameTag(old, n);
|
||||
}),
|
||||
renameL10n: l10n.rename,
|
||||
tagL10n: l10n.tag,
|
||||
addL10n: l10n.add,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -69,7 +69,6 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
onTagChanged: (tag) => setState(() => _tag = tag),
|
||||
initTag: _tag,
|
||||
width: _media.size.width,
|
||||
allL10n: l10n.all,
|
||||
),
|
||||
footer: UIs.height77,
|
||||
buildDefaultDragHandles: false,
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_background_service/flutter_background_service.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
|
||||
@@ -17,15 +17,14 @@ class SSHTabPage extends StatefulWidget {
|
||||
|
||||
class _SSHTabPageState extends State<SSHTabPage>
|
||||
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||
late final _tabIds = <String, Widget>{
|
||||
l10n.add: _buildAddPage(),
|
||||
late final _tabMap = <String, ({Widget page, FocusNode? focus})>{
|
||||
l10n.add: (page: _buildAddPage(), focus: null),
|
||||
};
|
||||
late var _tabController = TabController(
|
||||
length: _tabIds.length,
|
||||
length: _tabMap.length,
|
||||
vsync: this,
|
||||
);
|
||||
final _fabRN = ValueNotifier(0);
|
||||
final _focusMap = <String, FocusNode>{};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -33,13 +32,14 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
return Scaffold(
|
||||
appBar: TabBar(
|
||||
controller: _tabController,
|
||||
tabs: _tabIds.keys.map(_buildTabItem).toList(),
|
||||
tabs: _tabMap.keys.map(_buildTabItem).toList(),
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
dividerColor: Colors.transparent,
|
||||
onTap: (value) {
|
||||
_fabRN.value = value;
|
||||
_focusMap[_tabIds.keys.elementAt(value)]?.requestFocus();
|
||||
final mapKey = _tabMap.keys.elementAt(value);
|
||||
_tabMap[mapKey]?.focus?.requestFocus();
|
||||
},
|
||||
),
|
||||
body: _buildBody(),
|
||||
@@ -67,9 +67,9 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
children: [
|
||||
Text(e),
|
||||
UIs.width7,
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 17),
|
||||
onPressed: () async {
|
||||
IconBtn(
|
||||
icon: Icons.close,
|
||||
onTap: () async {
|
||||
final confirm = await context.showRoundDialog<bool>(
|
||||
title: l10n.attention,
|
||||
child: Text('${l10n.close} SSH ${l10n.conn}($e) ?'),
|
||||
@@ -87,7 +87,7 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
if (confirm != true) {
|
||||
return;
|
||||
}
|
||||
_tabIds.remove(e);
|
||||
_tabMap.remove(e);
|
||||
_refreshTabs();
|
||||
},
|
||||
),
|
||||
@@ -131,38 +131,39 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
return TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _tabController,
|
||||
children: _tabIds.values.toList(),
|
||||
children: _tabMap.values.map((e) => e.page).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
void _onTapInitCard(ServerPrivateInfo spi) {
|
||||
final name = () {
|
||||
if (_tabIds.containsKey(spi.name)) {
|
||||
return '${spi.name}(${_tabIds.length + 1})';
|
||||
if (_tabMap.containsKey(spi.name)) {
|
||||
return '${spi.name}(${_tabMap.length + 1})';
|
||||
}
|
||||
return spi.name;
|
||||
}();
|
||||
final focus = _focusMap.putIfAbsent(name, () => FocusNode());
|
||||
_tabIds[name] = SSHPage(
|
||||
spi: spi,
|
||||
final focus = FocusNode();
|
||||
_tabMap[name] = (
|
||||
page: SSHPage(
|
||||
spi: spi,
|
||||
focus: focus,
|
||||
notFromTab: false,
|
||||
onSessionEnd: () {
|
||||
_tabMap.remove(name);
|
||||
_refreshTabs();
|
||||
},
|
||||
),
|
||||
focus: focus,
|
||||
notFromTab: false,
|
||||
onSessionEnd: () {
|
||||
// debugPrint("Session done received on page whose tabId = $name");
|
||||
// debugPrint("key = $key");
|
||||
_tabIds.remove(name);
|
||||
_refreshTabs();
|
||||
},
|
||||
);
|
||||
_refreshTabs();
|
||||
final idx = _tabIds.length - 1;
|
||||
final idx = _tabMap.length - 1;
|
||||
_tabController.animateTo(idx);
|
||||
_fabRN.value = idx;
|
||||
}
|
||||
|
||||
void _refreshTabs() {
|
||||
_tabController = TabController(
|
||||
length: _tabIds.length,
|
||||
length: _tabMap.length,
|
||||
vsync: this,
|
||||
);
|
||||
setState(() {});
|
||||
|
||||
@@ -677,7 +677,15 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
Loggers.app.warning('$op failed', e, s);
|
||||
return ctx.showRoundDialog(
|
||||
title: l10n.error,
|
||||
child: Text(e.toString()),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(e.toString()),
|
||||
const SizedBox(height: 7),
|
||||
SimpleMarkdown(data: s.toString()),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => ctx.pop(),
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PopupMenu<T> extends StatelessWidget {
|
||||
final List<T> items;
|
||||
final Widget Function(T) builder;
|
||||
final void Function(T) onSelected;
|
||||
final Widget child;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final T? initialValue;
|
||||
|
||||
const PopupMenu({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.builder,
|
||||
required this.onSelected,
|
||||
this.child = UIs.popMenuChild,
|
||||
this.padding = const EdgeInsets.all(7),
|
||||
this.initialValue,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton<T>(
|
||||
itemBuilder: (_) =>
|
||||
items.map((e) => PopupMenuItem(value: e, child: builder(e))).toList(),
|
||||
onSelected: onSelected,
|
||||
initialValue: initialValue,
|
||||
padding: padding,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import '../../core/route.dart';
|
||||
import '../../core/utils/server.dart';
|
||||
import '../../data/model/pkg/upgrade_info.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import 'popup_menu.dart';
|
||||
|
||||
class ServerFuncBtnsTopRight extends StatelessWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
@@ -30,8 +29,9 @@ class ServerFuncBtnsTopRight extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenu<ServerFuncBtn>(
|
||||
items: ServerFuncBtn.values,
|
||||
builder: (e) => PopMenu.build(e, e.icon, e.toStr),
|
||||
items: ServerFuncBtn.values
|
||||
.map((e) => PopMenu.build(e, e.icon, e.toStr))
|
||||
.toList(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
onSelected: (val) => _onTapMoreBtns(val, spi, context),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user