Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
adc8a42b
Unverified
Commit
adc8a42b
authored
Nov 16, 2020
by
tiya
Committed by
GitHub
Nov 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bottom to search bar (#68794)
parent
bf2c9dfc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
search_demo.dart
..._tests/flutter_gallery/lib/demo/material/search_demo.dart
+6
-0
search.dart
packages/flutter/lib/src/material/search.dart
+21
-3
search_test.dart
packages/flutter/test/material/search_test.dart
+14
-0
No files found.
dev/integration_tests/flutter_gallery/lib/demo/material/search_demo.dart
View file @
adc8a42b
...
...
@@ -223,6 +223,12 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int?> {
),
];
}
@override
PreferredSizeWidget
buildBottom
(
BuildContext
context
)
=>
const
PreferredSize
(
preferredSize:
Size
.
fromHeight
(
56.0
),
child:
Text
(
'Numbers'
),
);
}
class
_ResultCard
extends
StatelessWidget
{
...
...
packages/flutter/lib/src/material/search.dart
View file @
adc8a42b
...
...
@@ -69,8 +69,9 @@ Future<T?> showSearch<T>({
///
/// The search page always shows an [AppBar] at the top where users can
/// enter their search queries. The buttons shown before and after the search
/// query text field can be customized via [SearchDelegate.buildLeading] and
/// [SearchDelegate.buildActions].
/// query text field can be customized via [SearchDelegate.buildLeading]
/// and [SearchDelegate.buildActions]. Additonally, a widget can be placed
/// across the bottom of the [AppBar] via [SearchDelegate.buildBottom].
///
/// The body below the [AppBar] can either show suggested queries (returned by
/// [SearchDelegate.buildSuggestions]) or - once the user submits a search - the
...
...
@@ -113,6 +114,12 @@ abstract class SearchDelegate<T> {
/// @override
/// Widget buildLeading(BuildContext context) => Text("leading");
///
/// PreferredSizeWidget buildBottom(BuildContext context) {
/// return PreferredSize(
/// preferredSize: Size.fromHeight(56.0),
/// child: Text("bottom"));
/// }
///
/// @override
/// Widget buildSuggestions(BuildContext context) => Text("suggestions");
///
...
...
@@ -188,6 +195,16 @@ abstract class SearchDelegate<T> {
/// * [AppBar.actions], the intended use for the return value of this method.
List
<
Widget
>
buildActions
(
BuildContext
context
);
/// Widget to display across the bottom of the [AppBar].
///
/// Returns null by default, i.e. a bottom widget is not included.
///
/// See also:
///
/// * [AppBar.bottom], the intended use for the return value of this method.
///
PreferredSizeWidget
?
buildBottom
(
BuildContext
context
)
=>
null
;
/// The theme used to configure the search page.
///
/// The returned [ThemeData] will be used to wrap the entire search page,
...
...
@@ -560,12 +577,13 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
decoration:
InputDecoration
(
hintText:
searchFieldLabel
),
),
actions:
widget
.
delegate
.
buildActions
(
context
),
bottom:
widget
.
delegate
.
buildBottom
(
context
),
),
body:
AnimatedSwitcher
(
duration:
const
Duration
(
milliseconds:
300
),
child:
body
,
),
)
,
)
),
);
}
...
...
packages/flutter/test/material/search_test.dart
View file @
adc8a42b
...
...
@@ -99,6 +99,7 @@ void main() {
expect
(
find
.
text
(
'HomeBody'
),
findsNothing
);
expect
(
find
.
text
(
'HomeTitle'
),
findsNothing
);
expect
(
find
.
text
(
'Suggestions'
),
findsOneWidget
);
expect
(
find
.
text
(
'Bottom'
),
findsOneWidget
);
// Simulate system back button
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
...
...
@@ -633,6 +634,11 @@ void main() {
textDirection:
TextDirection
.
ltr
,
textSelection:
const
TextSelection
(
baseOffset:
0
,
extentOffset:
0
),
),
TestSemantics
(
id:
14
,
label:
'Bottom'
,
textDirection:
TextDirection
.
ltr
,
),
],
),
TestSemantics
(
...
...
@@ -893,4 +899,12 @@ class _TestSearchDelegate extends SearchDelegate<String> {
List
<
Widget
>
buildActions
(
BuildContext
context
)
{
return
actions
;
}
@override
PreferredSizeWidget
buildBottom
(
BuildContext
context
)
{
return
const
PreferredSize
(
preferredSize:
Size
.
fromHeight
(
56.0
),
child:
Text
(
'Bottom'
),
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment