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
4 changes: 2 additions & 2 deletions lib/core/layout/querya_split_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -77,7 +77,7 @@ class _QueryaSplitHandleState extends material.State<QueryaSplitHandle> {

@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);
Expand Down
6 changes: 4 additions & 2 deletions lib/core/motion/querya_hover_surface.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -39,9 +41,9 @@ class _QueryaHoverSurfaceState extends State<QueryaHoverSurface> {

@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);

Expand Down
12 changes: 6 additions & 6 deletions lib/core/theme/querya_semantic_palette.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand Down
20 changes: 10 additions & 10 deletions lib/core/theme/theme_editor_draft.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;

Expand All @@ -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),
Expand All @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/core/ui/querya_tree_indent_guide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
52 changes: 16 additions & 36 deletions test/guards/colors_through_context_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <String>[
'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 = <String>[];
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()}');
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions test/guards/shadcn_imports_ratchet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
Loading