mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-10-17 13:07:26 +02:00
feat: Dead simple account switcher
This commit is contained in:
parent
a2d37102a4
commit
710a55ddbc
@ -409,6 +409,10 @@ class ChatListController extends State<ChatList> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setActiveClient(int i) => setState(() {
|
||||||
|
Matrix.of(context).activeClient = i;
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Matrix.of(context).navigatorContext = context;
|
Matrix.of(context).navigatorContext = context;
|
||||||
|
@ -216,6 +216,20 @@ class ChatListView extends StatelessWidget {
|
|||||||
child: Icon(CupertinoIcons.chat_bubble),
|
child: Icon(CupertinoIcons.chat_bubble),
|
||||||
)
|
)
|
||||||
: null,
|
: 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
|
drawer: controller.spaces.isEmpty
|
||||||
? null
|
? null
|
||||||
: Drawer(
|
: Drawer(
|
||||||
|
@ -58,7 +58,7 @@ class Matrix extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
int _activeClient = 0;
|
int activeClient = 0;
|
||||||
Store store = Store();
|
Store store = Store();
|
||||||
BuildContext navigatorContext;
|
BuildContext navigatorContext;
|
||||||
|
|
||||||
@ -68,14 +68,11 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
bool get isMultiAccount => widget.clients.length > 1;
|
bool get isMultiAccount => widget.clients.length > 1;
|
||||||
|
|
||||||
set activeClient(int newActiveClient) =>
|
|
||||||
setState(() => _activeClient = newActiveClient);
|
|
||||||
|
|
||||||
int get _safeActiveClient {
|
int get _safeActiveClient {
|
||||||
if (_activeClient < 0 || _activeClient >= widget.clients.length) {
|
if (activeClient < 0 || activeClient >= widget.clients.length) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return _activeClient;
|
return activeClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
Client _loginClientCandidate;
|
Client _loginClientCandidate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user