From a4ef60a250bf5cc40f4d949e72160fbdc2867d5a Mon Sep 17 00:00:00 2001 From: NicKoehler Date: Tue, 7 Mar 2023 19:27:39 +0100 Subject: [PATCH] reduced peer view type to one toggle, moved sorting button under peer view type --- flutter/lib/common/widgets/peer_tab_page.dart | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/flutter/lib/common/widgets/peer_tab_page.dart b/flutter/lib/common/widgets/peer_tab_page.dart index d0ab51058..b0ad4138a 100644 --- a/flutter/lib/common/widgets/peer_tab_page.dart +++ b/flutter/lib/common/widgets/peer_tab_page.dart @@ -113,14 +113,19 @@ class _PeerTabPageState extends State offstage: !isDesktop, child: _createPeerViewTypeSwitch(context) .marginOnly(left: 13)), - Offstage( - offstage: _hideSort, - child: PeerSortDropdown(), - ) ], ), ), ), + Row( + children: [ + Expanded(child: SizedBox()), + Offstage( + offstage: _hideSort, + child: PeerSortDropdown(), + ), + ], + ), _createPeersView(), ], ); @@ -240,32 +245,32 @@ class _PeerTabPageState extends State Widget _createPeerViewTypeSwitch(BuildContext context) { final textColor = Theme.of(context).textTheme.titleLarge?.color; - final activeDeco = - BoxDecoration(color: Theme.of(context).colorScheme.background); - return Row( - children: [PeerUiType.grid, PeerUiType.list] - .map((type) => Obx( - () => Container( - padding: EdgeInsets.all(4.0), - decoration: peerCardUiType.value == type ? activeDeco : null, - child: InkWell( - onTap: () async { - await bind.setLocalFlutterConfig( - k: 'peer-card-ui-type', v: type.index.toString()); - peerCardUiType.value = type; - }, - child: Icon( - type == PeerUiType.grid - ? Icons.grid_view_rounded - : Icons.list, - size: 18, - color: - peerCardUiType.value == type ? textColor : textColor - ?..withOpacity(0.5), - )), - ), - )) - .toList(), + final activeDeco = BoxDecoration( + color: Theme.of(context).colorScheme.background, + borderRadius: BorderRadius.circular(5), + ); + final types = [PeerUiType.grid, PeerUiType.list]; + + return Obx( + () => Container( + padding: EdgeInsets.all(4.0), + decoration: activeDeco, + child: InkWell( + onTap: () async { + final type = types.elementAt( + peerCardUiType.value == types.elementAt(0) ? 1 : 0); + await bind.setLocalFlutterConfig( + k: 'peer-card-ui-type', v: type.index.toString()); + peerCardUiType.value = type; + }, + child: Icon( + peerCardUiType.value == PeerUiType.grid + ? Icons.list_rounded + : Icons.grid_view_rounded, + size: 18, + color: textColor, + )), + ), ); } @@ -441,7 +446,7 @@ class _PeerSortDropdownState extends State { @override Widget build(BuildContext context) { return DropdownButton( - value: _sortType, + value: _sortType == "" ? 'id' : _sortType, elevation: 16, underline: SizedBox(), onChanged: (v) {