mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: ui
This commit is contained in:
@@ -26,9 +26,10 @@ extension on _ServerPageState {
|
||||
|
||||
Widget _buildTopRightWidget(Server s) {
|
||||
final (child, onTap) = switch (s.conn) {
|
||||
ServerConn.connecting ||
|
||||
ServerConn.loading ||
|
||||
ServerConn.connected => (SizedLoading(23, strokeWidth: 3, padding: 5), null),
|
||||
ServerConn.connecting || ServerConn.loading || ServerConn.connected => (
|
||||
SizedLoading(_ServerPageState._kCardHeightMin, strokeWidth: 3, padding: 5),
|
||||
null,
|
||||
),
|
||||
ServerConn.failed => (
|
||||
const Icon(Icons.refresh, size: 21, color: Colors.grey),
|
||||
() {
|
||||
@@ -55,7 +56,7 @@ extension on _ServerPageState {
|
||||
}
|
||||
|
||||
Widget _buildTopRightText(Server s) {
|
||||
final hasErr = s.conn == ServerConn.failed && s.status.err != null;
|
||||
final hasErr = s.status.err != null;
|
||||
final str = s._getTopRightStr(s.spi);
|
||||
if (str == null) return UIs.placeholder;
|
||||
return GestureDetector(
|
||||
|
||||
@@ -143,7 +143,7 @@ class _ServerPageState extends State<ServerPage> with AutomaticKeepAliveClientMi
|
||||
|
||||
Widget _buildBodySmall({
|
||||
required List<String> filtered,
|
||||
EdgeInsets? padding = const EdgeInsets.fromLTRB(7, 0, 7, 7),
|
||||
EdgeInsets? padding = const EdgeInsets.fromLTRB(0, 0, 5, 7),
|
||||
}) {
|
||||
if (filtered.isEmpty) {
|
||||
return Center(child: Text(libL10n.empty, textAlign: TextAlign.center));
|
||||
|
||||
@@ -9,19 +9,13 @@ extension _Actions on _ServerPageState {
|
||||
// key: ValueKey(srv.spi.id),
|
||||
// args: SpiRequiredArgs(srv.spi),
|
||||
// ));
|
||||
ServerDetailPage.route.go(
|
||||
context,
|
||||
SpiRequiredArgs(srv.spi),
|
||||
);
|
||||
ServerDetailPage.route.go(context, SpiRequiredArgs(srv.spi));
|
||||
} else {
|
||||
// _splitViewCtrl.replace(ServerEditPage(
|
||||
// key: ValueKey(srv.spi.id),
|
||||
// args: SpiRequiredArgs(srv.spi),
|
||||
// ));
|
||||
ServerEditPage.route.go(
|
||||
context,
|
||||
args: SpiRequiredArgs(srv.spi),
|
||||
);
|
||||
ServerEditPage.route.go(context, args: SpiRequiredArgs(srv.spi));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +23,9 @@ extension _Actions on _ServerPageState {
|
||||
if (srv.conn == ServerConn.finished) {
|
||||
final id = srv.spi.id;
|
||||
final cardStatus = _getCardNoti(id);
|
||||
cardStatus.value = cardStatus.value.copyWith(
|
||||
flip: !cardStatus.value.flip,
|
||||
);
|
||||
cardStatus.value = cardStatus.value.copyWith(flip: !cardStatus.value.flip);
|
||||
} else {
|
||||
ServerEditPage.route.go(
|
||||
context,
|
||||
args: SpiRequiredArgs(srv.spi),
|
||||
);
|
||||
ServerEditPage.route.go(context, args: SpiRequiredArgs(srv.spi));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,17 +46,10 @@ extension _Operation on _ServerPageState {
|
||||
_askFor(
|
||||
func: () async {
|
||||
if (Stores.setting.showSuspendTip.fetch()) {
|
||||
await context.showRoundDialog(
|
||||
title: libL10n.attention,
|
||||
child: Text(l10n.suspendTip),
|
||||
);
|
||||
await context.showRoundDialog(title: libL10n.attention, child: Text(l10n.suspendTip));
|
||||
Stores.setting.showSuspendTip.put(false);
|
||||
}
|
||||
srv.client?.execWithPwd(
|
||||
ShellFunc.suspend.exec(srv.spi.id),
|
||||
context: context,
|
||||
id: srv.id,
|
||||
);
|
||||
srv.client?.execWithPwd(ShellFunc.suspend.exec(srv.spi.id), context: context, id: srv.id);
|
||||
},
|
||||
typ: l10n.suspend,
|
||||
name: srv.spi.name,
|
||||
@@ -76,11 +58,7 @@ extension _Operation on _ServerPageState {
|
||||
|
||||
void _onTapShutdown(Server srv) {
|
||||
_askFor(
|
||||
func: () => srv.client?.execWithPwd(
|
||||
ShellFunc.shutdown.exec(srv.spi.id),
|
||||
context: context,
|
||||
id: srv.id,
|
||||
),
|
||||
func: () => srv.client?.execWithPwd(ShellFunc.shutdown.exec(srv.spi.id), context: context, id: srv.id),
|
||||
typ: l10n.shutdown,
|
||||
name: srv.spi.name,
|
||||
);
|
||||
@@ -88,11 +66,7 @@ extension _Operation on _ServerPageState {
|
||||
|
||||
void _onTapReboot(Server srv) {
|
||||
_askFor(
|
||||
func: () => srv.client?.execWithPwd(
|
||||
ShellFunc.reboot.exec(srv.spi.id),
|
||||
context: context,
|
||||
id: srv.id,
|
||||
),
|
||||
func: () => srv.client?.execWithPwd(ShellFunc.reboot.exec(srv.spi.id), context: context, id: srv.id),
|
||||
typ: l10n.reboot,
|
||||
name: srv.spi.name,
|
||||
);
|
||||
@@ -100,15 +74,9 @@ extension _Operation on _ServerPageState {
|
||||
|
||||
void _onTapEdit(Server srv) {
|
||||
if (srv.canViewDetails) {
|
||||
ServerDetailPage.route.go(
|
||||
context,
|
||||
SpiRequiredArgs(srv.spi),
|
||||
);
|
||||
ServerDetailPage.route.go(context, SpiRequiredArgs(srv.spi));
|
||||
} else {
|
||||
ServerEditPage.route.go(
|
||||
context,
|
||||
args: SpiRequiredArgs(srv.spi),
|
||||
);
|
||||
ServerEditPage.route.go(context, args: SpiRequiredArgs(srv.spi));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,11 +108,7 @@ extension _Utils on _ServerPageState {
|
||||
return _ServerPageState._kCardHeightNormal;
|
||||
}
|
||||
|
||||
void _askFor({
|
||||
required void Function() func,
|
||||
required String typ,
|
||||
required String name,
|
||||
}) {
|
||||
void _askFor({required void Function() func, required String typ, required String name}) {
|
||||
context.showRoundDialog(
|
||||
title: libL10n.attention,
|
||||
child: Text(libL10n.askContinue('$typ ${l10n.server}($name)')),
|
||||
@@ -157,10 +121,8 @@ extension _Utils on _ServerPageState {
|
||||
);
|
||||
}
|
||||
|
||||
_CardNotifier _getCardNoti(String id) => _cardsStatus.putIfAbsent(
|
||||
id,
|
||||
() => _CardNotifier(const _CardStatus()),
|
||||
);
|
||||
_CardNotifier _getCardNoti(String id) =>
|
||||
_cardsStatus.putIfAbsent(id, () => _CardNotifier(const _CardStatus()));
|
||||
|
||||
void _updateOffset() {
|
||||
if (!Stores.setting.fullScreenJitter.fetch()) return;
|
||||
@@ -190,6 +152,9 @@ extension _Utils on _ServerPageState {
|
||||
|
||||
extension _ServerX on Server {
|
||||
String? _getTopRightStr(Spi spi) {
|
||||
if (status.err != null) {
|
||||
return l10n.viewErr;
|
||||
}
|
||||
switch (conn) {
|
||||
case ServerConn.disconnected:
|
||||
return null;
|
||||
@@ -225,7 +190,7 @@ extension _ServerX on Server {
|
||||
final upTime = status.more[StatusCmdType.uptime];
|
||||
final items = [
|
||||
cmdTemp ?? (temperatureVal != null ? '${temperatureVal.toStringAsFixed(1)}°C' : null),
|
||||
upTime
|
||||
upTime,
|
||||
];
|
||||
final str = items.where((e) => e != null && e.isNotEmpty).join(' | ');
|
||||
if (str.isEmpty) return libL10n.empty;
|
||||
@@ -237,7 +202,7 @@ extension _ServerX on Server {
|
||||
case ServerConn.connecting:
|
||||
return null;
|
||||
case ServerConn.failed:
|
||||
return status.err != null ? l10n.viewErr : libL10n.fail;
|
||||
return libL10n.fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ class _SnippetListPageState extends State<SnippetListPage> with AutomaticKeepAli
|
||||
final _tag = ''.vn;
|
||||
final _splitViewCtrl = SplitViewController();
|
||||
|
||||
static final _desiredItemHeight = isDesktop ? 113 : 97;
|
||||
static final _childAspectRatio = UIs.columnWidth / _desiredItemHeight;
|
||||
static const _desiredItemHeight = 77.0;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -92,7 +91,7 @@ class _SnippetListPageState extends State<SnippetListPage> with AutomaticKeepAli
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9),
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: UIs.columnWidth,
|
||||
childAspectRatio: _childAspectRatio,
|
||||
mainAxisExtent: _desiredItemHeight,
|
||||
),
|
||||
itemCount: filtered.length,
|
||||
itemBuilder: (context, index) {
|
||||
|
||||
@@ -481,8 +481,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "v1.0.313"
|
||||
resolved-ref: "234dc4cd1f4c7bbcdb12834dc674f65c243dd8e4"
|
||||
ref: "v1.0.314"
|
||||
resolved-ref: "306b1ca5b7df6981ed3d09afbf97c6b3054c9d21"
|
||||
url: "https://github.com/lppcg/fl_lib"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
||||
@@ -62,7 +62,7 @@ dependencies:
|
||||
fl_lib:
|
||||
git:
|
||||
url: https://github.com/lppcg/fl_lib
|
||||
ref: v1.0.313
|
||||
ref: v1.0.314
|
||||
|
||||
dependency_overrides:
|
||||
# webdav_client_plus:
|
||||
|
||||
Reference in New Issue
Block a user