diff --git a/lib/view/page/server/tab/content.dart b/lib/view/page/server/tab/content.dart index 8b3689fd..94c9aa02 100644 --- a/lib/view/page/server/tab/content.dart +++ b/lib/view/page/server/tab/content.dart @@ -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( diff --git a/lib/view/page/server/tab/tab.dart b/lib/view/page/server/tab/tab.dart index 5d187cfa..7af96dcd 100644 --- a/lib/view/page/server/tab/tab.dart +++ b/lib/view/page/server/tab/tab.dart @@ -143,7 +143,7 @@ class _ServerPageState extends State with AutomaticKeepAliveClientMi Widget _buildBodySmall({ required List 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)); diff --git a/lib/view/page/server/tab/utils.dart b/lib/view/page/server/tab/utils.dart index 781ecc3a..168edc00 100644 --- a/lib/view/page/server/tab/utils.dart +++ b/lib/view/page/server/tab/utils.dart @@ -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; } } } diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index eecec797..b5bd2b7f 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -21,8 +21,7 @@ class _SnippetListPageState extends State 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 with AutomaticKeepAli padding: const EdgeInsets.symmetric(horizontal: 9), gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: UIs.columnWidth, - childAspectRatio: _childAspectRatio, + mainAxisExtent: _desiredItemHeight, ), itemCount: filtered.length, itemBuilder: (context, index) { diff --git a/pubspec.lock b/pubspec.lock index 216841e9..e891a91c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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" diff --git a/pubspec.yaml b/pubspec.yaml index 68a565a0..b00c94d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: