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
3 changes: 2 additions & 1 deletion lib/features/settings/preferences_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down
21 changes: 13 additions & 8 deletions lib/features/settings/theme_editor_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -149,19 +151,22 @@ class _ThemeEditorDialogState extends material.State<ThemeEditorDialog> {
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: [
Expand Down Expand Up @@ -253,7 +258,7 @@ class _ThemeEditorDialogState extends material.State<ThemeEditorDialog> {
],
),
),
),
),
actions: [
QueryaButton.secondary(
label: 'Reset from current',
Expand Down
4 changes: 3 additions & 1 deletion lib/shared/widgets/querya_modal_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions test/features/settings/preferences_master_detail_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<material.Container>(railContainer);
expect(containerWidget.constraints?.maxWidth, 184 * 1.5);
});
});
}
32 changes: 32 additions & 0 deletions test/features/settings/theme_editor_dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<QueryaModalDialog>(modalFinder);
expect(modalWidget.constraints.maxWidth, 580 * 1.25);
expect(modalWidget.constraints.maxHeight, 600 * 1.25);

await tester.tap(find.text('Done'));
await tester.pumpAndSettle();
});
});
}
3 changes: 2 additions & 1 deletion test/support/querya_theme_test_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(),
Expand Down
Loading