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
41 changes: 26 additions & 15 deletions lib/features/settings/preferences_shortcuts_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,30 +381,40 @@ class _PreferencesShortcutsSectionState
),
),
const material.SizedBox(width: 12),
material.Row(
mainAxisSize: material.MainAxisSize.min,
children: [
for (var c = 0; c < item.allKeys.length; c++) ...[
if (c > 0)
material.Padding(
padding: const material.EdgeInsets.symmetric(horizontal: 6),
child: const Text('or').muted().xSmall(),
),
..._keycaps(item.allKeys[c], theme),
material.Flexible(
child: material.Wrap(
alignment: material.WrapAlignment.end,
crossAxisAlignment: material.WrapCrossAlignment.center,
spacing: 4,
runSpacing: 4,
children: [
for (var c = 0; c < item.allKeys.length; c++) ...[
if (c > 0)
material.Padding(
padding: const material.EdgeInsets.symmetric(horizontal: 4),
child: const Text('or').muted().xSmall(),
),
..._keycaps(context, item.allKeys[c], theme),
],
],
],
),
),
],
),
);
}

List<material.Widget> _keycaps(List<String> keys, ThemeData theme) {
List<material.Widget> _keycaps(
BuildContext context,
List<String> keys,
ThemeData theme,
) {
final wb = context.workbenchOrDefault;
return [
for (var j = 0; j < keys.length; j++) ...[
if (j > 0)
material.Padding(
padding: const material.EdgeInsets.symmetric(horizontal: 3),
padding: const material.EdgeInsets.symmetric(horizontal: 2),
child: const Text('+').muted().xSmall(),
),
material.Container(
Expand All @@ -413,14 +423,14 @@ class _PreferencesShortcutsSectionState
vertical: 3,
),
decoration: material.BoxDecoration(
color: theme.colorScheme.background,
color: wb.surface,
borderRadius: material.BorderRadius.circular(4),
border: material.Border.all(
color: theme.colorScheme.border.withValues(alpha: 0.4),
),
boxShadow: [
material.BoxShadow(
color: material.Colors.black.withValues(alpha: 0.08),
color: wb.shadow.withValues(alpha: 0.12),
offset: const material.Offset(0, 1),
blurRadius: 1,
),
Expand All @@ -430,6 +440,7 @@ class _PreferencesShortcutsSectionState
keys[j],
style: material.TextStyle(
fontFamily: QueryaTypography.mono,
fontFamilyFallback: QueryaTypography.monoFontFamilyFallback,
fontSize: 11,
fontWeight: material.FontWeight.w600,
color: theme.colorScheme.foreground,
Expand Down
35 changes: 35 additions & 0 deletions test/features/settings/preferences_shortcuts_section_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import 'package:flutter/material.dart' as material;
import 'package:flutter_test/flutter_test.dart';
import 'package:querya_desktop/core/theme/querya_theme.dart';
import 'package:querya_desktop/core/theme/querya_typography.dart';
import 'package:querya_desktop/features/settings/preferences_shortcuts_section.dart';
import 'package:querya_desktop/shared/widgets/widgets.dart';

import '../../support/querya_theme_test_shell.dart';

void main() {
Widget buildTestWidget({String searchQuery = ''}) {
return ShadcnApp(
Expand Down Expand Up @@ -104,5 +108,36 @@ void main() {
expect(find.text('No shortcuts match "xyzunknown"'), findsOneWidget);
expect(find.text('Execute query / selection'), findsNothing);
});

testWidgets('uses mono font fallback and does not overflow under narrow constraints (#1652)',
(tester) async {
tester.view.physicalSize = const material.Size(320, 600);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);

await tester.pumpWidget(
queryaThemeTestShell(
data: QueryaTheme.darkDefault,
child: const material.Scaffold(
body: material.SingleChildScrollView(
child: PreferencesShortcutsSection(),
),
),
),
);
await tester.pumpAndSettle();

// No RenderFlex overflow should occur.
expect(tester.takeException(), isNull);

// Verify mono font and fallback stack on keycaps.
final f5Key = tester.widget<material.Text>(find.text('F5').first);
expect(f5Key.style?.fontFamily, QueryaTypography.mono);
expect(
f5Key.style?.fontFamilyFallback,
QueryaTypography.monoFontFamilyFallback,
);
});
});
}
Loading