fix: ssh tab page UI (#555)

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-08-27 17:20:47 +08:00
committed by GitHub
parent eb83d05c81
commit 4f9ee7781f
3 changed files with 33 additions and 50 deletions

View File

@@ -315,16 +315,25 @@ class _ServerPageState extends State<ServerPage>
} }
} }
final height = _calcCardHeight(srv.conn, cardStatus.value.flip);
return AnimatedContainer( return AnimatedContainer(
duration: const Duration(milliseconds: 377), duration: const Duration(milliseconds: 377),
curve: Curves.fastEaseInToSlowEaseOut, curve: Curves.fastEaseInToSlowEaseOut,
height: _calcCardHeight(srv.conn, cardStatus.value.flip), height: height,
// Use [OverflowBox] to dismiss the warning of [Column] overflow.
child: OverflowBox(
// If `height == _kCardHeightMin`, the `maxHeight` will be ignored.
//
// You can comment the `maxHeight` then connect&disconnect the server
// to see the difference.
maxHeight: height != _kCardHeightMin ? height : null,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: children, children: children,
), ),
),
); );
}, },
); );

View File

@@ -90,45 +90,23 @@ class _SSHTabPageState extends State<SSHTabPage>
child: Text(libL10n.empty, textAlign: TextAlign.center), child: Text(libL10n.empty, textAlign: TextAlign.center),
); );
} }
return Wrap(
final ratio = context.media.size.aspectRatio; children: order.map((id) {
return GridView.builder( final spi = ServerProvider.pick(id: id)?.value.spi;
padding: const EdgeInsets.all(7),
cacheExtent: 50,
itemBuilder: (context, idx) {
final spi = ServerProvider.pick(id: order[idx])?.value.spi;
if (spi == null) return UIs.placeholder; if (spi == null) return UIs.placeholder;
return CardX( return CardX(
child: InkWell( child: InkWell(
onTap: () => _onTapInitCard(spi), onTap: () => _onTapInitCard(spi),
child: Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(left: 17, right: 7),
child: Row(
children: [
Expanded(
child: Text( child: Text(
spi.name, spi.name,
style: UIs.text18, style: UIs.text18,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ).paddingSymmetric(horizontal: 13, vertical: 7),
),
const Icon(Icons.chevron_right)
],
),
),
),
);
},
itemCount: ServerProvider.servers.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3 * (ratio / (9 / 16)),
crossAxisSpacing: 3,
mainAxisSpacing: 3,
), ),
); );
}).toList(),
).paddingSymmetric(horizontal: 13);
}), }),
); );
} }
@@ -262,20 +240,20 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(color: color), style: TextStyle(color: color),
softWrap: false, softWrap: false,
textAlign: TextAlign.center, textAlign: TextAlign.right,
textWidthBasis: TextWidthBasis.parent, textWidthBasis: TextWidthBasis.parent,
); );
final Widget btn; final Widget btn;
if (selected) { if (selected) {
btn = Row( btn = Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Btn.icon( Btn.icon(
icon: Icon(MingCute.close_circle_fill, color: color, size: 17), icon: Icon(MingCute.close_circle_fill, color: color, size: 17),
onTap: () => onClose(name), onTap: () => onClose(name),
padding: null, padding: null,
), ),
SizedBox(width: kNarrowWidth - 10, child: text), SizedBox(width: kNarrowWidth - 15, child: text),
], ],
); );
} else { } else {
@@ -284,9 +262,11 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
child = AnimatedContainer( child = AnimatedContainer(
width: selected ? kWideWidth : kNarrowWidth, width: selected ? kWideWidth : kNarrowWidth,
duration: Durations.medium3, duration: Durations.medium3,
padding: selected ? const EdgeInsets.symmetric(horizontal: 7) : null,
curve: Curves.fastEaseInToSlowEaseOut, curve: Curves.fastEaseInToSlowEaseOut,
child: OverflowBox(
maxWidth: selected ? kWideWidth : null,
child: btn, child: btn,
),
); );
} }

View File

@@ -7,8 +7,6 @@ PODS:
- local_auth_darwin (0.0.1): - local_auth_darwin (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- mobile_scanner (5.1.1):
- FlutterMacOS
- package_info_plus (0.0.1): - package_info_plus (0.0.1):
- FlutterMacOS - FlutterMacOS
- path_provider_foundation (0.0.1): - path_provider_foundation (0.0.1):
@@ -33,7 +31,6 @@ DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`) - FlutterMacOS (from `Flutter/ephemeral`)
- icloud_storage (from `Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos`) - icloud_storage (from `Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos`)
- local_auth_darwin (from `Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin`) - local_auth_darwin (from `Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin`)
- mobile_scanner (from `Flutter/ephemeral/.symlinks/plugins/mobile_scanner/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
@@ -52,8 +49,6 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos :path: Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos
local_auth_darwin: local_auth_darwin:
:path: Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin :path: Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin
mobile_scanner:
:path: Flutter/ephemeral/.symlinks/plugins/mobile_scanner/macos
package_info_plus: package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
path_provider_foundation: path_provider_foundation:
@@ -76,7 +71,6 @@ SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
icloud_storage: 33b05299e26d1391d724da8d62860e702380a1cd icloud_storage: 33b05299e26d1391d724da8d62860e702380a1cd
local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3 local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3
mobile_scanner: 1efac1e53c294b24e3bb55bcc7f4deee0233a86b
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38