Push sidebar if needed and scroll to notif when tapped

Fixes #116
This commit is contained in:
Henry Hiles 2026-10-14 16:51:14 -04:00
commit 8fda43ccf8
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
6 changed files with 159 additions and 87 deletions

View file

@ -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,