-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Create SearchAnchor and SearchViewTheme Widget
#123256
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
Conversation
SearchAnchor and SearchViewTheme WidgetSearchAnchor and SearchViewTheme Widget
HansMuller
left a comment
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 looks great! Only real bit of feedback here is a suggestion about the "anchorBuilder" name.
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.
Does this mean that if nothing was selected the caller will see a stale value?
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.
Yes. When _closeView is called without providing any text, only the search view route is popped and the controller's value will not change. Or another way I can think of is, when selectedText is null, we just clear the value that the controller originally hold. Do you think if this makes sense?
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 think the way you have it now is OK; it is pretty clear what's going to happen when closeView(null) is called.
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.
If you use a non-null reverseCurve you might want to hold this object in a State object rather than recreating it each time your widget builds in order to take advantage of the state in this object that avoids visual discontinuities.
If bringing the page up and down (before the animation completes) looks janky, making the CurvedAnimation part of this Route's state might be a good idea. Could be handled in a separate PR.
QuncCccccc
left a comment
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 a lot for the feedback! Fixing it now.
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.
Yes. When _closeView is called without providing any text, only the search view route is popped and the controller's value will not change. Or another way I can think of is, when selectedText is null, we just clear the value that the controller originally hold. Do you think if this makes sense?
HansMuller
left a comment
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.
Assuming that anchorBuilder is renamed to builder, LGTM!
a867b97 to
555bb69
Compare
555bb69 to
c11e3bc
Compare
This PR is to create a
SearchAnchorwidget in which we can use an anchor to trigger a search view. Typically an anchor is aSearchBar, orIconButton.In order to use the
SearchAnchorwith the new Material 3 colors, turn on theuseMaterial3flag in theThemeData:Fixes #117483.
This is an example to show how we can use the SearchAnchor.bar() constructor. The sample code is in examples/api/lib/material/search_anchor/search_anchor.0.dart
Screen.Recording.2023-03-22.at.11.15.25.AM.mov
Same example running on mobile devices shows full screen.
Screen.Recording.2023-03-22.at.11.06.16.AM.mov
Another example in examples/api/lib/material/search_anchor/search_anchor.1.dart is to show how we can use SliverAppBar and SearchAnchor to get a pinned/floating effect. To achieve this, we need to add an additional api
clipBehaviorto AppBar, otherwise the shadow might be clipped.See the commit.
Screen.Recording.2023-03-22.at.11.09.16.AM.mov
Pre-launch Checklist
///).