From 4eba9f856742f706f7033bee2ab23043179fcab8 Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Sat, 17 Oct 2026 07:21:58 +0300 Subject: [PATCH] ui(settings): adapt left category rail width to UI scale and make theme editor responsive (#1653) --- lib/features/settings/preferences_dialog.dart | 3 +- .../settings/theme_editor_dialog.dart | 21 +++++++----- lib/shared/widgets/querya_modal_dialog.dart | 4 ++- .../preferences_master_detail_test.dart | 23 +++++++++++++ .../settings/theme_editor_dialog_test.dart | 32 +++++++++++++++++++ test/support/querya_theme_test_shell.dart | 3 +- 6 files changed, 75 insertions(+), 11 deletions(-) diff --git a/lib/features/settings/preferences_dialog.dart b/lib/features/settings/preferences_dialog.dart index 71ac9cd4..8e35828b 100644 --- a/lib/features/settings/preferences_dialog.dart +++ b/lib/features/settings/preferences_dialog.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart' as material; import 'package:flutter/services.dart' show LogicalKeyboardKey; +import 'package:querya_desktop/core/layout/ui_scale.dart'; import 'package:querya_desktop/core/layout/window_layout.dart'; import 'package:querya_desktop/core/storage/app_settings.dart'; import 'package:querya_desktop/core/updater/update_manifest.dart'; @@ -374,7 +375,7 @@ class PreferencesDialogContentState children: [ // Left Category Rail material.Container( - width: 184, + width: context.scaled(184), decoration: material.BoxDecoration( border: material.Border( right: material.BorderSide( diff --git a/lib/features/settings/theme_editor_dialog.dart b/lib/features/settings/theme_editor_dialog.dart index b7ba96af..66420771 100644 --- a/lib/features/settings/theme_editor_dialog.dart +++ b/lib/features/settings/theme_editor_dialog.dart @@ -3,6 +3,8 @@ import 'dart:io'; import 'package:file_selector/file_selector.dart'; import 'package:flutter/material.dart' as material; +import 'package:querya_desktop/core/layout/ui_scale.dart'; +import 'package:querya_desktop/core/layout/window_layout.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/querya_typography.dart'; @@ -149,19 +151,22 @@ class _ThemeEditorDialogState extends material.State { final cs = theme.colorScheme; return QueryaModalDialog( - constraints: const material.BoxConstraints(maxWidth: 580), + constraints: WindowLayout.dialogConstraints( + context, + maxWidth: 580, + maxHeight: 600, + ), title: const Text('Theme Studio'), description: const Text('Customize color tokens with real-time UI preview'), icon: const material.Icon(material.Icons.palette_outlined), showCloseButton: true, content: material.SizedBox( - width: 540, - height: 480, + width: context.scaled(540), child: _loading - ? const material.Center( - child: QueryaSpinner(size: QueryaSpinnerSize.lg), - ) - : material.SingleChildScrollView( + ? const material.Center( + child: QueryaSpinner(size: QueryaSpinnerSize.lg), + ) + : material.SingleChildScrollView( child: material.Column( crossAxisAlignment: material.CrossAxisAlignment.start, children: [ @@ -253,7 +258,7 @@ class _ThemeEditorDialogState extends material.State { ], ), ), - ), + ), actions: [ QueryaButton.secondary( label: 'Reset from current', diff --git a/lib/shared/widgets/querya_modal_dialog.dart b/lib/shared/widgets/querya_modal_dialog.dart index a551cdea..8432b600 100644 --- a/lib/shared/widgets/querya_modal_dialog.dart +++ b/lib/shared/widgets/querya_modal_dialog.dart @@ -139,7 +139,9 @@ class QueryaModalDialog extends material.StatelessWidget { // Content if (content != null) ...[ const material.SizedBox(height: 16), - content!, + constraints.hasBoundedHeight + ? material.Flexible(child: content!) + : content!, ], // Actions diff --git a/test/features/settings/preferences_master_detail_test.dart b/test/features/settings/preferences_master_detail_test.dart index 3d12141b..20ca31d9 100644 --- a/test/features/settings/preferences_master_detail_test.dart +++ b/test/features/settings/preferences_master_detail_test.dart @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:querya_desktop/core/storage/app_settings.dart'; import 'package:querya_desktop/core/storage/local_db.dart'; +import 'package:querya_desktop/core/layout/ui_scale.dart'; import 'package:querya_desktop/core/theme/app_theme.dart'; import 'package:querya_desktop/features/settings/preferences_controls.dart'; import 'package:querya_desktop/features/settings/preferences_dialog.dart'; @@ -226,5 +227,27 @@ void main() { expect(currentValue, isTrue); }); + + testWidgets('adapts category rail width to UI scale (#1653)', (tester) async { + await tester.pumpWidget( + QueryaUiScaleScope( + scale: 1.5, + child: buildTestApp(), + ), + ); + await openDialog(tester); + + final railScrollView = find.ancestor( + of: find.text('General').first, + matching: find.byType(material.SingleChildScrollView), + ); + final railContainer = find.ancestor( + of: railScrollView, + matching: find.byType(material.Container), + ).first; + + final containerWidget = tester.widget(railContainer); + expect(containerWidget.constraints?.maxWidth, 184 * 1.5); + }); }); } diff --git a/test/features/settings/theme_editor_dialog_test.dart b/test/features/settings/theme_editor_dialog_test.dart index b23a9b61..4dec0733 100644 --- a/test/features/settings/theme_editor_dialog_test.dart +++ b/test/features/settings/theme_editor_dialog_test.dart @@ -10,6 +10,7 @@ import 'package:querya_desktop/core/theme/theme_controller.dart'; import 'package:querya_desktop/core/theme/theme_editor_draft.dart'; import 'package:querya_desktop/core/theme/theme_registry_service.dart'; import 'package:querya_desktop/features/settings/theme_editor_dialog.dart'; +import 'package:querya_desktop/shared/widgets/widgets.dart'; import '../../support/querya_theme_test_shell.dart'; @@ -116,5 +117,36 @@ void main() { expect(find.text('Theme Studio'), findsNothing); }); + + testWidgets('applies WindowLayout.dialogConstraints to Theme Studio modal (#1653)', + (tester) async { + await tester.binding.setSurfaceSize(const material.Size(1280, 900)); + await tester.pumpWidget( + queryaThemeTestShell( + uiScale: 1.25, + child: material.Scaffold( + body: material.Builder( + builder: (context) => material.ElevatedButton( + onPressed: () => showThemeEditorDialog(context), + child: const material.Text('Open'), + ), + ), + ), + ), + ); + await tester.pumpAndSettle(); + + await tester.tap(find.text('Open')); + await tester.pumpAndSettle(); + + final modalFinder = find.byType(QueryaModalDialog); + expect(modalFinder, findsOneWidget); + final modalWidget = tester.widget(modalFinder); + expect(modalWidget.constraints.maxWidth, 580 * 1.25); + expect(modalWidget.constraints.maxHeight, 600 * 1.25); + + await tester.tap(find.text('Done')); + await tester.pumpAndSettle(); + }); }); } diff --git a/test/support/querya_theme_test_shell.dart b/test/support/querya_theme_test_shell.dart index 16604034..dd3f26fc 100644 --- a/test/support/querya_theme_test_shell.dart +++ b/test/support/querya_theme_test_shell.dart @@ -8,6 +8,7 @@ Widget queryaThemeTestShell({ required Widget child, QueryaTheme data = QueryaTheme.darkDefault, ThemeData? theme, + double uiScale = 1.0, }) { final td = theme ?? data.toShadcnThemeData(); return ShadcnApp( @@ -18,7 +19,7 @@ Widget queryaThemeTestShell({ // binding reports, and a sheet needs a DrawerOverlay the app does not have. menuHandler: const PopoverOverlayHandler(), builder: (context, appChild) => QueryaUiScaleScope( - scale: 1.0, + scale: uiScale, child: QueryaThemeScope( data: data, child: appChild ?? const SizedBox.shrink(),