diff --git a/lib/pages/chat_list.dart b/lib/pages/chat_list.dart index 78411034..413613a4 100644 --- a/lib/pages/chat_list.dart +++ b/lib/pages/chat_list.dart @@ -409,6 +409,10 @@ class ChatListController extends State { } } + void setActiveClient(int i) => setState(() { + Matrix.of(context).activeClient = i; + }); + @override Widget build(BuildContext context) { Matrix.of(context).navigatorContext = context; diff --git a/lib/pages/views/chat_list_view.dart b/lib/pages/views/chat_list_view.dart index 5e071581..197744e8 100644 --- a/lib/pages/views/chat_list_view.dart +++ b/lib/pages/views/chat_list_view.dart @@ -216,6 +216,20 @@ class ChatListView extends StatelessWidget { child: Icon(CupertinoIcons.chat_bubble), ) : 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(), + ) + : null, drawer: controller.spaces.isEmpty ? null : Drawer( diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 4c65ce98..ffe257af 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -58,7 +58,7 @@ class Matrix extends StatefulWidget { } class MatrixState extends State with WidgetsBindingObserver { - int _activeClient = 0; + int activeClient = 0; Store store = Store(); BuildContext navigatorContext; @@ -68,14 +68,11 @@ class MatrixState extends State with WidgetsBindingObserver { bool get isMultiAccount => widget.clients.length > 1; - set activeClient(int newActiveClient) => - setState(() => _activeClient = newActiveClient); - int get _safeActiveClient { - if (_activeClient < 0 || _activeClient >= widget.clients.length) { + if (activeClient < 0 || activeClient >= widget.clients.length) { return 0; } - return _activeClient; + return activeClient; } Client _loginClientCandidate;