feat(app): deliver live attention notifications and show permission in Settings
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../attention/notify/notification_controller.dart';
|
||||
import '../attention/ui/notification_permission_tile.dart';
|
||||
|
||||
/// The Settings entry for the browser notification permission.
|
||||
///
|
||||
/// It reads the platform's own state from the app-level
|
||||
/// [NotificationController] and asks only when the operator presses the tile's
|
||||
/// Enable action. The controller is shared with the Runs attention surface, so
|
||||
/// the permission shown here is the one that gates the live notices.
|
||||
class SettingsNotificationsSection extends StatelessWidget {
|
||||
const SettingsNotificationsSection({
|
||||
super.key,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final NotificationController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) => NotificationPermissionTile(
|
||||
state: controller.permission,
|
||||
asked: controller.asked,
|
||||
onRequest: () {
|
||||
// The platform answer updates the controller; the AnimationBuilder above
|
||||
// redraws the tile with its own words.
|
||||
controller.requestPermission();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -4,10 +4,12 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/transport/pipelines_client.dart' as transport;
|
||||
import '../attention/notify/notification_controller.dart';
|
||||
import 'default_endpoint.dart';
|
||||
import 'settings_controller.dart';
|
||||
import 'settings_controls.dart';
|
||||
import 'settings_layout.dart';
|
||||
import 'settings_notifications_section.dart';
|
||||
import 'settings_sections.dart';
|
||||
import 'settings_store.dart';
|
||||
import 'settings_templates_section.dart';
|
||||
@@ -29,6 +31,7 @@ class SettingsScreen extends StatefulWidget {
|
||||
this.ping,
|
||||
this.embedded = false,
|
||||
this.onOpenTemplates,
|
||||
this.notifications,
|
||||
});
|
||||
|
||||
final transport.PipelinesClient client;
|
||||
@@ -50,6 +53,9 @@ class SettingsScreen extends StatefulWidget {
|
||||
/// without a dead row that would go nowhere.
|
||||
final VoidCallback? onOpenTemplates;
|
||||
|
||||
/// The app-level notification capability; absent in connection-only fixtures.
|
||||
final NotificationController? notifications;
|
||||
|
||||
@override
|
||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||
}
|
||||
@@ -127,6 +133,14 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
controller: _controller,
|
||||
workspaceField: _workspaceField,
|
||||
),
|
||||
if (widget.notifications != null) ...<Widget>[
|
||||
const SizedBox(height: settingsSectionGap),
|
||||
const _SectionTitle('Notifications'),
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
SettingsNotificationsSection(
|
||||
controller: widget.notifications!,
|
||||
),
|
||||
],
|
||||
if (widget.onOpenTemplates != null) ...<Widget>[
|
||||
const SizedBox(height: settingsSectionGap),
|
||||
const _SectionTitle('Templates'),
|
||||
|
||||
Reference in New Issue
Block a user