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