Skip to content

Commit 86ecc84

Browse files
committed
disable push enabled toggle if no permission
1 parent 37e1010 commit 86ecc84

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

examples/build.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ Push Section:
357357
- Section title: "Push" with info icon for tooltip
358358
- Push Subscription ID display (readonly)
359359
- Enabled toggle switch (controls optIn/optOut)
360+
- Disabled when notification permission is NOT granted
360361
- Notification permission is automatically requested when home screen loads
361362
- PROMPT PUSH button:
362363
- Only visible when notification permission is NOT granted (fallback if user denied)
@@ -799,6 +800,7 @@ Notification permission is automatically requested when the home screen loads:
799800
- This ensures prompt appears after user sees the app UI
800801
- PROMPT PUSH button remains as fallback if user initially denied
801802
- Button hidden once permission is granted
803+
- Keep Push "Enabled" toggle disabled until permission is granted
802804
```
803805

804806
---

examples/demo/lib/widgets/sections/push_section.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class PushSection extends StatelessWidget {
4949
ToggleRow(
5050
label: 'Enabled',
5151
value: vm.pushEnabled,
52-
onChanged: vm.togglePush,
52+
onChanged: vm.hasNotificationPermission
53+
? vm.togglePush
54+
: null,
5355
),
5456
],
5557
),

examples/demo/lib/widgets/toggle_row.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ class ToggleRow extends StatelessWidget {
44
final String label;
55
final String? description;
66
final bool value;
7-
final ValueChanged<bool> onChanged;
7+
final ValueChanged<bool>? onChanged;
88

99
const ToggleRow({
1010
super.key,
1111
required this.label,
1212
this.description,
1313
required this.value,
14-
required this.onChanged,
14+
this.onChanged,
1515
});
1616

1717
@override

0 commit comments

Comments
 (0)