feat(app): deliver live attention notifications and show permission in Settings
This commit is contained in:
@@ -8,6 +8,8 @@ import '../core/api_gateway.dart';
|
||||
import '../core/transport/pipelines_client.dart';
|
||||
import '../shell/adaptive_shell.dart';
|
||||
import '../shell/destination.dart';
|
||||
import '../features/attention/notify/notification_controller.dart';
|
||||
import '../features/attention/notify/notification_store.dart';
|
||||
import '../features/settings/settings_screen.dart';
|
||||
import 'app.dart';
|
||||
import 'app_route.dart';
|
||||
@@ -61,6 +63,12 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
/// list once; the run itself is then opened from its route.
|
||||
int _runsRefresh = 0;
|
||||
|
||||
/// One notification capability for the app: the Runs attention surface
|
||||
/// publishes live transitions and Settings renders the same permission.
|
||||
late final NotificationController _notifications = NotificationController(
|
||||
store: const SharedPreferencesNotificationStore(),
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -81,6 +89,8 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
);
|
||||
}
|
||||
_cupertino = widget.cupertino ?? _platformIsCupertino;
|
||||
_notifications.onOpenRun = (id) => _delegate.goTo(AppRoute.run(id));
|
||||
unawaited(_notifications.load());
|
||||
_delegate = AppRouterDelegate(
|
||||
initial: initial,
|
||||
cupertino: _cupertino,
|
||||
@@ -100,6 +110,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_notifications.dispose();
|
||||
_delegate.dispose();
|
||||
if (_ownsProvider) {
|
||||
(_provider as PlatformRouteInformationProvider).dispose();
|
||||
@@ -178,6 +189,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
server: widget.server,
|
||||
initialRunId: route.runId,
|
||||
listRefreshToken: _runsRefresh,
|
||||
notifications: _notifications,
|
||||
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
||||
onBack: () => _delegate.goTo(AppRoute.runs),
|
||||
),
|
||||
@@ -193,6 +205,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
initialEndpoint: _session.endpoint,
|
||||
embedded: true,
|
||||
onOpenTemplates: _delegate.openTemplates,
|
||||
notifications: _notifications,
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../features/attention/notify/notification_controller.dart';
|
||||
import '../features/runs/screen.dart';
|
||||
import '../ui/adaptive/host.dart';
|
||||
import 'app_session.dart';
|
||||
@@ -21,6 +22,7 @@ class RunsDestination extends StatelessWidget {
|
||||
this.onRunSelected,
|
||||
this.onBack,
|
||||
this.listRefreshToken = 0,
|
||||
this.notifications,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
@@ -33,6 +35,9 @@ class RunsDestination extends StatelessWidget {
|
||||
/// re-reads its list once; no row is inserted locally.
|
||||
final int listRefreshToken;
|
||||
|
||||
/// The app-level notification capability shared with Settings.
|
||||
final NotificationController? notifications;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: session,
|
||||
@@ -70,6 +75,7 @@ class RunsDestination extends StatelessWidget {
|
||||
initialRunId: initialRunId,
|
||||
syncToken: session.connectionEpoch,
|
||||
listRefreshToken: listRefreshToken,
|
||||
notifications: notifications,
|
||||
onRunSelected: onRunSelected,
|
||||
onBack: onBack,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user