Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Web: even out the phone search row's icons (#1760)

Jacob Phamd77fd5d8cf97
diff --git a/desktop/lib/widgets/desktop_search_panel.dart b/desktop/lib/widgets/desktop_search_panel.dart
index 68a0c97da..b00c7db42 100644
--- a/desktop/lib/widgets/desktop_search_panel.dart
+++ b/desktop/lib/widgets/desktop_search_panel.dart
@@ -94,8 +94,12 @@ class DesktopSearchPanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
- // A phone's buttons are a finger's size; a mouse keeps 32.
- final button = workspaceIsCompact(context) ? kFingerTarget : 32.0;
+ // A phone's buttons are a finger's size; a mouse keeps 32. On a phone the
+ // three glyphs share one size, and the row's right inset puts Close's glyph
+ // as far from the edge as the search glyph is on the left.
+ final compact = workspaceIsCompact(context);
+ final button = compact ? kFingerTarget : 32.0;
+ final glyph = compact ? 20.0 : 18.0;
return DesktopChrome(
child: Align(
alignment: Alignment.topCenter,
@@ -150,7 +154,12 @@ class DesktopSearchPanel extends StatelessWidget {
),
),
Padding(
- padding: const EdgeInsets.fromLTRB(24, 12, 16, 8),
+ padding: EdgeInsets.fromLTRB(
+ 24,
+ 12,
+ compact ? 24 - (kFingerTarget - glyph) / 2 : 16,
+ 8,
+ ),
child: Row(
children: [
Icon(
@@ -190,7 +199,7 @@ class DesktopSearchPanel extends StatelessWidget {
},
icon: Icon(
AppIcons.circleX,
- size: 16,
+ size: compact ? glyph : 16,
color: DesktopChrome.muted,
),
),
@@ -211,9 +220,9 @@ class DesktopSearchPanel extends StatelessWidget {
onRefocus();
}
: null,
- icon: const AppPaneIcon(
+ icon: AppPaneIcon(
AppPaneSymbol.splitRight,
- size: 18,
+ size: glyph,
),
),
),
@@ -222,7 +231,7 @@ class DesktopSearchPanel extends StatelessWidget {
key: const ValueKey('search-close'),
tooltip: 'Close search',
onPressed: onClose,
- icon: const Icon(AppIcons.close, size: 18),
+ icon: Icon(AppIcons.close, size: glyph),
),
],
),
diff --git a/desktop/test/web_search_phone_test.dart b/desktop/test/web_search_phone_test.dart
index 12ffc68ed..29265be96 100644
--- a/desktop/test/web_search_phone_test.dart
+++ b/desktop/test/web_search_phone_test.dart
@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/screens/swarm_screen.dart';
+import 'package:harness/shared/theme/app_icons.dart';
+import 'package:harness/shared/theme/app_pane_icon.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/web/shell/web_chrome.dart';
@@ -66,6 +68,47 @@ void main() {
await _close(tester);
});
+ testWidgets('a phone\'s search row draws its glyphs alike and evenly', (
+ tester,
+ ) async {
+ await _openSearch(tester, const Size(390, 844));
+ await tester.enterText(
+ find.byKey(const ValueKey('swarm-search-input')),
+ '@',
+ );
+ await tester.pump(const Duration(milliseconds: 300));
+ Rect glyphIn(Finder parent, bool Function(Widget) isGlyph) =>
+ tester.getRect(
+ find
+ .descendant(of: parent, matching: find.byWidgetPredicate(isGlyph))
+ .first,
+ );
+ Rect glyphOf(String key) => glyphIn(
+ find.byKey(ValueKey(key)),
+ (w) => w is Icon || w is AppPaneIcon,
+ );
+ final sizes = {
+ for (final key in [
+ 'search-clear-query',
+ 'search-toggle-preview',
+ 'search-close',
+ ])
+ glyphOf(key).width,
+ };
+ expect(sizes, {20.0});
+ final panel = find.byKey(const ValueKey('swarm-search-results'));
+ final edges = tester.getRect(panel);
+ final search = glyphIn(
+ panel,
+ (w) => w is Icon && w.icon == AppIcons.search,
+ );
+ expect(
+ edges.right - glyphOf('search-close').right,
+ closeTo(search.left - edges.left, 0.5),
+ );
+ await _close(tester);
+ });
+
testWidgets('a wide window keeps the mouse-sized search controls', (
tester,
) async {