diff --git a/lib/core/theme/querya_theme_scope.dart b/lib/core/theme/querya_theme_scope.dart index a834d601..546ca1d2 100644 --- a/lib/core/theme/querya_theme_scope.dart +++ b/lib/core/theme/querya_theme_scope.dart @@ -59,7 +59,7 @@ extension QueryaThemeContext on BuildContext { QueryaTheme get queryaTheme => QueryaThemeScope.of(this); - QueryaWorkbenchTheme get workbench => queryaTheme.workbench; + QueryaWorkbenchTheme get workbench => workbenchOrDefault; /// The workbench tokens of the nearest [QueryaThemeScope], or the defaults /// for the ambient brightness when there is none (a widget under a bare app, @@ -71,8 +71,17 @@ extension QueryaThemeContext on BuildContext { ? QueryaWorkbenchTheme.lightDefault : QueryaWorkbenchTheme.darkDefault); - QueryaEditorTheme get editorTheme => queryaTheme.editor; + QueryaEditorTheme get editorTheme => + QueryaThemeScope.maybeOf(this)?.editor ?? + (colors.brightness == Brightness.light + ? QueryaEditorTheme.lightDefault + : QueryaEditorTheme.darkDefault); QueryaSemanticPalette get semanticPalette => - QueryaSemanticPalette.fromTheme(queryaTheme); + QueryaSemanticPalette.fromTheme( + QueryaThemeScope.maybeOf(this) ?? + (colors.brightness == Brightness.light + ? QueryaTheme.lightDefault + : QueryaTheme.darkDefault), + ); } diff --git a/lib/features/connections/extension_connection_form.dart b/lib/features/connections/extension_connection_form.dart index 6cda1a20..51800724 100644 --- a/lib/features/connections/extension_connection_form.dart +++ b/lib/features/connections/extension_connection_form.dart @@ -195,6 +195,7 @@ class _ExtensionConnectionFormContentState @override material.Widget build(material.BuildContext context) { final theme = context.colors; + final wb = context.workbench; final title = _isEditing ? 'Edit ${widget.driver.displayName}' : widget.driver.displayName; @@ -267,7 +268,7 @@ class _ExtensionConnectionFormContentState style: material.TextStyle( fontSize: 12, color: _testSucceeded - ? material.Colors.green + ? wb.success : theme.destructive, ), ), diff --git a/lib/features/connections/querya_connection_tree_row.dart b/lib/features/connections/querya_connection_tree_row.dart index 6d836029..66195fd6 100644 --- a/lib/features/connections/querya_connection_tree_row.dart +++ b/lib/features/connections/querya_connection_tree_row.dart @@ -106,6 +106,7 @@ class QueryaConnectionTreeRow extends material.StatelessWidget { final theme = Theme.of(context); final primary = theme.colorScheme.primary; final muted = theme.colorScheme.mutedForeground; + final wb = context.workbench; final row = material.CallbackShortcuts( bindings: { if (expanded == false && onTap != null) @@ -157,7 +158,7 @@ class QueryaConnectionTreeRow extends material.StatelessWidget { material.Icon( material.Icons.star_rounded, size: 13, - color: material.Colors.amber.shade600, + color: wb.warning, ), const Gap(4), ], @@ -205,7 +206,7 @@ class QueryaConnectionTreeRow extends material.StatelessWidget { : material.Icons.star_border_rounded, size: 18, color: isPinned - ? material.Colors.amber.shade600 + ? wb.warning : theme.colorScheme.mutedForeground, ), onPressed: (_) => onTogglePin!(), diff --git a/lib/features/connections/ssh_tunnel_section.dart b/lib/features/connections/ssh_tunnel_section.dart index e44def2d..bbdc4755 100644 --- a/lib/features/connections/ssh_tunnel_section.dart +++ b/lib/features/connections/ssh_tunnel_section.dart @@ -196,6 +196,7 @@ class _SshTunnelSectionState extends material.State { material.Widget build(material.BuildContext context) { final theme = Theme.of(context); final cs = theme.colorScheme; + final wb = context.workbench; return material.Container( margin: const material.EdgeInsets.only(top: 16), @@ -458,7 +459,7 @@ class _SshTunnelSectionState extends material.State { style: material.TextStyle( fontSize: 12, color: _testSuccess - ? material.Colors.green + ? wb.success : cs.destructive, ), ), diff --git a/lib/features/workspace/dml_preview_dialog.dart b/lib/features/workspace/dml_preview_dialog.dart index 46b6f419..c741f740 100644 --- a/lib/features/workspace/dml_preview_dialog.dart +++ b/lib/features/workspace/dml_preview_dialog.dart @@ -63,6 +63,7 @@ class _DmlPreviewDialogState extends material.State<_DmlPreviewDialog> { material.Widget build(material.BuildContext context) { final theme = Theme.of(context); final cs = theme.colorScheme; + final wb = context.workbench; final isDark = theme.brightness == Brightness.dark; final sql = widget.plan.toTransactionSql(); @@ -160,19 +161,19 @@ class _DmlPreviewDialogState extends material.State<_DmlPreviewDialog> { if (_updateCount > 0) _buildCountPill( label: '$_updateCount UPDATE', - color: material.Colors.amber.shade700, + color: wb.warning, isDark: isDark, ), if (_insertCount > 0) _buildCountPill( label: '$_insertCount INSERT', - color: material.Colors.green.shade600, + color: wb.success, isDark: isDark, ), if (_deleteCount > 0) _buildCountPill( label: '$_deleteCount DELETE', - color: material.Colors.red.shade600, + color: wb.destructive, isDark: isDark, ), ], @@ -192,12 +193,12 @@ class _DmlPreviewDialogState extends material.State<_DmlPreviewDialog> { vertical: 6, ), decoration: material.BoxDecoration( - color: material.Colors.amber.withValues( + color: wb.warning.withValues( alpha: isDark ? 0.15 : 0.08, ), borderRadius: material.BorderRadius.circular(6), border: material.Border.all( - color: material.Colors.amber.withValues(alpha: 0.4), + color: wb.warning.withValues(alpha: 0.4), ), ), child: material.Row( @@ -205,7 +206,7 @@ class _DmlPreviewDialogState extends material.State<_DmlPreviewDialog> { material.Icon( material.Icons.warning_amber_rounded, size: 15, - color: material.Colors.amber.shade700, + color: wb.warning, ), const Gap(8), material.Expanded( @@ -241,7 +242,7 @@ class _DmlPreviewDialogState extends material.State<_DmlPreviewDialog> { : material.Icons.copy_rounded, size: 13, color: _copied - ? material.Colors.green + ? wb.success : cs.mutedForeground, ), const Gap(4), diff --git a/lib/features/workspace/grid_cell_editor.dart b/lib/features/workspace/grid_cell_editor.dart index dce589de..26196ac5 100644 --- a/lib/features/workspace/grid_cell_editor.dart +++ b/lib/features/workspace/grid_cell_editor.dart @@ -168,7 +168,7 @@ class _GridCellEditorState extends material.State { decoration: material.BoxDecoration( color: cs.card, border: material.Border.all( - color: hasError ? material.Colors.red.shade500 : cs.primary, + color: hasError ? cs.destructive : cs.primary, width: 1.5, ), ), @@ -208,7 +208,7 @@ class _GridCellEditorState extends material.State { child: material.Icon( material.Icons.error_outline_rounded, size: 14, - color: material.Colors.red.shade500, + color: cs.destructive, ), ), ), diff --git a/test/features/connections/querya_connection_tree_row_test.dart b/test/features/connections/querya_connection_tree_row_test.dart new file mode 100644 index 00000000..4b89d72e --- /dev/null +++ b/test/features/connections/querya_connection_tree_row_test.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart' as material; +import 'package:flutter_test/flutter_test.dart'; +import 'package:querya_desktop/core/theme/querya_theme.dart'; +import 'package:querya_desktop/features/connections/querya_connection_tree_row.dart'; + +import '../../support/querya_theme_test_shell.dart'; + +void main() { + group('QueryaConnectionTreeRow', () { + testWidgets('renders pinned star icon with workbench.warning (#1643)', + (tester) async { + await tester.pumpWidget( + queryaThemeTestShell( + data: QueryaTheme.darkDefault, + child: const material.Material( + child: QueryaConnectionTreeRow( + label: 'Production DB', + isPinned: true, + textStyle: material.TextStyle(fontSize: 13), + ), + ), + ), + ); + await tester.pumpAndSettle(); + + final starIconFinder = find.byIcon(material.Icons.star_rounded); + expect(starIconFinder, findsOneWidget); + + final starIcon = tester.widget(starIconFinder); + expect(starIcon.color, QueryaTheme.darkDefault.workbench.warning); + }); + + testWidgets('adapts pinned star icon to light theme workbench.warning (#1643)', + (tester) async { + await tester.pumpWidget( + queryaThemeTestShell( + data: QueryaTheme.lightDefault, + child: const material.Material( + child: QueryaConnectionTreeRow( + label: 'Staging DB', + isPinned: true, + textStyle: material.TextStyle(fontSize: 13), + ), + ), + ), + ); + await tester.pumpAndSettle(); + + final starIconFinder = find.byIcon(material.Icons.star_rounded); + expect(starIconFinder, findsOneWidget); + + final starIcon = tester.widget(starIconFinder); + expect(starIcon.color, QueryaTheme.lightDefault.workbench.warning); + }); + }); +} diff --git a/test/features/workspace/dml_preview_dialog_test.dart b/test/features/workspace/dml_preview_dialog_test.dart index 7044d9cf..cfa09de9 100644 --- a/test/features/workspace/dml_preview_dialog_test.dart +++ b/test/features/workspace/dml_preview_dialog_test.dart @@ -164,5 +164,25 @@ void main() { QueryaTheme.lightDefault.colorScheme.foreground, ); }); + + testWidgets( + 'breakdown pills and warning banner use workbench status colors (#1643)', + (tester) async { + await tester.pumpWidget(buildTestDialog( + plan: samplePlan, + data: QueryaTheme.darkDefault, + )); + await tester.tap(find.text('Open Dialog')); + await tester.pumpAndSettle(); + + final updateText = tester.widget(find.text('1 UPDATE')); + expect(updateText.style?.color, QueryaTheme.darkDefault.workbench.warning); + + final insertText = tester.widget(find.text('1 INSERT')); + expect(insertText.style?.color, QueryaTheme.darkDefault.workbench.success); + + final deleteText = tester.widget(find.text('1 DELETE')); + expect(deleteText.style?.color, QueryaTheme.darkDefault.workbench.destructive); + }); }); } diff --git a/test/features/workspace/grid_cell_editor_test.dart b/test/features/workspace/grid_cell_editor_test.dart index 2bd5cc2e..534952c7 100644 --- a/test/features/workspace/grid_cell_editor_test.dart +++ b/test/features/workspace/grid_cell_editor_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:querya_desktop/features/workspace/data_grid_staging_buffer.dart'; import 'package:querya_desktop/features/workspace/grid_cell_editor.dart'; import 'package:querya_desktop/features/workspace/grid_cell_popover_inspector.dart'; +import 'package:querya_desktop/core/theme/querya_theme.dart'; import 'package:querya_desktop/features/workspace/result_grid_view.dart'; import 'package:shadcn_flutter/shadcn_flutter.dart' hide TextExtension; @@ -143,6 +144,13 @@ void main() { await tester.pumpAndSettle(); expect(find.byIcon(material.Icons.error_outline_rounded), findsOneWidget); + final errorIcon = tester.widget( + find.byIcon(material.Icons.error_outline_rounded), + ); + expect( + errorIcon.color, + QueryaTheme.darkDefault.colorScheme.destructive, + ); }); });