diff --git a/lib/core/layout/querya_split_handle.dart b/lib/core/layout/querya_split_handle.dart index 0c888f8f..59ec2c38 100644 --- a/lib/core/layout/querya_split_handle.dart +++ b/lib/core/layout/querya_split_handle.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart' as material; import 'package:flutter/services.dart'; import 'package:querya_desktop/core/motion/querya_motion.dart'; import 'package:querya_desktop/core/motion/querya_motion_context.dart'; -import 'package:shadcn_flutter/shadcn_flutter.dart' hide Gap, TextExtension; +import 'package:querya_desktop/core/theme/querya_theme_scope.dart'; /// Accessible split-pane handle that supports mouse dragging and arrow keys. /// @@ -77,7 +77,7 @@ class _QueryaSplitHandleState extends material.State { @override material.Widget build(material.BuildContext context) { - final colors = Theme.of(context).colorScheme; + final colors = context.colors; final horizontal = widget.axis == material.Axis.horizontal; final duration = context.motionDuration(QueryaMotion.fast); final curve = context.motionCurve(QueryaMotion.enter); diff --git a/lib/core/motion/querya_hover_surface.dart b/lib/core/motion/querya_hover_surface.dart index be95a5b1..3fd8b1db 100644 --- a/lib/core/motion/querya_hover_surface.dart +++ b/lib/core/motion/querya_hover_surface.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:querya_desktop/core/theme/querya_theme_scope.dart'; + import 'querya_motion.dart'; import 'querya_motion_context.dart'; @@ -39,9 +41,9 @@ class _QueryaHoverSurfaceState extends State { @override Widget build(BuildContext context) { - final scheme = Theme.of(context).colorScheme; + final colors = context.colors; final hovered = widget.hoveredColor ?? - scheme.onSurface.withValues(alpha: 0.06); + colors.foreground.withValues(alpha: 0.06); final duration = context.motionDuration(QueryaMotion.fast); final curve = context.motionCurve(QueryaMotion.enter); diff --git a/lib/core/theme/querya_semantic_palette.dart b/lib/core/theme/querya_semantic_palette.dart index 92e0ccdc..5acefed9 100644 --- a/lib/core/theme/querya_semantic_palette.dart +++ b/lib/core/theme/querya_semantic_palette.dart @@ -21,18 +21,18 @@ class QueryaSemanticPalette { }); factory QueryaSemanticPalette.fromTheme(QueryaTheme theme) { - final scheme = theme.colorScheme; + final colors = theme.colors; final workbench = theme.workbench; return QueryaSemanticPalette( action: workbench.accent, success: workbench.success, destructive: workbench.destructive, muted: workbench.mutedForeground, - type1: scheme.chart1, - type2: scheme.chart2, - type3: scheme.chart3, - type4: scheme.chart4, - type5: scheme.chart5, + type1: colors.chart1, + type2: colors.chart2, + type3: colors.chart3, + type4: colors.chart4, + type5: colors.chart5, ); } diff --git a/lib/core/theme/theme_editor_draft.dart b/lib/core/theme/theme_editor_draft.dart index 63442848..9cb7abf6 100644 --- a/lib/core/theme/theme_editor_draft.dart +++ b/lib/core/theme/theme_editor_draft.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:ui'; -import 'package:shadcn_flutter/shadcn_flutter.dart' show ColorScheme; +import 'package:querya_desktop/core/theme/querya_ui_colors.dart'; import 'package:querya_desktop/core/theme/parser/color_parser.dart'; import 'package:querya_desktop/core/theme/parser/querya_theme_manifest.dart'; import 'package:querya_desktop/core/theme/parser/vscode_theme_manifest.dart'; @@ -144,7 +144,7 @@ class ThemeEditorDraft { ThemeMetadata? metadata, bool readOnlySource = false, }) { - final scheme = theme.colorScheme; + final colors = theme.colors; final editor = theme.editor; final workbench = theme.workbench; @@ -155,7 +155,7 @@ class ThemeEditorDraft { shadcnColors: { for (final field in themeEditorMvpColorFields) if (field.section == 'shadcn_colors') - field.key: _colorForShadcnField(field.key, scheme), + field.key: _colorForShadcnField(field.key, colors), }, editorColors: { 'background': formatVsCodeColor(editor.background), @@ -176,14 +176,14 @@ class ThemeEditorDraft { ); } - static String _colorForShadcnField(String key, ColorScheme scheme) { + static String _colorForShadcnField(String key, QueryaUiColors colors) { final color = switch (key) { - 'primary' => scheme.primary, - 'background' => scheme.background, - 'foreground' => scheme.foreground, - 'card' => scheme.card, - 'border' => scheme.border, - _ => scheme.primary, + 'primary' => colors.primary, + 'background' => colors.background, + 'foreground' => colors.foreground, + 'card' => colors.card, + 'border' => colors.border, + _ => colors.primary, }; return formatVsCodeColor(color); } diff --git a/lib/core/ui/querya_tree_indent_guide.dart b/lib/core/ui/querya_tree_indent_guide.dart index 60636c6f..68ecc9a0 100644 --- a/lib/core/ui/querya_tree_indent_guide.dart +++ b/lib/core/ui/querya_tree_indent_guide.dart @@ -40,8 +40,7 @@ class QueryaTreeIndentGuide extends StatelessWidget { if (depth <= 0) return content; - final base = QueryaThemeScope.maybeOf(context)?.workbench.borderSubtle ?? - Theme.of(context).colorScheme.outline; + final base = context.workbench.borderSubtle; final color = base.withValues(alpha: QueryaTreeTokens.guideAlpha); return CustomPaint( diff --git a/test/guards/colors_through_context_test.dart b/test/guards/colors_through_context_test.dart index 72cfcd50..fe74ff62 100644 --- a/test/guards/colors_through_context_test.dart +++ b/test/guards/colors_through_context_test.dart @@ -4,46 +4,26 @@ import 'package:flutter_test/flutter_test.dart'; /// Epic #1465, #1731: colours are read through `context.colors` /// (`QueryaUiColors`), not through a theme's `colorScheme`. `Theme.of` itself -/// stays allowed for what is not a colour (brightness, radius) until #1735. A folder joins -/// [migrated] in the PR that moves it; at the end the list is all of `lib/`. +/// stays allowed for what is not a colour (brightness, radius) until #1735. +/// +/// The guard covers all of `lib/` except `lib/core/theme/`, which bridges to +/// the shadcn shell and leaves with #1465 step 5. void main() { - const migrated = [ - 'lib/app', - 'lib/features/command_palette', - 'lib/features/connections', - 'lib/features/erd', - 'lib/features/extensions', - 'lib/features/help', - 'lib/features/main_screen', - 'lib/features/mongodb', - 'lib/features/mysql', - 'lib/features/onboarding', - 'lib/features/postgresql', - 'lib/features/recovery', - 'lib/features/redis', - 'lib/features/results', - 'lib/features/settings', - 'lib/features/sqlite', - 'lib/features/updater', - 'lib/features/workspace', - 'lib/shared', - ]; - final banned = RegExp(r'\bcolorScheme\b|\bColorScheme\b'); - test('migrated folders read colours through context.colors', () { + test('lib/ reads colours through context.colors (outside core/theme)', () { final offenders = []; - for (final dir in migrated) { - for (final e in Directory(dir).listSync(recursive: true)) { - if (e is! File || !e.path.endsWith('.dart')) continue; - final lines = e.readAsLinesSync(); - for (var i = 0; i < lines.length; i++) { - final line = lines[i]; - if (line.trimLeft().startsWith('//')) continue; - if (banned.hasMatch(line)) { - offenders.add('${e.path.replaceAll(r'\', '/')}:${i + 1}: ' - '${line.trim()}'); - } + for (final e in Directory('lib').listSync(recursive: true)) { + if (e is! File || !e.path.endsWith('.dart')) continue; + final normalized = e.path.replaceAll(r'\', '/'); + if (normalized.startsWith('lib/core/theme/')) continue; + + final lines = e.readAsLinesSync(); + for (var i = 0; i < lines.length; i++) { + final line = lines[i]; + if (line.trimLeft().startsWith('//')) continue; + if (banned.hasMatch(line)) { + offenders.add('$normalized:${i + 1}: ${line.trim()}'); } } } diff --git a/test/guards/shadcn_imports_ratchet_test.dart b/test/guards/shadcn_imports_ratchet_test.dart index c6c4171e..20de29ff 100644 --- a/test/guards/shadcn_imports_ratchet_test.dart +++ b/test/guards/shadcn_imports_ratchet_test.dart @@ -13,7 +13,6 @@ void main() { 'lib/app/app.dart', 'lib/app/querya_core_commands.dart', 'lib/core/editor/querya_code_editor.dart', - 'lib/core/layout/querya_split_handle.dart', 'lib/core/storage/app_settings.dart', 'lib/core/theme/app_theme.dart', 'lib/core/theme/parser/querya_theme_color_scheme.dart', @@ -22,7 +21,6 @@ void main() { 'lib/core/theme/querya_theme.dart', 'lib/core/theme/querya_theme_scope.dart', 'lib/core/theme/theme_controller.dart', - 'lib/core/theme/theme_editor_draft.dart', 'lib/features/erd/erd_view.dart', 'lib/features/erd/widgets/erd_group_frame.dart', 'lib/features/erd/widgets/erd_group_menu.dart',