34 lines
1.1 KiB
Dart
34 lines
1.1 KiB
Dart
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();
|
|
},
|
|
),
|
|
);
|
|
}
|