parent
7007c9af89
commit
b55a6e0e83
1 changed files with 42 additions and 22 deletions
|
|
@ -4,20 +4,28 @@ import "package:navigation_rail_m3e/navigation_rail_m3e.dart";
|
|||
import "package:nexus/models/room.dart";
|
||||
import "package:nexus/widgets/avatar_or_hash.dart";
|
||||
|
||||
extension RoomDestination on Room {
|
||||
NavigationRailM3EDestination toDestination({
|
||||
required bool isDm,
|
||||
String? label,
|
||||
Widget? icon,
|
||||
}) => NavigationRailM3EDestination(
|
||||
label: label ?? metadata?.name ?? "Unnamed Room",
|
||||
badgeCount: switch (metadata?.unreadNotifications) {
|
||||
0 || null => metadata?.unreadMessages == 0 ? null : 0,
|
||||
int unread => unread,
|
||||
},
|
||||
icon:
|
||||
icon ??
|
||||
AvatarOrHash(
|
||||
metadata?.avatar,
|
||||
metadata?.name ?? "Unnamed Room",
|
||||
fallback: isDm ? null : const Icon(Icons.numbers),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
extension RoomDestinations on IList<Room> {
|
||||
List<NavigationRailM3EDestination> toDestinations({required bool isDm}) =>
|
||||
map(
|
||||
(room) => NavigationRailM3EDestination(
|
||||
label: room.metadata?.name ?? "Unnamed Room",
|
||||
badgeCount: switch (room.metadata?.unreadNotifications) {
|
||||
0 || null => room.metadata?.unreadMessages == 0 ? null : 0,
|
||||
int unread => unread,
|
||||
},
|
||||
icon: AvatarOrHash(
|
||||
room.metadata?.avatar,
|
||||
room.metadata?.name ?? "Unnamed Room",
|
||||
fallback: isDm ? null : const Icon(Icons.numbers),
|
||||
),
|
||||
),
|
||||
).toList();
|
||||
map((room) => room.toDestination(isDm: isDm)).toList();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue