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

@ -7,7 +7,7 @@ import "package:nexus/controllers/portal.dart";
import "package:nexus/main.dart";
import "package:flutter_local_notifications/flutter_local_notifications.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/widgets/notifications_list.dart";
import "package:nexus/controllers/notification_request.dart";
import "package:xdg_desktop_portal/xdg_desktop_portal.dart";
class NotificationController
@ -34,16 +34,10 @@ class NotificationController
if (details.payload == null) return;
if (int.tryParse(details.payload!) case final rowId?) {
if (navigatorKey.currentContext case final context?) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => NotificationsList(
highlightedEvent: rowId,
defaultToAllNotifications: true,
),
),
);
}
navigatorKey.currentState?.popUntil((route) => route.isFirst);
ref
.read(NotificationRequestController.provider.notifier)
.request(rowId);
}
},
);
@ -58,16 +52,10 @@ class NotificationController
}
if (int.tryParse(call.arguments) case int rowId) {
if (navigatorKey.currentContext case final context?) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => NotificationsList(
highlightedEvent: rowId,
defaultToAllNotifications: true,
),
),
);
}
navigatorKey.currentState?.popUntil((route) => route.isFirst);
ref
.read(NotificationRequestController.provider.notifier)
.request(rowId);
}
});

View file

@ -0,0 +1,14 @@
import "package:flutter_riverpod/flutter_riverpod.dart";
class NotificationRequestController extends Notifier<int?> {
@override
int? build() => null;
void request(int rowId) => state = rowId;
void consume() => state = null;
static final provider = NotifierProvider<NotificationRequestController, int?>(
NotificationRequestController.new,
);
}