parent
3a33bf7bfe
commit
8fda43ccf8
6 changed files with 159 additions and 87 deletions
|
|
@ -1,15 +1,29 @@
|
|||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/controllers/notification_request.dart";
|
||||
import "package:nexus/models/nav_page.dart";
|
||||
import "package:nexus/widgets/invites_list.dart";
|
||||
import "package:nexus/widgets/notifications_list.dart";
|
||||
import "package:nexus/widgets/room_list.dart";
|
||||
|
||||
class const Sidebar({super.key}) extends HookWidget {
|
||||
class const Sidebar({super.key}) extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selectedIndex = useState(0);
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
const pages = <NavPage>[RoomList(), NotificationsList(), InvitesList()];
|
||||
final notificationsIndex = pages.indexWhere(
|
||||
(page) => page is NotificationsList,
|
||||
);
|
||||
|
||||
final selectedIndex = useState(
|
||||
ref.read(NotificationRequestController.provider) == null
|
||||
? 0
|
||||
: notificationsIndex,
|
||||
);
|
||||
|
||||
ref.listen(NotificationRequestController.provider, (_, next) {
|
||||
if (next != null) selectedIndex.value = notificationsIndex;
|
||||
});
|
||||
|
||||
return Drawer(
|
||||
width: 330,
|
||||
|
|
|
|||
Loading…
Reference in a new issue