From 641a0a0924bb729927cac14c54b7890db661405d Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Sun, 18 Oct 2026 19:44:31 +0300 Subject: [PATCH] refactor(misc): read colours through context.colors across shared and misc features (#1731) Migrate colour reading from Theme.of(context).colorScheme / shadcn.Theme.of(context).colorScheme to context.colors across: - lib/shared - lib/app - lib/features/command_palette - lib/features/erd - lib/features/help - lib/features/main_screen - lib/features/onboarding - lib/features/recovery - lib/features/results - lib/features/updater Drop package:shadcn_flutter from erd_export_data.dart, erd_edge_tip_label.dart, and update_changelog_view.dart, and update the shadcn ratchet accordingly. Add all 10 locations to the migrated list in colors_through_context_test.dart. Part of #1731. --- lib/app/app.dart | 3 +-- lib/core/theme/theme_controller.dart | 4 ++++ .../command_match_highlight.dart | 4 ++-- .../command_palette_dialog.dart | 4 ++-- .../quick_switcher_dialog.dart | 6 ++--- lib/features/erd/erd_export_data.dart | 4 +--- .../erd/widgets/erd_edge_tip_label.dart | 4 ++-- lib/features/erd/widgets/erd_note_card.dart | 2 +- lib/features/help/about_dialog.dart | 4 ++-- .../main_screen/querya_status_bar.dart | 4 ++-- .../main_screen/querya_window_title_bar.dart | 6 ++--- .../main_screen/workspace_empty_hero.dart | 8 +++---- lib/features/main_screen/workspace_panel.dart | 9 ++++---- .../onboarding/welcome_tour_dialog.dart | 13 +++++------ .../recovery/querya_startup_recovery_app.dart | 22 +++++++++---------- .../results/charts/quick_chart_view.dart | 2 +- .../updater/update_changelog_view.dart | 5 +++-- lib/features/updater/update_dialog.dart | 6 ++--- .../widgets/connection_tree_loading_row.dart | 5 +---- lib/shared/widgets/poll_stale_overlay.dart | 7 +++--- lib/shared/widgets/query_error_view.dart | 2 +- lib/shared/widgets/querya_badge.dart | 2 +- lib/shared/widgets/querya_dropdown.dart | 8 +++---- lib/shared/widgets/querya_spinner.dart | 6 ++--- lib/shared/widgets/tree_load_error.dart | 6 ++--- test/guards/colors_through_context_test.dart | 10 +++++++++ test/guards/shadcn_imports_ratchet_test.dart | 3 --- 27 files changed, 81 insertions(+), 78 deletions(-) diff --git a/lib/app/app.dart b/lib/app/app.dart index bba6d3ed..861cc4f4 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -23,7 +23,6 @@ class QueryaApp extends StatelessWidget { listenable: themeController, builder: (context, __) { final queryaTheme = themeController.activeTheme; - final colorScheme = queryaTheme.colorScheme; return ListenableBuilder( listenable: uiScaleController, @@ -58,7 +57,7 @@ class QueryaApp extends StatelessWidget { theme: themeController.lightShadcnTheme, darkTheme: themeController.darkShadcnTheme, themeMode: themeController.themeMode, - materialTheme: themeController.materialThemeFor(colorScheme), + materialTheme: themeController.activeMaterialTheme, debugShowCheckedModeBanner: false, menuHandler: const PopoverOverlayHandler( defaultShowDuration: Duration(milliseconds: 60), diff --git a/lib/core/theme/theme_controller.dart b/lib/core/theme/theme_controller.dart index 3c8ce91b..4a7712fb 100644 --- a/lib/core/theme/theme_controller.dart +++ b/lib/core/theme/theme_controller.dart @@ -172,6 +172,10 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver { ThemeData get darkShadcnTheme => _cachedDarkShadcnTheme ??= _resolvedThemeForBrightness(Brightness.dark).toShadcnThemeData(); + /// Active Material theme aligned with [activeTheme]. + material.ThemeData get activeMaterialTheme => + materialThemeFor(activeTheme.colorScheme); + /// Cached Material theme for dialogs/dropdowns (avoids rebuild churn). material.ThemeData materialThemeFor(ColorScheme scheme) { if (_cachedMaterialTheme != null && _cachedMaterialThemeScheme == scheme) { diff --git a/lib/features/command_palette/command_match_highlight.dart b/lib/features/command_palette/command_match_highlight.dart index 39ba1047..38c680e4 100644 --- a/lib/features/command_palette/command_match_highlight.dart +++ b/lib/features/command_palette/command_match_highlight.dart @@ -19,7 +19,7 @@ class CommandMatchHighlight extends StatelessWidget { final needle = q.toLowerCase(); final index = lower.indexOf(needle); if (index < 0) return Text(text); - final theme = Theme.of(context).colorScheme; + final colors = context.colors; return Text.rich( TextSpan( children: [ @@ -28,7 +28,7 @@ class CommandMatchHighlight extends StatelessWidget { text: text.substring(index, index + needle.length), style: TextStyle( fontWeight: FontWeight.w600, - color: theme.primary, + color: colors.primary, ), ), TextSpan(text: text.substring(index + needle.length)), diff --git a/lib/features/command_palette/command_palette_dialog.dart b/lib/features/command_palette/command_palette_dialog.dart index d1b7dc06..69a39412 100644 --- a/lib/features/command_palette/command_palette_dialog.dart +++ b/lib/features/command_palette/command_palette_dialog.dart @@ -156,7 +156,7 @@ class _CommandPaletteDialogState extends State { @override Widget build(BuildContext context) { - final theme = Theme.of(context); + final colors = context.colors; final hits = _hits; final selectedIndex = hits.isEmpty ? 0 : _selected.clamp(0, hits.length - 1); @@ -238,7 +238,7 @@ class _CommandPaletteDialogState extends State { child: DecoratedBox( decoration: BoxDecoration( color: active - ? theme.colorScheme.primary + ? colors.primary .withValues(alpha: 0.12) : Colors.transparent, borderRadius: BorderRadius.circular(6), diff --git a/lib/features/command_palette/quick_switcher_dialog.dart b/lib/features/command_palette/quick_switcher_dialog.dart index 3ddacdf7..9cc45c25 100644 --- a/lib/features/command_palette/quick_switcher_dialog.dart +++ b/lib/features/command_palette/quick_switcher_dialog.dart @@ -171,7 +171,6 @@ class _QuickSwitcherDialogState extends State { @override Widget build(BuildContext context) { - final theme = Theme.of(context); final hits = _hits; final selectedIndex = hits.isEmpty ? 0 : _selected.clamp(0, hits.length - 1); @@ -209,7 +208,7 @@ class _QuickSwitcherDialogState extends State { ), ), const QueryaDivider(), - Expanded(child: _body(theme.colorScheme, hits, selectedIndex)), + Expanded(child: _body(hits, selectedIndex)), ], ), ), @@ -218,7 +217,6 @@ class _QuickSwitcherDialogState extends State { } Widget _body( - ColorScheme colors, List hits, int selectedIndex, ) { @@ -276,7 +274,7 @@ class _QuickSwitcherDialogState extends State { child: DecoratedBox( decoration: BoxDecoration( color: active - ? colors.primary.withValues(alpha: 0.12) + ? context.colors.primary.withValues(alpha: 0.12) : Colors.transparent, borderRadius: BorderRadius.circular(6), ), diff --git a/lib/features/erd/erd_export_data.dart b/lib/features/erd/erd_export_data.dart index e2561b99..8f7407d5 100644 --- a/lib/features/erd/erd_export_data.dart +++ b/lib/features/erd/erd_export_data.dart @@ -4,8 +4,6 @@ import 'package:querya_desktop/core/erd/erd_model.dart'; import 'package:querya_desktop/core/erd/erd_saved_layout.dart'; import 'package:querya_desktop/core/theme/querya_theme_scope.dart'; import 'package:querya_desktop/features/erd/erd_export.dart'; -import 'package:shadcn_flutter/shadcn_flutter.dart' as shadcn - hide TextExtension; /// Turns what the diagram shows on screen (header tints, notes, group frames, /// theme colours) into the plain values the SVG / DBML export takes (#1362). @@ -93,7 +91,7 @@ abstract final class ErdExportData { border: hex(wb.borderSubtle), header: hex(material.Color.alphaBlend( wb.accent.withValues(alpha: 0.10), wb.surface)), - text: hex(shadcn.Theme.of(context).colorScheme.foreground), + text: hex(context.colors.foreground), muted: hex(wb.mutedForeground), edge: hex(wb.mutedForeground), primaryKey: hex(palette.type1), diff --git a/lib/features/erd/widgets/erd_edge_tip_label.dart b/lib/features/erd/widgets/erd_edge_tip_label.dart index 30afe693..14554bee 100644 --- a/lib/features/erd/widgets/erd_edge_tip_label.dart +++ b/lib/features/erd/widgets/erd_edge_tip_label.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart' as material; import 'package:querya_desktop/core/erd/erd_model.dart'; -import 'package:shadcn_flutter/shadcn_flutter.dart' hide Gap, TextExtension; +import 'package:querya_desktop/core/theme/querya_theme_scope.dart'; /// "orders.customer_id → customers.id" next to the pointer. class ErdEdgeTipLabel extends material.StatelessWidget { @@ -11,7 +11,7 @@ class ErdEdgeTipLabel extends material.StatelessWidget { @override material.Widget build(material.BuildContext context) { final r = relation; - final cs = Theme.of(context).colorScheme; + final cs = context.colors; return material.DecoratedBox( decoration: material.BoxDecoration( color: cs.popover, diff --git a/lib/features/erd/widgets/erd_note_card.dart b/lib/features/erd/widgets/erd_note_card.dart index 69b55bad..879b750e 100644 --- a/lib/features/erd/widgets/erd_note_card.dart +++ b/lib/features/erd/widgets/erd_note_card.dart @@ -59,7 +59,7 @@ class ErdNoteCard extends material.StatelessWidget { final color = n.color == null ? null : slotColor(n.color!); final lines = parseErdNote(n.text); final base = material.TextStyle( - fontSize: 12, color: Theme.of(context).colorScheme.foreground); + fontSize: 12, color: context.colors.foreground); return material.Positioned( left: n.x, top: n.y, diff --git a/lib/features/help/about_dialog.dart b/lib/features/help/about_dialog.dart index 64157193..69e98289 100644 --- a/lib/features/help/about_dialog.dart +++ b/lib/features/help/about_dialog.dart @@ -31,7 +31,7 @@ class _AboutDialogContentState extends material.State<_AboutDialogContent> { @override material.Widget build(material.BuildContext context) { - final theme = Theme.of(context).colorScheme; + final colors = context.colors; final wb = context.workbench; return QueryaDialogCard( @@ -40,7 +40,7 @@ class _AboutDialogContentState extends material.State<_AboutDialogContent> { maxWidth: 420, minWidth: 320, ), - borderColor: theme.muted, + borderColor: colors.muted, child: material.Column( mainAxisSize: material.MainAxisSize.min, children: [ diff --git a/lib/features/main_screen/querya_status_bar.dart b/lib/features/main_screen/querya_status_bar.dart index 54092c0a..8368a890 100644 --- a/lib/features/main_screen/querya_status_bar.dart +++ b/lib/features/main_screen/querya_status_bar.dart @@ -41,7 +41,7 @@ class QueryaStatusBar extends material.StatelessWidget { @override material.Widget build(material.BuildContext context) { final wb = context.workbench; - final theme = Theme.of(context); + final colors = context.colors; final isMac = Platform.isMacOS; final environment = activeConnection?.environment; @@ -114,7 +114,7 @@ class QueryaStatusBar extends material.StatelessWidget { style: material.TextStyle( fontSize: 11, fontWeight: material.FontWeight.w500, - color: theme.colorScheme.foreground, + color: colors.foreground, ), ), ), diff --git a/lib/features/main_screen/querya_window_title_bar.dart b/lib/features/main_screen/querya_window_title_bar.dart index 5bd6103a..59016800 100644 --- a/lib/features/main_screen/querya_window_title_bar.dart +++ b/lib/features/main_screen/querya_window_title_bar.dart @@ -65,13 +65,13 @@ class QueryaWindowTitleBar extends StatelessWidget { @visibleForTesting static WindowButtonColors windowButtonColors(BuildContext context) { final wb = context.workbench; - final cs = Theme.of(context).colorScheme; + final colors = context.colors; return WindowButtonColors( iconNormal: wb.mutedForeground, mouseOver: wb.surface.withValues(alpha: 0.85), mouseDown: wb.borderSubtle.withValues(alpha: 0.55), - iconMouseOver: cs.foreground, - iconMouseDown: cs.foreground, + iconMouseOver: colors.foreground, + iconMouseDown: colors.foreground, ); } diff --git a/lib/features/main_screen/workspace_empty_hero.dart b/lib/features/main_screen/workspace_empty_hero.dart index 9aa3bab1..7627eb11 100644 --- a/lib/features/main_screen/workspace_empty_hero.dart +++ b/lib/features/main_screen/workspace_empty_hero.dart @@ -98,7 +98,7 @@ class _WorkspaceEmptyHeroState extends State { @override Widget build(BuildContext context) { - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final wb = context.workbench; final showRecent = _loaded && _recent.isNotEmpty; @@ -325,7 +325,7 @@ class _RecentConnectionsSection extends StatelessWidget { @override Widget build(BuildContext context) { - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final wb = context.workbench; return material.Container( @@ -380,7 +380,7 @@ class _RecentConnectionRow extends StatelessWidget { @override Widget build(BuildContext context) { - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final subtitle = _connectionSubtitle(connection); return material.Material( @@ -473,7 +473,7 @@ class _InteractiveQuickStartRowState extends State<_InteractiveQuickStartRow> { @override Widget build(BuildContext context) { - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final wb = context.workbench; return material.MouseRegion( diff --git a/lib/features/main_screen/workspace_panel.dart b/lib/features/main_screen/workspace_panel.dart index 54a75aa5..18ad7406 100644 --- a/lib/features/main_screen/workspace_panel.dart +++ b/lib/features/main_screen/workspace_panel.dart @@ -207,7 +207,7 @@ class _WorkspacePanelState extends State { @override Widget build(BuildContext context) { - final theme = Theme.of(context); + final colors = context.colors; final activeConn = widget.activeConnection; final empty = material.Align( @@ -227,7 +227,7 @@ class _WorkspacePanelState extends State { activeBody = _cachedActiveBody ?? const material.SizedBox.expand(); } else { _lastConnectedId = activeConn.id; - activeBody = _buildActiveConnectionBody(theme, activeConn); + activeBody = _buildActiveConnectionBody(activeConn); _cachedActiveBody = activeBody; } @@ -236,7 +236,7 @@ class _WorkspacePanelState extends State { final connKey = activeConn?.id ?? _lastConnectedId ?? 0; return material.Container( - color: theme.colorScheme.background, + color: colors.background, child: QueryaSwitchingBody( index: activeConn == null ? 0 : 1, children: [ @@ -253,7 +253,6 @@ class _WorkspacePanelState extends State { } material.Widget _buildActiveConnectionBody( - ThemeData theme, ConnectionRow activeConn, ) { material.Widget? driverWorkspace; @@ -436,7 +435,7 @@ class _WorkspacePanelState extends State { material.Icon( material.Icons.error_outline_rounded, size: 36, - color: theme.colorScheme.mutedForeground, + color: context.colors.mutedForeground, ), const material.SizedBox(height: 12), const Text('Unsupported connection type').semiBold(), diff --git a/lib/features/onboarding/welcome_tour_dialog.dart b/lib/features/onboarding/welcome_tour_dialog.dart index 1d36b2d4..e727743b 100644 --- a/lib/features/onboarding/welcome_tour_dialog.dart +++ b/lib/features/onboarding/welcome_tour_dialog.dart @@ -6,6 +6,7 @@ import 'package:flutter/services.dart'; import 'package:querya_desktop/core/layout/window_layout.dart'; import 'package:querya_desktop/core/storage/app_settings.dart'; import 'package:querya_desktop/core/theme/querya_typography.dart'; +import 'package:querya_desktop/core/theme/querya_ui_colors.dart'; import 'package:querya_desktop/core/theme/querya_workbench_theme.dart'; import 'package:querya_desktop/shared/widgets/widgets.dart'; import 'package:querya_desktop/core/ui/querya_control_tokens.dart'; @@ -80,7 +81,7 @@ class KbdBadge extends StatelessWidget { fontWeight: material.FontWeight.w600, fontFamily: QueryaTypography.mono, fontFamilyFallback: QueryaTypography.monoFontFamilyFallback, - color: Theme.of(context).colorScheme.foreground, + color: context.colors.foreground, ), ), ), @@ -205,7 +206,7 @@ class _WelcomeTourDialogState extends State { @override Widget build(BuildContext context) { - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final wb = context.workbench; final isMac = Platform.isMacOS; @@ -399,7 +400,7 @@ onPressed: _finish, Widget _buildSlideContent({ required int step, required String cmdCtrl, - required ColorScheme cs, + required QueryaUiColors cs, required QueryaWorkbenchTheme wb, }) { switch (step) { @@ -601,9 +602,7 @@ class _TourSlideView extends StatelessWidget { tipText, style: TextStyle( fontSize: 12.5, - color: Theme.of(context) - .colorScheme - .foreground + color: context.colors.foreground .withValues(alpha: 0.9), height: 1.35, ), @@ -750,7 +749,7 @@ class _HotkeysMatrixSlideView extends StatelessWidget { label, style: TextStyle( fontSize: 12, - color: Theme.of(context).colorScheme.foreground, + color: context.colors.foreground, fontWeight: material.FontWeight.w500, ), ), diff --git a/lib/features/recovery/querya_startup_recovery_app.dart b/lib/features/recovery/querya_startup_recovery_app.dart index 63e5561d..2176403a 100644 --- a/lib/features/recovery/querya_startup_recovery_app.dart +++ b/lib/features/recovery/querya_startup_recovery_app.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart' as material; import 'package:querya_desktop/app/app.dart'; import 'package:querya_desktop/core/storage/app_data_root.dart'; import 'package:querya_desktop/core/storage/local_db.dart'; +import 'package:querya_desktop/core/theme/querya_theme.dart'; import 'package:querya_desktop/core/theme/querya_typography.dart'; import 'package:querya_desktop/core/theme/theme_controller.dart'; import 'package:querya_desktop/core/ui/querya_icons.dart'; @@ -124,8 +125,7 @@ class _QueryaStartupRecoveryAppState @override material.Widget build(material.BuildContext context) { - final themeData = ThemeController.instance.darkShadcnTheme; - final colorScheme = themeData.colorScheme; + final colors = QueryaTheme.darkDefault.colors; return ShadcnApp( title: 'Querya - Startup Recovery', @@ -134,14 +134,14 @@ class _QueryaStartupRecoveryAppState themeMode: ThemeMode.dark, debugShowCheckedModeBanner: false, home: material.Scaffold( - backgroundColor: colorScheme.background, + backgroundColor: colors.background, body: material.Center( child: material.SingleChildScrollView( padding: const material.EdgeInsets.all(32), child: material.ConstrainedBox( constraints: const material.BoxConstraints(maxWidth: 640), child: QueryaDialogCard( - borderColor: colorScheme.destructive, + borderColor: colors.destructive, child: material.Padding( padding: const material.EdgeInsets.all(28), child: material.Column( @@ -153,7 +153,7 @@ class _QueryaStartupRecoveryAppState material.Icon( QueryaIcons.treeError, size: 32, - color: colorScheme.destructive, + color: colors.destructive, ), const material.SizedBox(width: 12), const material.Expanded( @@ -174,10 +174,10 @@ class _QueryaStartupRecoveryAppState width: double.infinity, padding: const material.EdgeInsets.all(12), decoration: material.BoxDecoration( - color: colorScheme.muted.withOpacity(0.3), + color: colors.muted.withOpacity(0.3), borderRadius: material.BorderRadius.circular(6), border: material.Border.all( - color: colorScheme.border, + color: colors.border, ), ), child: material.SelectableText( @@ -197,8 +197,8 @@ class _QueryaStartupRecoveryAppState padding: const material.EdgeInsets.all(10), decoration: material.BoxDecoration( color: (_isErrorStatus - ? colorScheme.destructive - : colorScheme.primary) + ? colors.destructive + : colors.primary) .withOpacity(0.15), borderRadius: material.BorderRadius.circular(6), ), @@ -206,8 +206,8 @@ class _QueryaStartupRecoveryAppState _statusMessage!, style: material.TextStyle( color: _isErrorStatus - ? colorScheme.destructive - : colorScheme.primary, + ? colors.destructive + : colors.primary, fontSize: 13, fontWeight: material.FontWeight.w500, ), diff --git a/lib/features/results/charts/quick_chart_view.dart b/lib/features/results/charts/quick_chart_view.dart index e03afaf2..b20161f2 100644 --- a/lib/features/results/charts/quick_chart_view.dart +++ b/lib/features/results/charts/quick_chart_view.dart @@ -597,7 +597,7 @@ class _QuickChartViewState extends material.State { material.BuildContext context, List points, double width) { final palette = context.semanticPalette; final wb = context.workbench; - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final label = material.TextStyle(color: wb.mutedForeground, fontSize: 10); final step = (points.length / 8).ceil().clamp(1, 1000); // Labels shown: one per step. Rotate them when a slot is too narrow. diff --git a/lib/features/updater/update_changelog_view.dart b/lib/features/updater/update_changelog_view.dart index bfc565bb..7661f25a 100644 --- a/lib/features/updater/update_changelog_view.dart +++ b/lib/features/updater/update_changelog_view.dart @@ -1,7 +1,8 @@ import 'dart:convert'; import 'package:flutter/material.dart' as material; -import 'package:shadcn_flutter/shadcn_flutter.dart' hide Gap, TextExtension; +import 'package:flutter/widgets.dart' show StatelessWidget, Text; +import 'package:querya_desktop/core/theme/querya_theme_scope.dart'; import 'package:querya_desktop/shared/widgets/querya_text.dart'; /// Lightweight Markdown-ish renderer for GitHub release notes. @@ -86,7 +87,7 @@ class UpdateChangelogView extends StatelessWidget { return material.SelectionArea( child: material.DefaultTextStyle( style: material.TextStyle( - color: Theme.of(context).colorScheme.foreground, + color: context.colors.foreground, height: 1.45, ), child: material.Column( diff --git a/lib/features/updater/update_dialog.dart b/lib/features/updater/update_dialog.dart index 2b8c75dd..5a8405c5 100644 --- a/lib/features/updater/update_dialog.dart +++ b/lib/features/updater/update_dialog.dart @@ -430,7 +430,7 @@ class UpdateDialogContentState extends material.State { @override material.Widget build(material.BuildContext context) { - final theme = Theme.of(context).colorScheme; + final colors = context.colors; final wb = context.workbench; return QueryaDialogCard( @@ -440,7 +440,7 @@ class UpdateDialogContentState extends material.State { minWidth: 360, maxHeight: 640, ), - borderColor: theme.muted, + borderColor: colors.muted, child: material.Column( mainAxisSize: material.MainAxisSize.min, crossAxisAlignment: material.CrossAxisAlignment.stretch, @@ -499,7 +499,7 @@ class UpdateDialogContentState extends material.State { decoration: material.BoxDecoration( border: material.Border( top: material.BorderSide( - color: theme.border.withValues(alpha: 0.3), + color: colors.border.withValues(alpha: 0.3), ), ), ), diff --git a/lib/shared/widgets/connection_tree_loading_row.dart b/lib/shared/widgets/connection_tree_loading_row.dart index b11651b7..fea12d6f 100644 --- a/lib/shared/widgets/connection_tree_loading_row.dart +++ b/lib/shared/widgets/connection_tree_loading_row.dart @@ -43,10 +43,7 @@ class ConnectionTreeLoadingRow extends material.StatelessWidget { label, style: material.DefaultTextStyle.of(context).style.copyWith( fontSize: 12, - color: QueryaThemeScope.maybeOf(context) - ?.workbench - .mutedForeground ?? - material.Theme.of(context).colorScheme.onSurfaceVariant, + color: context.workbench.mutedForeground, ), ), ], diff --git a/lib/shared/widgets/poll_stale_overlay.dart b/lib/shared/widgets/poll_stale_overlay.dart index a4d24e52..625d74dd 100644 --- a/lib/shared/widgets/poll_stale_overlay.dart +++ b/lib/shared/widgets/poll_stale_overlay.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart' show ValueListenable; import 'package:flutter/material.dart'; import 'package:querya_desktop/core/motion/polling_controller.dart'; +import 'package:querya_desktop/core/theme/querya_theme_scope.dart'; /// Shows [child] with a small "out of date" note in the top-right corner while /// the latest poll failed, so a dashboard that kept its last good numbers does @@ -30,13 +31,13 @@ class PollStaleOverlay extends StatelessWidget { valueListenable: status, builder: (context, s, _) { if (!s.isStale) return const SizedBox.shrink(); - final scheme = Theme.of(context).colorScheme; + final colors = context.colors; return Tooltip( message: '${s.lastError}', child: DecoratedBox( key: const ValueKey('poll_stale_hint'), decoration: BoxDecoration( - color: scheme.errorContainer, + color: colors.destructive.withValues(alpha: 0.15), borderRadius: BorderRadius.circular(6), ), child: Padding( @@ -46,7 +47,7 @@ class PollStaleOverlay extends StatelessWidget { message(s), style: TextStyle( fontSize: 12, - color: scheme.onErrorContainer, + color: colors.destructive, ), ), ), diff --git a/lib/shared/widgets/query_error_view.dart b/lib/shared/widgets/query_error_view.dart index deda373f..cb073540 100644 --- a/lib/shared/widgets/query_error_view.dart +++ b/lib/shared/widgets/query_error_view.dart @@ -55,7 +55,7 @@ class _QueryErrorViewState extends material.State { @override material.Widget build(material.BuildContext context) { - final cs = Theme.of(context).colorScheme; + final cs = context.colors; final error = widget.error; final inline = widget.inline; final align = inline diff --git a/lib/shared/widgets/querya_badge.dart b/lib/shared/widgets/querya_badge.dart index 554efe3c..a40b7e90 100644 --- a/lib/shared/widgets/querya_badge.dart +++ b/lib/shared/widgets/querya_badge.dart @@ -106,7 +106,7 @@ class QueryaBadge extends material.StatelessWidget { @override material.Widget build(material.BuildContext context) { - final cs = context.queryaTheme.colorScheme; + final cs = context.colors; final workbench = QueryaThemeScope.maybeOf(context)?.workbench; final palette = context.semanticPalette; diff --git a/lib/shared/widgets/querya_dropdown.dart b/lib/shared/widgets/querya_dropdown.dart index 476ff60d..557e321d 100644 --- a/lib/shared/widgets/querya_dropdown.dart +++ b/lib/shared/widgets/querya_dropdown.dart @@ -211,7 +211,7 @@ class _QueryaDropdownState extends material.State> { item: item, selected: item.value == widget.value, enabled: widget.enabled && item.enabled, - colorScheme: cs, + colors: cs, compact: widget.compact, size: size, onPick: () { @@ -503,7 +503,7 @@ class _QueryaDropdownMenuItem extends material.StatefulWidget { required this.item, required this.selected, required this.enabled, - required this.colorScheme, + required this.colors, required this.compact, required this.size, required this.onPick, @@ -512,7 +512,7 @@ class _QueryaDropdownMenuItem extends material.StatefulWidget { final QueryaDropdownItem item; final bool selected; final bool enabled; - final QueryaUiColors colorScheme; + final QueryaUiColors colors; final bool compact; final QueryaControlSize size; final material.VoidCallback onPick; @@ -545,7 +545,7 @@ class _QueryaDropdownMenuItemState @override material.Widget build(material.BuildContext context) { - final cs = widget.colorScheme; + final cs = widget.colors; final bg = (_hovered || _focused) ? cs.accent.withValues(alpha: 0.14) : widget.selected diff --git a/lib/shared/widgets/querya_spinner.dart b/lib/shared/widgets/querya_spinner.dart index 5d6e70e5..3c680131 100644 --- a/lib/shared/widgets/querya_spinner.dart +++ b/lib/shared/widgets/querya_spinner.dart @@ -48,11 +48,11 @@ class QueryaSpinner extends material.StatelessWidget { material.Widget build(material.BuildContext context) { final theme = QueryaThemeScope.maybeOf(context); final workbench = theme?.workbench; - final fallback = material.Theme.of(context).colorScheme; + final colors = context.colors; final dimension = customDimension ?? size.dimension; final stroke = strokeWidth ?? size.strokeWidth; - final effectiveColor = color ?? workbench?.accent ?? fallback.primary; + final effectiveColor = color ?? workbench?.accent ?? colors.primary; final spinner = material.SizedBox( width: dimension, @@ -77,7 +77,7 @@ class QueryaSpinner extends material.StatelessWidget { label!, style: material.TextStyle( fontSize: size == QueryaSpinnerSize.sm ? 11 : 12, - color: workbench?.mutedForeground ?? fallback.onSurfaceVariant, + color: workbench?.mutedForeground ?? colors.mutedForeground, ), ), ], diff --git a/lib/shared/widgets/tree_load_error.dart b/lib/shared/widgets/tree_load_error.dart index 3a481bfa..440c7b11 100644 --- a/lib/shared/widgets/tree_load_error.dart +++ b/lib/shared/widgets/tree_load_error.dart @@ -31,9 +31,9 @@ class TreeLoadError extends material.StatelessWidget { @override material.Widget build(material.BuildContext context) { - final theme = Theme.of(context); - final destructive = theme.colorScheme.destructive; - final muted = theme.colorScheme.mutedForeground; + final colors = context.colors; + final destructive = colors.destructive; + final muted = colors.mutedForeground; return material.Padding( padding: padding, diff --git a/test/guards/colors_through_context_test.dart b/test/guards/colors_through_context_test.dart index d7e933ba..72cfcd50 100644 --- a/test/guards/colors_through_context_test.dart +++ b/test/guards/colors_through_context_test.dart @@ -8,15 +8,25 @@ import 'package:flutter_test/flutter_test.dart'; /// [migrated] in the PR that moves it; at the end the list is all of `lib/`. 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'); diff --git a/test/guards/shadcn_imports_ratchet_test.dart b/test/guards/shadcn_imports_ratchet_test.dart index 0349ccd1..c6c4171e 100644 --- a/test/guards/shadcn_imports_ratchet_test.dart +++ b/test/guards/shadcn_imports_ratchet_test.dart @@ -23,9 +23,7 @@ void main() { 'lib/core/theme/querya_theme_scope.dart', 'lib/core/theme/theme_controller.dart', 'lib/core/theme/theme_editor_draft.dart', - 'lib/features/erd/erd_export_data.dart', 'lib/features/erd/erd_view.dart', - 'lib/features/erd/widgets/erd_edge_tip_label.dart', 'lib/features/erd/widgets/erd_group_frame.dart', 'lib/features/erd/widgets/erd_group_menu.dart', 'lib/features/erd/widgets/erd_note_card.dart', @@ -35,7 +33,6 @@ void main() { 'lib/features/mongodb/mongo_documents_json_view.dart', 'lib/features/mongodb/mongo_documents_table_view.dart', 'lib/features/settings/preferences_controls.dart', - 'lib/features/updater/update_changelog_view.dart', 'lib/features/workspace/data_grid_calc_bar.dart', 'lib/features/workspace/data_grid_filter_bar.dart', 'lib/features/workspace/data_grid_value_panel.dart',