update search box design

This commit is contained in:
Fabian Freund
2026-03-12 16:26:14 +01:00
parent df69498fbe
commit a378bc697f
2 changed files with 178 additions and 164 deletions
@@ -232,7 +232,8 @@ class SearchScreen extends HookConsumerWidget {
final measuredHeight = getTextFieldHeight(textFieldKey); final measuredHeight = getTextFieldHeight(textFieldKey);
if (measuredHeight != null) { if (measuredHeight != null) {
preferredHeight.value = measuredHeight; // Add 2px to account for SearchField container border
preferredHeight.value = measuredHeight + 2;
return; return;
} }
} }
@@ -458,7 +459,7 @@ class SearchScreen extends HookConsumerWidget {
title: isEditMode title: isEditMode
? null ? null
: Padding( : Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Builder( child: Builder(
builder: (context) { builder: (context) {
final tabTypeSwitcher = Focus( final tabTypeSwitcher = Focus(
@@ -529,8 +530,6 @@ class SearchScreen extends HookConsumerWidget {
), ),
bottom: PreferredSize( bottom: PreferredSize(
preferredSize: Size.fromHeight(preferredHeight.value), preferredSize: Size.fromHeight(preferredHeight.value),
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: SearchField( child: SearchField(
textFieldKey: textFieldKey, textFieldKey: textFieldKey,
showBangIcon: showBangIcon, showBangIcon: showBangIcon,
@@ -595,9 +594,7 @@ class SearchScreen extends HookConsumerWidget {
if (isEditMode) { if (isEditMode) {
// Load into existing tab // Load into existing tab
await ref await ref
.read( .read(tabSessionProvider(tabId: tabId).notifier)
tabSessionProvider(tabId: tabId).notifier,
)
.loadUrl(url: newUrl); .loadUrl(url: newUrl);
} else { } else {
// Create new tab // Create new tab
@@ -612,8 +609,7 @@ class SearchScreen extends HookConsumerWidget {
: null, : null,
launchedFromIntent: launchedFromIntent, launchedFromIntent: launchedFromIntent,
selectTab: true, selectTab: true,
containerSelection: containerSelection: selectedContainer == null
selectedContainer == null
? const TabContainerSelection.unassigned() ? const TabContainerSelection.unassigned()
: TabContainerSelection.specific( : TabContainerSelection.specific(
selectedContainer, selectedContainer,
@@ -636,7 +632,6 @@ class SearchScreen extends HookConsumerWidget {
), ),
), ),
), ),
),
SliverToBoxAdapter( SliverToBoxAdapter(
child: ClipboardFillLink(controller: searchTextController), child: ClipboardFillLink(controller: searchTextController),
), ),
@@ -107,7 +107,17 @@ class SearchField extends HookConsumerWidget {
); );
} }
return AutoSuggestTextField( final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(
color: colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: colorScheme.outlineVariant),
),
child: AutoSuggestTextField(
controller: textEditingController, controller: textEditingController,
suggestion: suggestion.value, suggestion: suggestion.value,
enableIMEPersonalizedLearning: !incognitoEnabled, enableIMEPersonalizedLearning: !incognitoEnabled,
@@ -121,6 +131,7 @@ class SearchField extends HookConsumerWidget {
autofocus: autofocus, autofocus: autofocus,
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
contentPadding: const EdgeInsetsDirectional.fromSTEB(12, 12, 0, 12),
prefixIcon: (showBangIcon && activeBang != null) prefixIcon: (showBangIcon && activeBang != null)
? Padding( ? Padding(
padding: const EdgeInsetsDirectional.all(12.0), padding: const EdgeInsetsDirectional.all(12.0),
@@ -130,14 +141,20 @@ class SearchField extends HookConsumerWidget {
label: label, label: label,
hint: hint, hint: hint,
floatingLabelBehavior: FloatingLabelBehavior.always, floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIconConstraints: const BoxConstraints(minHeight: 48),
suffixIcon: hasText suffixIcon: hasText
? IconButton( ? Padding(
padding: const EdgeInsetsDirectional.only(end: 8.0),
child: IconButton(
onPressed: () { onPressed: () {
textEditingController.clear(); textEditingController.clear();
}, },
icon: const Icon(Icons.clear), icon: const Icon(Icons.clear),
),
) )
: Row( : Padding(
padding: const EdgeInsetsDirectional.only(end: 8.0),
child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
QrScannerButton( QrScannerButton(
@@ -155,6 +172,7 @@ class SearchField extends HookConsumerWidget {
], ],
), ),
), ),
),
onTapOutside: unfocusOnTapOutside onTapOutside: unfocusOnTapOutside
? (event) { ? (event) {
safeFocusNode.unfocus(); safeFocusNode.unfocus();
@@ -173,6 +191,7 @@ class SearchField extends HookConsumerWidget {
suggestion.value = null; suggestion.value = null;
} }
}, },
),
); );
} }
} }