opt: adapt global scroll on mobile

This commit is contained in:
Kingtous 2022-09-28 21:07:44 +08:00
parent ff56753756
commit e42b543a42
2 changed files with 52 additions and 34 deletions

View File

@ -73,32 +73,47 @@ class _PeerCardState extends State<_PeerCard>
_menuPos = RelativeRect.fromLTRB(x, y, x, y); _menuPos = RelativeRect.fromLTRB(x, y, x, y);
_showPeerMenu(peer.id); _showPeerMenu(peer.id);
}, },
child: ListTile( child: Container(
contentPadding: const EdgeInsets.only(left: 12), // padding: EdgeInsets.only(left: 12, top: 8, bottom: 8),
subtitle: Text('${peer.username}@${peer.hostname}'), child: Row(
title: Row(children: [ children: [
getOnline(4, peer.online), Container(
Text(peer.alias.isEmpty ? formatID(peer.id) : peer.alias) width: 50,
]), height: 50,
leading: Container( decoration: BoxDecoration(
decoration: BoxDecoration( color: str2color('${peer.id}${peer.platform}', 0x7f),
color: str2color('${peer.id}${peer.platform}', 0x7f), borderRadius: BorderRadius.circular(4),
borderRadius: BorderRadius.circular(4), ),
padding: const EdgeInsets.all(6),
child: getPlatformImage(peer.platform)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(children: [
getOnline(4, peer.online),
Text(peer.alias.isEmpty
? formatID(peer.id)
: peer.alias)
]),
Text('${peer.username}@${peer.hostname}')
],
).paddingOnly(left: 8.0),
), ),
padding: const EdgeInsets.all(6), InkWell(
child: getPlatformImage(peer.platform)), child: const Padding(
trailing: InkWell( padding: EdgeInsets.all(12),
child: const Padding( child: Icon(Icons.more_vert)),
padding: EdgeInsets.all(12), onTapDown: (e) {
child: Icon(Icons.more_vert)), final x = e.globalPosition.dx;
onTapDown: (e) { final y = e.globalPosition.dy;
final x = e.globalPosition.dx; _menuPos = RelativeRect.fromLTRB(x, y, x, y);
final y = e.globalPosition.dy; },
_menuPos = RelativeRect.fromLTRB(x, y, x, y); onTap: () {
}, _showPeerMenu(peer.id);
onTap: () { })
_showPeerMenu(peer.id); ],
}), ),
))); )));
} }

View File

@ -66,15 +66,16 @@ class _ConnectionPageState extends State<ConnectionPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Provider.of<FfiModel>(context); Provider.of<FfiModel>(context);
return Column( return CustomScrollView(
mainAxisAlignment: MainAxisAlignment.start, slivers: [
mainAxisSize: MainAxisSize.max, SliverList(
crossAxisAlignment: CrossAxisAlignment.center, delegate: SliverChildListDelegate([
children: <Widget>[
_buildUpdateUI(), _buildUpdateUI(),
_buildRemoteIDTextField(), _buildRemoteIDTextField(),
Expanded( ])),
child: PeerTabPage( SliverFillRemaining(
hasScrollBody: false,
child: PeerTabPage(
tabs: [ tabs: [
translate('Recent Sessions'), translate('Recent Sessions'),
translate('Favorites'), translate('Favorites'),
@ -87,8 +88,10 @@ class _ConnectionPageState extends State<ConnectionPage> {
DiscoveredPeersView(), DiscoveredPeersView(),
const AddressBook(), const AddressBook(),
], ],
)), ),
]).marginOnly(top: 2, left: 10, right: 10); )
],
).marginOnly(top: 2, left: 10, right: 10);
} }
/// Callback for the connect button. /// Callback for the connect button.