Merge branch 'worktree-agent-af8a7475a38f6de50' into integrate/notify-marked
This commit is contained in:
@@ -4,15 +4,25 @@ import '../../core/api_gateway.dart';
|
||||
|
||||
/// One server-side ntfy notification choice, in the server's wire key.
|
||||
class NtfySetting {
|
||||
const NtfySetting(this.key, this.label);
|
||||
const NtfySetting(this.key, this.label, {this.subtitle});
|
||||
|
||||
final String key;
|
||||
final String label;
|
||||
|
||||
/// Optional one-line explanation shown under [label].
|
||||
final String? subtitle;
|
||||
}
|
||||
|
||||
/// The server's global notification choices, in display order.
|
||||
///
|
||||
/// `run_finished` (server default off) makes every run end notify; without it
|
||||
/// only runs started with "Notify me" announce their success or failure.
|
||||
const ntfySettings = <NtfySetting>[
|
||||
NtfySetting('run_finished', 'Run finished'),
|
||||
NtfySetting(
|
||||
'run_finished',
|
||||
'Notify when any run ends',
|
||||
subtitle: 'Otherwise only runs started with Notify me',
|
||||
),
|
||||
NtfySetting('chat_needs_you', 'Chat needs your answer or approval'),
|
||||
NtfySetting('chat_reply_finished', 'Chat reply finished'),
|
||||
];
|
||||
|
||||
@@ -140,6 +140,7 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
|
||||
return CupertinoListTile(
|
||||
key: ntfySettingKey(setting.key),
|
||||
title: Text(setting.label),
|
||||
subtitle: setting.subtitle == null ? null : Text(setting.subtitle!),
|
||||
// iOS settings rows toggle with a switch; an unchecked checkbox is
|
||||
// nearly invisible on the grouped row.
|
||||
trailing: CupertinoSwitch(value: value, onChanged: onChanged),
|
||||
@@ -149,6 +150,7 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
|
||||
return CheckboxListTile(
|
||||
key: ntfySettingKey(setting.key),
|
||||
title: Text(setting.label),
|
||||
subtitle: setting.subtitle == null ? null : Text(setting.subtitle!),
|
||||
value: value,
|
||||
onChanged: onChanged == null ? null : (next) => onChanged(next!),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
Settings has a **Phone notifications** section beside the in-app
|
||||
Notifications permission tile. It holds three checkboxes for the server's global
|
||||
ntfy choices: **Run finished** (`run_finished`, default on), **Chat needs your
|
||||
ntfy choices: **Notify when any run ends** (`run_finished`, default off,
|
||||
subtitle "Otherwise only runs started with Notify me"), **Chat needs your
|
||||
answer or approval** (`chat_needs_you`, default on) and **Chat reply finished**
|
||||
(`chat_reply_finished`, default off), under one line saying they go through
|
||||
ntfy to the subscribed devices. Material uses `CheckboxListTile`. Cupertino uses
|
||||
|
||||
@@ -65,7 +65,11 @@ void main() {
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls.single.$1, 'notification_settings');
|
||||
expect(find.text('Run finished'), findsOneWidget);
|
||||
expect(find.text('Notify when any run ends'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Otherwise only runs started with Notify me'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Chat needs your answer or approval'), findsOneWidget);
|
||||
expect(find.text('Chat reply finished'), findsOneWidget);
|
||||
expect(find.text(ntfySectionSubtitle), findsOneWidget);
|
||||
@@ -77,6 +81,21 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('$style shows the server default: only marked runs', (
|
||||
tester,
|
||||
) async {
|
||||
// The server's defaults: run ends notify only for "Notify me" runs.
|
||||
final gateway = _Gateway((_, _) => _reply(false, true, false));
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_checked(tester, 'run_finished', cupertino: cupertino), isFalse);
|
||||
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isTrue);
|
||||
expect(
|
||||
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('$style toggling writes only that setting', (tester) async {
|
||||
final gateway = _Gateway((type, fields) {
|
||||
if (type == 'set_notification_settings') {
|
||||
|
||||
Reference in New Issue
Block a user