New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create SearchBar
and SearchBarTheme
#122309
Conversation
0b8f764
to
c021b4c
Compare
SearchBar
and SearchTheme
SearchBar
and SearchTheme
SearchBar
and SearchBarTheme
da283f3
to
4403dac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, just gave it a quick first pass.
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/widgets.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be name search_bar.dart
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I think the search bar will only be used for the widget SearchAnchor
which will be created in the future PR, so just want to put them in the same file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what search anchor refers to, I couldn't find a mention in the guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. To open a search view, I'm creating a SearchAnchor widget so that we can get all the anchor(SearchBar or IconButton or any widget) information, such as size, position and etc. Here's the design doc https://docs.google.com/document/d/1_WOcgddfJ7OyYyaCJhkIWgOYywj2jDeMooFsKg012B4/edit#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm a bit confused because it talks about the introduction of 2 widgets, and the SearchView
section only mentions SearchAnchor
. Are these terms used interchangeably and should s/anchor/view/?
If SearchView
and SearchAnchor
are distinct widgets, is there a way to avoid having 3 public widgets? 2 would be ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think we will only need SearchBar
and SearchAnchor
widgets. Will update the design soon! Thanks:)
/// The [leading] widget is on the left side of the bar and should contain either | ||
/// a navigational action (such as a menu or up-arrow) or a non-functional | ||
/// search icon. | ||
/// | ||
/// The [trailing] is an optional list. There should be up to two action icons | ||
/// that are located on the bar’s right-hand side. These actions can represent | ||
/// additional modes of searching (like voice search), a separate high-level | ||
/// action (such as current location) or an overflow menu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in the constructor docs?
70e4a5e
to
7557923
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just small stuff. This is looking good.
this.padding, | ||
this.textStyle, | ||
this.hintStyle, | ||
}) : assert(trailing == null || trailing.length <= 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to prevent developers from using 3 or more trailing widgets? Although it's definitely not advisable, it doesn't seem worth asserting if a developer founds a justification for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Removed this assertion.
surfaceTintColor: MaterialStatePropertyAll<Color>(Color(0xfffffff3)), | ||
overlayColor: MaterialStatePropertyAll<Color>(Color(0xfffffff4)), | ||
side: MaterialStatePropertyAll<BorderSide>( | ||
BorderSide(width: 2.0, color: Color(0xfffffff5))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be on one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this and others! I think the IDE did this kind of format automatically. Sorry for not catching this.
08d118c
to
ea22491
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/// The surface tint color of the button's [Material]. | ||
/// | ||
/// See [Material.surfaceTintColor] for more details. | ||
/// | ||
/// If null, the value of [SearchBarThemeData.surfaceTintColor] will be used. | ||
/// If this is also null, then the default value is [ColorScheme.surfaceTint]. | ||
final MaterialStateProperty<Color?>? surfaceTintColor; | ||
|
||
/// The highlight color that's typically used to indicate that | ||
/// the button is focused, hovered, or pressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what "the button" is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "Search bar". Thanks for catching this. Fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending documentation update for surfaceTintColor
and overlayColor
This PR is to create a
SearchBar
widget which is the default trigger for aSearchView
.A
SearchAnchor
widget will be created soon to show search view.In order to use the
SearchBar
with the new Material 3 colors, turn on theuseMaterial3
flag in theThemeData
:Related to #117483.
Pre-launch Checklist
///
).