Merge branch 'braid/spaces-list-fix' into 'main'
fix: space bottom bar with group/DM separation See merge request famedly/fluffychat!858
This commit is contained in:
commit
84fb5be302
|
@ -80,9 +80,11 @@ class _ChatListViewBodyState extends State<ChatListViewBody> {
|
||||||
.shouldShowStoriesHeader(context);
|
.shouldShowStoriesHeader(context);
|
||||||
child = ListView.builder(
|
child = ListView.builder(
|
||||||
key: ValueKey(Matrix.of(context).client.userID.toString() +
|
key: ValueKey(Matrix.of(context).client.userID.toString() +
|
||||||
widget.controller.activeSpaceId.toString()),
|
widget.controller.activeSpaceId.toString() +
|
||||||
|
widget.controller.activeSpacesEntry.runtimeType.toString()),
|
||||||
controller: widget.controller.scrollController,
|
controller: widget.controller.scrollController,
|
||||||
itemCount: rooms.length + (displayStoriesHeader ? 1 : 0),
|
// add +1 space below in order to properly scroll below the spaces bar
|
||||||
|
itemCount: rooms.length + (displayStoriesHeader ? 2 : 1),
|
||||||
itemBuilder: (BuildContext context, int i) {
|
itemBuilder: (BuildContext context, int i) {
|
||||||
if (displayStoriesHeader) {
|
if (displayStoriesHeader) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -90,6 +92,9 @@ class _ChatListViewBodyState extends State<ChatListViewBody> {
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
if (i >= rooms.length) {
|
||||||
|
return const ListTile();
|
||||||
|
}
|
||||||
return ChatListItem(
|
return ChatListItem(
|
||||||
rooms[i],
|
rooms[i],
|
||||||
selected: widget.controller.selectedRoomIds.contains(rooms[i].id),
|
selected: widget.controller.selectedRoomIds.contains(rooms[i].id),
|
||||||
|
|
|
@ -94,11 +94,10 @@ class _SpacesBottomNavigation extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final currentIndex = controller.activeSpaceId == null
|
final currentIndex = controller.spacesEntries.indexWhere((space) =>
|
||||||
? 1
|
controller.activeSpacesEntry.runtimeType == space.runtimeType &&
|
||||||
: controller.spaces
|
(controller.activeSpaceId == space.getSpace(context)?.id)) +
|
||||||
.indexWhere((space) => controller.activeSpaceId == space.id) +
|
1;
|
||||||
2;
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
height: 56,
|
height: 56,
|
||||||
|
@ -110,14 +109,9 @@ class _SpacesBottomNavigation extends StatelessWidget {
|
||||||
currentIndex: currentIndex,
|
currentIndex: currentIndex,
|
||||||
onTap: (i) => i == 0
|
onTap: (i) => i == 0
|
||||||
? controller.expandSpaces()
|
? controller.expandSpaces()
|
||||||
: i == 1
|
|
||||||
? controller.setActiveSpacesEntry(
|
|
||||||
context,
|
|
||||||
null,
|
|
||||||
)
|
|
||||||
: controller.setActiveSpacesEntry(
|
: controller.setActiveSpacesEntry(
|
||||||
context,
|
context,
|
||||||
controller.spacesEntries[i],
|
controller.spacesEntries[i - 1],
|
||||||
),
|
),
|
||||||
selectedItemColor: Theme.of(context).colorScheme.primary,
|
selectedItemColor: Theme.of(context).colorScheme.primary,
|
||||||
items: [
|
items: [
|
||||||
|
|
|
@ -13,11 +13,9 @@ class SpacesDrawer extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final currentIndex = controller.activeSpaceId == null
|
final currentIndex = controller.spacesEntries.indexWhere((space) =>
|
||||||
? 0
|
controller.activeSpacesEntry.runtimeType == space.runtimeType &&
|
||||||
: controller.spaces
|
(controller.activeSpaceId == space.getSpace(context)?.id));
|
||||||
.indexWhere((space) => controller.activeSpaceId == space.id) +
|
|
||||||
1;
|
|
||||||
|
|
||||||
final Map<SpacesEntry, dynamic> spaceHierarchy =
|
final Map<SpacesEntry, dynamic> spaceHierarchy =
|
||||||
Map.fromEntries(controller.spacesEntries.map((e) => MapEntry(e, null)));
|
Map.fromEntries(controller.spacesEntries.map((e) => MapEntry(e, null)));
|
||||||
|
@ -30,35 +28,27 @@ class SpacesDrawer extends StatelessWidget {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
children: List.generate(
|
children: List.generate(spaceHierarchy.length, (index) {
|
||||||
spaceHierarchy.length,
|
|
||||||
(index) {
|
|
||||||
if (index == 0) {
|
|
||||||
return ListTile(
|
|
||||||
selected: currentIndex == index,
|
|
||||||
leading: const Icon(Icons.keyboard_arrow_down),
|
|
||||||
title: Text(L10n.of(context)!.allChats),
|
|
||||||
onTap: () => controller.setActiveSpacesEntry(
|
|
||||||
context,
|
|
||||||
null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
final space = spaceHierarchy.keys.toList()[index];
|
final space = spaceHierarchy.keys.toList()[index];
|
||||||
final room = space.getSpace(context)!;
|
final room = space.getSpace(context);
|
||||||
|
final active = currentIndex == index;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
selected: currentIndex == index,
|
selected: active,
|
||||||
leading: Avatar(
|
leading: index == 0
|
||||||
|
? const Icon(Icons.keyboard_arrow_down)
|
||||||
|
: room == null
|
||||||
|
? space.getIcon(active)
|
||||||
|
: Avatar(
|
||||||
mxContent: room.avatar,
|
mxContent: room.avatar,
|
||||||
name: space.getName(context),
|
name: space.getName(context),
|
||||||
size: 24,
|
size: 24,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
title: Text(space.getName(context)),
|
title: Text(space.getName(context)),
|
||||||
subtitle: room.topic.isEmpty
|
subtitle: room?.topic.isEmpty ?? true
|
||||||
? null
|
? null
|
||||||
: Tooltip(
|
: Tooltip(
|
||||||
message: room.topic,
|
message: room!.topic,
|
||||||
child: Text(
|
child: Text(
|
||||||
room.topic.replaceAll('\n', ' '),
|
room.topic.replaceAll('\n', ' '),
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
|
@ -69,15 +59,15 @@ class SpacesDrawer extends StatelessWidget {
|
||||||
context,
|
context,
|
||||||
space,
|
space,
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: room != null
|
||||||
|
? IconButton(
|
||||||
icon: const Icon(Icons.edit),
|
icon: const Icon(Icons.edit),
|
||||||
tooltip: L10n.of(context)!.edit,
|
tooltip: L10n.of(context)!.edit,
|
||||||
onPressed: () => controller.editSpace(context, room.id),
|
onPressed: () => controller.editSpace(context, room.id),
|
||||||
),
|
)
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}),
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue