feat(settings): settings panel shell + settings.open command (T-445)
Lay the foundation for the schema-driven settings UI (epic T-444). A new `settings.open` command (⌘`,`, plus a File-menu and command-palette entry) opens a centered Settings modal over the dimmed app via the dialog router, built from the modalSurface* tokens (D-7, no Material). The shell frames the two regions later tickets fill in — the category rail (T-447) and the scrolling carded panel (T-448) — and dismisses on ✕, Esc, or barrier tap. With no category registered yet it shows its empty state, which is the correct runtime state. Flesh out the `builtin.settings-ui` stub (was 0.0.0-stub) into a real extension; ship its en-US i18n catalog. Relabel the theme picker's `theme.pick` command title from "Settings…" to "Theme…" so the two no longer collide in the palette (the picker folds into the new panel's Appearance category in T-452). Tests: command + ⌘`,` binding registered, shell renders, Esc and close both dismiss. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import 'package:clide/builtin/settings_ui/settings_ui.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../helpers/kernel_fixture.dart';
|
||||
import '../../helpers/widget_harness.dart';
|
||||
|
||||
void main() {
|
||||
group('SettingsUiExtension', () {
|
||||
late KernelFixture f;
|
||||
|
||||
setUp(() async {
|
||||
f = await KernelFixture.create(
|
||||
i18nCatalogs: {
|
||||
'builtin.settings-ui': {
|
||||
const Locale('en', 'US'): const {
|
||||
'modal.title': {'translation': 'Settings'},
|
||||
'modal.close': {'translation': 'Close'},
|
||||
'modal.close.hint': {'translation': 'Close settings'},
|
||||
'rail.header': {'translation': 'Categories'},
|
||||
'panel.empty': {'translation': 'No settings categories are registered yet.'},
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() async => f.dispose());
|
||||
|
||||
test('contributes a settings.open command', () async {
|
||||
f.services.extensions.register(SettingsUiExtension());
|
||||
await f.services.extensions.activateAll();
|
||||
expect(f.services.commands.get('settings.open'), isNotNull);
|
||||
});
|
||||
|
||||
test('default binding ctrl+, is registered', () async {
|
||||
f.services.extensions.register(SettingsUiExtension());
|
||||
await f.services.extensions.activateAll();
|
||||
expect(f.services.keybindings.commandFor(Keybinding.parse('ctrl+,')), 'settings.open');
|
||||
});
|
||||
|
||||
testWidgets('modal shell renders title, rail header, and empty state', (tester) async {
|
||||
await tester.pumpWidget(harness(f, SettingsModal(onDismiss: () {})));
|
||||
expect(find.text('Settings'), findsOneWidget);
|
||||
expect(find.text('Categories'), findsOneWidget);
|
||||
expect(find.text('No settings categories are registered yet.'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Esc dismisses the modal', (tester) async {
|
||||
var dismissed = 0;
|
||||
await tester.pumpWidget(harness(f, SettingsModal(onDismiss: () => dismissed++)));
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pump();
|
||||
expect(dismissed, 1);
|
||||
});
|
||||
|
||||
testWidgets('close button dismisses the modal', (tester) async {
|
||||
var dismissed = 0;
|
||||
await tester.pumpWidget(harness(f, SettingsModal(onDismiss: () => dismissed++)));
|
||||
// The close button carries the "Close" semantics label.
|
||||
await tester.tap(find.bySemanticsLabel('Close'));
|
||||
await tester.pump();
|
||||
expect(dismissed, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user