fix: Bottombar design

This commit is contained in:
Christian Pauly 2021-09-19 12:28:53 +02:00
parent f879708d42
commit e227bb9200
2 changed files with 78 additions and 27 deletions

View File

@ -410,10 +410,10 @@ class ChatListController extends State<ChatList> {
}
}
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(() {

View File

@ -25,9 +25,7 @@ class ChatListView extends StatelessWidget {
List<BottomNavigationBarItem> 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,26 +286,80 @@ class ChatListView extends StatelessWidget {
s.accountData != null &&
s.accountData
.any((e) => e.type == accountBundlesType)))),
builder: (context, _) => SingleChildScrollView(
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,
Matrix.of(context).widget.clients.length *
84.0,
),
child: BottomNavigationBar(
onTap: controller.setActiveClient,
currentIndex: Matrix.of(context).activeClient +
(controller.displayBundles ? 1 : 0),
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: getBottomBarItems(context),
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)))),
),
),
),
],
),
),
)
: null,