update peer view type options

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
Sahil Yeole 2023-10-24 22:33:51 +05:30
parent 94e51a8041
commit d9e1b2df7f

View File

@ -216,21 +216,24 @@ 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 types = [PeerUiType.grid, PeerUiType.list]; final types = [PeerUiType.grid, PeerUiType.tile, PeerUiType.list];
return Obx(() => _hoverAction( return Obx(() => _hoverAction(
context: context, context: context,
onTap: () async { onTap: () async {
final type = types final currentIndex = types.indexOf(peerCardUiType.value);
.elementAt(peerCardUiType.value == types.elementAt(0) ? 1 : 0); final newIndex = (currentIndex + 1) % types.length; // cycle through types
final type = types[newIndex];
await bind.setLocalFlutterOption( await bind.setLocalFlutterOption(
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: Tooltip( child: Tooltip(
message: peerCardUiType.value == PeerUiType.grid message: peerCardUiType.value == PeerUiType.grid
? translate('List View') ? translate('Small tiles')
: translate('Grid View'), : peerCardUiType.value == PeerUiType.tile
? translate('List')
: translate('Big tiles'),
child: Icon( child: Icon(
peerCardUiType.value == PeerUiType.grid peerCardUiType.value == PeerUiType.grid
? Icons.view_list_rounded ? Icons.view_list_rounded