diff --git a/lib/pages/chat_list.dart b/lib/pages/chat_list.dart index cb66f725..6260205a 100644 --- a/lib/pages/chat_list.dart +++ b/lib/pages/chat_list.dart @@ -412,7 +412,8 @@ class ChatListController extends State { void setActiveClient(int i) => setState(() { _activeSpaceId = null; selectedRoomIds.clear(); - Matrix.of(context).activeClient = i; + Matrix.of(context).activeClient = + i - (Matrix.of(context).hasComplexBundles ? 1 : 0); }); @override diff --git a/lib/pages/views/chat_list_view.dart b/lib/pages/views/chat_list_view.dart index 197744e8..0490e548 100644 --- a/lib/pages/views/chat_list_view.dart +++ b/lib/pages/views/chat_list_view.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:fluffychat/widgets/avatar.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/pages/chat_list.dart'; @@ -17,6 +19,43 @@ class ChatListView extends StatelessWidget { const ChatListView(this.controller, {Key key}) : super(key: key); + List getBottomBarItems(BuildContext context) { + final items = Matrix.of(context) + .widget + .clients + .map((client) => BottomNavigationBarItem( + label: client.userID, + icon: FutureBuilder( + future: client.ownProfile, + builder: (context, snapshot) { + return Avatar( + snapshot.data?.avatarUrl, + snapshot.data?.displayName ?? client.userID.localpart, + size: 32, + ); + }), + )) + .toList(); + + if (Matrix.of(context).hasComplexBundles) { + items.insert( + 0, + BottomNavigationBarItem( + label: 'Bundles', + icon: PopupMenuButton( + icon: Icon( + Icons.menu, + color: Theme.of(context).textTheme.bodyText1.color, + ), + itemBuilder: (_) => [ + PopupMenuItem(child: Text('Arbeit')), + PopupMenuItem(child: Text('Privat')), + ], + ))); + } + return items; + } + @override Widget build(BuildContext context) { return StreamBuilder( @@ -217,17 +256,24 @@ class ChatListView extends StatelessWidget { ) : null, bottomNavigationBar: Matrix.of(context).isMultiAccount - ? BottomNavigationBar( - onTap: controller.setActiveClient, - currentIndex: Matrix.of(context).activeClient, - items: Matrix.of(context) - .widget - .clients - .map((client) => BottomNavigationBarItem( - label: client.userID, - icon: Icon(Icons.account_box_outlined), - )) - .toList(), + ? SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: SizedBox( + width: max( + MediaQuery.of(context).size.width, + Matrix.of(context).widget.clients.length * 84.0, + ), + child: BottomNavigationBar( + onTap: controller.setActiveClient, + currentIndex: Matrix.of(context).activeClient + + (Matrix.of(context).hasComplexBundles ? 1 : 0), + showUnselectedLabels: false, + showSelectedLabels: true, + type: BottomNavigationBarType.shifting, + selectedItemColor: Theme.of(context).primaryColor, + items: getBottomBarItems(context), + ), + ), ) : null, drawer: controller.spaces.isEmpty @@ -235,7 +281,7 @@ class ChatListView extends StatelessWidget { : Drawer( child: SafeArea( child: ListView.builder( - itemCount: controller.spaces.length + 1, + itemCount: controller.spaces.length, itemBuilder: (context, i) { if (i == 0) { return ListTile(