diff --git a/lib/pages/chat_list.dart b/lib/pages/chat_list.dart index 53e677eb..4b0aa6ac 100644 --- a/lib/pages/chat_list.dart +++ b/lib/pages/chat_list.dart @@ -410,10 +410,10 @@ class ChatListController extends State { } } - void setActiveClient(int i) => setState(() { + void setActiveClient(Client client) => setState(() { _activeSpaceId = null; selectedRoomIds.clear(); - Matrix.of(context).activeClient = i - (displayBundles ? 1 : 0); + Matrix.of(context).setActiveClient(client); }); void setActiveBundle(String bundle) => setState(() { diff --git a/lib/pages/views/chat_list_view.dart b/lib/pages/views/chat_list_view.dart index 9cd1fc75..9b4f5755 100644 --- a/lib/pages/views/chat_list_view.dart +++ b/lib/pages/views/chat_list_view.dart @@ -25,9 +25,7 @@ class ChatListView extends StatelessWidget { List getBottomBarItems(BuildContext context) { final displayClients = Matrix.of(context).hasComplexBundles - ? Matrix.of(context).accountBundles[Matrix.of(context).activeBundle ?? - Matrix.of(context).client.accountBundles.first.name] ?? - [] + ? Matrix.of(context).currentBundle : Matrix.of(context).widget.clients; if (displayClients.isEmpty) { displayClients.addAll(Matrix.of(context).widget.clients); @@ -41,8 +39,7 @@ class ChatListView extends StatelessWidget { builder: (context, snapshot) { return InkWell( borderRadius: BorderRadius.circular(32), - onTap: () => controller.setActiveClient( - Matrix.of(context).getClientIndexByMatrixId(client.userID)), + onTap: () => controller.setActiveClient(client), onLongPress: () => controller.editBundlesForAccount(client.userID), child: Avatar( @@ -55,7 +52,7 @@ class ChatListView extends StatelessWidget { ); }).toList(); - if (controller.displayBundles) { + if (controller.displayBundles && false) { items.insert( 0, BottomNavigationBarItem( @@ -289,25 +286,79 @@ class ChatListView extends StatelessWidget { s.accountData != null && s.accountData .any((e) => e.type == accountBundlesType)))), - builder: (context, _) => SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: SizedBox( - width: max( - FluffyThemes.isColumnMode(context) - ? FluffyThemes.columnWidth - : MediaQuery.of(context).size.width, - Matrix.of(context).widget.clients.length * 84.0, - ), - child: BottomNavigationBar( - onTap: controller.setActiveClient, - currentIndex: Matrix.of(context).activeClient + - (controller.displayBundles ? 1 : 0), - showUnselectedLabels: false, - showSelectedLabels: true, - type: BottomNavigationBarType.shifting, - selectedItemColor: Theme.of(context).primaryColor, - items: getBottomBarItems(context), - ), + builder: (context, _) => Material( + color: Theme.of(context) + .bottomNavigationBarTheme + .backgroundColor, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Divider(height: 1), + Builder(builder: (context) { + final items = getBottomBarItems(context); + if (items.length == 1) { + return Padding( + padding: const EdgeInsets.all(7.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + items.single.icon, + Text(items.single.label), + ], + ), + ); + } + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: SizedBox( + width: max( + FluffyThemes.isColumnMode(context) + ? FluffyThemes.columnWidth + : MediaQuery.of(context).size.width, + Matrix.of(context).widget.clients.length * + 84.0, + ), + child: BottomNavigationBar( + elevation: 0, + onTap: (i) => controller.setActiveClient( + Matrix.of(context).currentBundle[i]), + currentIndex: Matrix.of(context) + .currentBundle + .indexWhere( + (client) => + client == + Matrix.of(context).client, + ), + showUnselectedLabels: false, + showSelectedLabels: true, + type: BottomNavigationBarType.shifting, + selectedItemColor: + Theme.of(context).primaryColor, + items: items, + ), + ), + ); + }), + if (controller.displayBundles) + Padding( + padding: const EdgeInsets.symmetric( + vertical: 4.0, + horizontal: 12, + ), + child: SizedBox( + width: double.infinity, + child: CupertinoSlidingSegmentedControl( + groupValue: Matrix.of(context).activeBundle, + onValueChanged: controller.setActiveBundle, + children: Map.fromEntries(Matrix.of(context) + .accountBundles + .keys + .map((bundle) => + MapEntry(bundle, Text(bundle)))), + ), + ), + ), + ], ), ), )