displaying unreads
This commit is contained in:
parent
220c13a245
commit
5ae23f4620
2 changed files with 20 additions and 8 deletions
|
|
@ -7,6 +7,7 @@ import "package:nexus/controllers/spaces_controller.dart";
|
||||||
import "package:nexus/helpers/extension_helper.dart";
|
import "package:nexus/helpers/extension_helper.dart";
|
||||||
import "package:nexus/pages/settings_page.dart";
|
import "package:nexus/pages/settings_page.dart";
|
||||||
import "package:nexus/widgets/avatar_or_hash.dart";
|
import "package:nexus/widgets/avatar_or_hash.dart";
|
||||||
|
import "package:nexus/widgets/chat_page/unread.dart";
|
||||||
|
|
||||||
class Sidebar extends HookConsumerWidget {
|
class Sidebar extends HookConsumerWidget {
|
||||||
const Sidebar({super.key});
|
const Sidebar({super.key});
|
||||||
|
|
@ -40,12 +41,8 @@ class Sidebar extends HookConsumerWidget {
|
||||||
destinations: spaces
|
destinations: spaces
|
||||||
.map(
|
.map(
|
||||||
(space) => NavigationRailDestination(
|
(space) => NavigationRailDestination(
|
||||||
icon: Badge(
|
icon: Unread(
|
||||||
smallSize: 8,
|
isUnread:
|
||||||
backgroundColor: Theme.of(
|
|
||||||
context,
|
|
||||||
).colorScheme.primary,
|
|
||||||
isLabelVisible:
|
|
||||||
space.children.firstWhereOrNull(
|
space.children.firstWhereOrNull(
|
||||||
(room) => room.roomData.hasNewMessages,
|
(room) => room.roomData.hasNewMessages,
|
||||||
) !=
|
) !=
|
||||||
|
|
@ -107,8 +104,8 @@ class Sidebar extends HookConsumerWidget {
|
||||||
.map(
|
.map(
|
||||||
(room) => NavigationRailDestination(
|
(room) => NavigationRailDestination(
|
||||||
label: Text(room.title),
|
label: Text(room.title),
|
||||||
icon: Badge(
|
icon: Unread(
|
||||||
isLabelVisible: room.roomData.hasNewMessages,
|
isUnread: room.roomData.hasNewMessages,
|
||||||
child: AvatarOrHash(
|
child: AvatarOrHash(
|
||||||
room.avatar,
|
room.avatar,
|
||||||
room.title,
|
room.title,
|
||||||
|
|
|
||||||
15
lib/widgets/chat_page/unread.dart
Normal file
15
lib/widgets/chat_page/unread.dart
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
|
class Unread extends StatelessWidget {
|
||||||
|
final bool isUnread;
|
||||||
|
final Widget child;
|
||||||
|
const Unread({required this.isUnread, required this.child, super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Badge(
|
||||||
|
smallSize: 8,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
isLabelVisible: isUnread,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue