reduced peer view type to one toggle, moved sorting button under peer view type

This commit is contained in:
NicKoehler 2023-03-07 19:27:39 +01:00
parent a04351baf4
commit a4ef60a250
No known key found for this signature in database
GPG Key ID: BAE01394EB51AC58

View File

@ -113,14 +113,19 @@ class _PeerTabPageState extends State<PeerTabPage>
offstage: !isDesktop, offstage: !isDesktop,
child: _createPeerViewTypeSwitch(context) child: _createPeerViewTypeSwitch(context)
.marginOnly(left: 13)), .marginOnly(left: 13)),
Offstage(
offstage: _hideSort,
child: PeerSortDropdown(),
)
], ],
), ),
), ),
), ),
Row(
children: [
Expanded(child: SizedBox()),
Offstage(
offstage: _hideSort,
child: PeerSortDropdown(),
),
],
),
_createPeersView(), _createPeersView(),
], ],
); );
@ -240,32 +245,32 @@ class _PeerTabPageState extends State<PeerTabPage>
Widget _createPeerViewTypeSwitch(BuildContext context) { Widget _createPeerViewTypeSwitch(BuildContext context) {
final textColor = Theme.of(context).textTheme.titleLarge?.color; final textColor = Theme.of(context).textTheme.titleLarge?.color;
final activeDeco = final activeDeco = BoxDecoration(
BoxDecoration(color: Theme.of(context).colorScheme.background); color: Theme.of(context).colorScheme.background,
return Row( borderRadius: BorderRadius.circular(5),
children: [PeerUiType.grid, PeerUiType.list] );
.map((type) => Obx( final types = [PeerUiType.grid, PeerUiType.list];
return Obx(
() => Container( () => Container(
padding: EdgeInsets.all(4.0), padding: EdgeInsets.all(4.0),
decoration: peerCardUiType.value == type ? activeDeco : null, decoration: activeDeco,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
final type = types.elementAt(
peerCardUiType.value == types.elementAt(0) ? 1 : 0);
await bind.setLocalFlutterConfig( await bind.setLocalFlutterConfig(
k: 'peer-card-ui-type', v: type.index.toString()); k: 'peer-card-ui-type', v: type.index.toString());
peerCardUiType.value = type; peerCardUiType.value = type;
}, },
child: Icon( child: Icon(
type == PeerUiType.grid peerCardUiType.value == PeerUiType.grid
? Icons.grid_view_rounded ? Icons.list_rounded
: Icons.list, : Icons.grid_view_rounded,
size: 18, size: 18,
color: color: textColor,
peerCardUiType.value == type ? textColor : textColor
?..withOpacity(0.5),
)), )),
), ),
))
.toList(),
); );
} }
@ -441,7 +446,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DropdownButton<String>( return DropdownButton<String>(
value: _sortType, value: _sortType == "" ? 'id' : _sortType,
elevation: 16, elevation: 16,
underline: SizedBox(), underline: SizedBox(),
onChanged: (v) { onChanged: (v) {