mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-22 17:20:43 +01:00
feat: Nicer bottombar
This commit is contained in:
parent
a973f8d371
commit
d619fefa62
@ -412,7 +412,8 @@ class ChatListController extends State<ChatList> {
|
|||||||
void setActiveClient(int i) => setState(() {
|
void setActiveClient(int i) => setState(() {
|
||||||
_activeSpaceId = null;
|
_activeSpaceId = null;
|
||||||
selectedRoomIds.clear();
|
selectedRoomIds.clear();
|
||||||
Matrix.of(context).activeClient = i;
|
Matrix.of(context).activeClient =
|
||||||
|
i - (Matrix.of(context).hasComplexBundles ? 1 : 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:fluffychat/widgets/avatar.dart';
|
import 'package:fluffychat/widgets/avatar.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:fluffychat/pages/chat_list.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);
|
const ChatListView(this.controller, {Key key}) : super(key: key);
|
||||||
|
|
||||||
|
List<BottomNavigationBarItem> getBottomBarItems(BuildContext context) {
|
||||||
|
final items = Matrix.of(context)
|
||||||
|
.widget
|
||||||
|
.clients
|
||||||
|
.map((client) => BottomNavigationBarItem(
|
||||||
|
label: client.userID,
|
||||||
|
icon: FutureBuilder<Profile>(
|
||||||
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamBuilder<Object>(
|
return StreamBuilder<Object>(
|
||||||
@ -217,17 +256,24 @@ class ChatListView extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
bottomNavigationBar: Matrix.of(context).isMultiAccount
|
bottomNavigationBar: Matrix.of(context).isMultiAccount
|
||||||
? BottomNavigationBar(
|
? 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,
|
onTap: controller.setActiveClient,
|
||||||
currentIndex: Matrix.of(context).activeClient,
|
currentIndex: Matrix.of(context).activeClient +
|
||||||
items: Matrix.of(context)
|
(Matrix.of(context).hasComplexBundles ? 1 : 0),
|
||||||
.widget
|
showUnselectedLabels: false,
|
||||||
.clients
|
showSelectedLabels: true,
|
||||||
.map((client) => BottomNavigationBarItem(
|
type: BottomNavigationBarType.shifting,
|
||||||
label: client.userID,
|
selectedItemColor: Theme.of(context).primaryColor,
|
||||||
icon: Icon(Icons.account_box_outlined),
|
items: getBottomBarItems(context),
|
||||||
))
|
),
|
||||||
.toList(),
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
drawer: controller.spaces.isEmpty
|
drawer: controller.spaces.isEmpty
|
||||||
@ -235,7 +281,7 @@ class ChatListView extends StatelessWidget {
|
|||||||
: Drawer(
|
: Drawer(
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: controller.spaces.length + 1,
|
itemCount: controller.spaces.length,
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user