Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/core/theme/querya_theme_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
);
}
3 changes: 2 additions & 1 deletion lib/features/connections/extension_connection_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -267,7 +268,7 @@ class _ExtensionConnectionFormContentState
style: material.TextStyle(
fontSize: 12,
color: _testSucceeded
? material.Colors.green
? wb.success
: theme.destructive,
),
),
Expand Down
5 changes: 3 additions & 2 deletions lib/features/connections/querya_connection_tree_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
],
Expand Down Expand Up @@ -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!(),
Expand Down
3 changes: 2 additions & 1 deletion lib/features/connections/ssh_tunnel_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class _SshTunnelSectionState extends material.State<SshTunnelSection> {
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),
Expand Down Expand Up @@ -458,7 +459,7 @@ class _SshTunnelSectionState extends material.State<SshTunnelSection> {
style: material.TextStyle(
fontSize: 12,
color: _testSuccess
? material.Colors.green
? wb.success
: cs.destructive,
),
),
Expand Down
15 changes: 8 additions & 7 deletions lib/features/workspace/dml_preview_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
),
],
Expand All @@ -192,20 +193,20 @@ 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(
children: [
material.Icon(
material.Icons.warning_amber_rounded,
size: 15,
color: material.Colors.amber.shade700,
color: wb.warning,
),
const Gap(8),
material.Expanded(
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions lib/features/workspace/grid_cell_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class _GridCellEditorState extends material.State<GridCellEditor> {
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,
),
),
Expand Down Expand Up @@ -208,7 +208,7 @@ class _GridCellEditorState extends material.State<GridCellEditor> {
child: material.Icon(
material.Icons.error_outline_rounded,
size: 14,
color: material.Colors.red.shade500,
color: cs.destructive,
),
),
),
Expand Down
56 changes: 56 additions & 0 deletions test/features/connections/querya_connection_tree_row_test.dart
Original file line number Diff line number Diff line change
@@ -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<material.Icon>(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<material.Icon>(starIconFinder);
expect(starIcon.color, QueryaTheme.lightDefault.workbench.warning);
});
});
}
20 changes: 20 additions & 0 deletions test/features/workspace/dml_preview_dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Text>(find.text('1 UPDATE'));
expect(updateText.style?.color, QueryaTheme.darkDefault.workbench.warning);

final insertText = tester.widget<Text>(find.text('1 INSERT'));
expect(insertText.style?.color, QueryaTheme.darkDefault.workbench.success);

final deleteText = tester.widget<Text>(find.text('1 DELETE'));
expect(deleteText.style?.color, QueryaTheme.darkDefault.workbench.destructive);
});
});
}
8 changes: 8 additions & 0 deletions test/features/workspace/grid_cell_editor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -143,6 +144,13 @@ void main() {
await tester.pumpAndSettle();

expect(find.byIcon(material.Icons.error_outline_rounded), findsOneWidget);
final errorIcon = tester.widget<material.Icon>(
find.byIcon(material.Icons.error_outline_rounded),
);
expect(
errorIcon.color,
QueryaTheme.darkDefault.colorScheme.destructive,
);
});
});

Expand Down
Loading