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
aa81ac60
Unverified
Commit
aa81ac60
authored
May 11, 2021
by
Rick Krystianne Lim
Committed by
GitHub
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify CupertinoSearchTextField's prefix icon. (#81100)
parent
b7dd9acb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
2 deletions
+40
-2
search_field.dart
packages/flutter/lib/src/cupertino/search_field.dart
+11
-2
search_field_test.dart
packages/flutter/test/cupertino/search_field_test.dart
+29
-0
No files found.
packages/flutter/lib/src/cupertino/search_field.dart
View file @
aa81ac60
...
@@ -116,6 +116,9 @@ class CupertinoSearchTextField extends StatefulWidget {
...
@@ -116,6 +116,9 @@ class CupertinoSearchTextField extends StatefulWidget {
/// default fields were determined using the comparison tool in
/// default fields were determined using the comparison tool in
/// https://github.com/flutter/platform_tests/.
/// https://github.com/flutter/platform_tests/.
///
///
/// To customize the prefix icon, pass a [Widget] to [prefixIcon]. This
/// defaults to the search icon.
///
/// To customize the suffix icon, pass an [Icon] to [suffixIcon]. This
/// To customize the suffix icon, pass an [Icon] to [suffixIcon]. This
/// defaults to the X-Mark.
/// defaults to the X-Mark.
///
///
...
@@ -141,6 +144,7 @@ class CupertinoSearchTextField extends StatefulWidget {
...
@@ -141,6 +144,7 @@ class CupertinoSearchTextField extends StatefulWidget {
this
.
itemColor
=
CupertinoColors
.
secondaryLabel
,
this
.
itemColor
=
CupertinoColors
.
secondaryLabel
,
this
.
itemSize
=
20.0
,
this
.
itemSize
=
20.0
,
this
.
prefixInsets
=
const
EdgeInsetsDirectional
.
fromSTEB
(
6
,
0
,
0
,
4
),
this
.
prefixInsets
=
const
EdgeInsetsDirectional
.
fromSTEB
(
6
,
0
,
0
,
4
),
this
.
prefixIcon
=
const
Icon
(
CupertinoIcons
.
search
),
this
.
suffixInsets
=
const
EdgeInsetsDirectional
.
fromSTEB
(
0
,
0
,
5
,
2
),
this
.
suffixInsets
=
const
EdgeInsetsDirectional
.
fromSTEB
(
0
,
0
,
5
,
2
),
this
.
suffixIcon
=
const
Icon
(
CupertinoIcons
.
xmark_circle_fill
),
this
.
suffixIcon
=
const
Icon
(
CupertinoIcons
.
xmark_circle_fill
),
this
.
suffixMode
=
OverlayVisibilityMode
.
editing
,
this
.
suffixMode
=
OverlayVisibilityMode
.
editing
,
...
@@ -246,6 +250,11 @@ class CupertinoSearchTextField extends StatefulWidget {
...
@@ -246,6 +250,11 @@ class CupertinoSearchTextField extends StatefulWidget {
/// the comparison tool in https://github.com/flutter/platform_tests/.
/// the comparison tool in https://github.com/flutter/platform_tests/.
final
EdgeInsetsGeometry
prefixInsets
;
final
EdgeInsetsGeometry
prefixInsets
;
/// Sets a prefix widget.
///
/// Cannot be null. Defaults to an [Icon] widget with the [CupertinoIcons.search] icon.
final
Widget
prefixIcon
;
/// Sets the padding insets for the prefix.
/// Sets the padding insets for the prefix.
///
///
/// Cannot be null. Defaults to padding that replicates the
/// Cannot be null. Defaults to padding that replicates the
...
@@ -287,7 +296,7 @@ class CupertinoSearchTextField extends StatefulWidget {
...
@@ -287,7 +296,7 @@ class CupertinoSearchTextField extends StatefulWidget {
/// Disables the text field when false.
/// Disables the text field when false.
///
///
/// Text fields in disabled states have a light grey background and don't
/// Text fields in disabled states have a light grey background and don't
/// respond to touch events including the [
suffixIcon] and the search
button.
/// respond to touch events including the [
prefixIcon] and [suffixIcon]
button.
final
bool
?
enabled
;
final
bool
?
enabled
;
@override
@override
...
@@ -387,7 +396,7 @@ class _CupertinoSearchTextFieldState extends State<CupertinoSearchTextField>
...
@@ -387,7 +396,7 @@ class _CupertinoSearchTextFieldState extends State<CupertinoSearchTextField>
final
Widget
prefix
=
Padding
(
final
Widget
prefix
=
Padding
(
child:
IconTheme
(
child:
IconTheme
(
data:
iconThemeData
,
data:
iconThemeData
,
child:
const
Icon
(
CupertinoIcons
.
search
)
,
child:
widget
.
prefixIcon
,
),
),
padding:
widget
.
prefixInsets
,
padding:
widget
.
prefixInsets
,
);
);
...
...
packages/flutter/test/cupertino/search_field_test.dart
View file @
aa81ac60
...
@@ -257,6 +257,35 @@ void main() {
...
@@ -257,6 +257,35 @@ void main() {
},
},
);
);
testWidgets
(
'prefix widget visibility'
,
(
WidgetTester
tester
)
async
{
const
Key
prefixIcon
=
Key
(
'prefix'
);
await
tester
.
pumpWidget
(
const
CupertinoApp
(
home:
Center
(
child:
CupertinoSearchTextField
(
prefixIcon:
SizedBox
(
key:
prefixIcon
,
width:
50
,
height:
50
,
),
),
),
),
);
expect
(
find
.
byIcon
(
CupertinoIcons
.
search
),
findsNothing
);
expect
(
find
.
byKey
(
prefixIcon
),
findsOneWidget
);
await
tester
.
enterText
(
find
.
byType
(
CupertinoSearchTextField
),
'text input'
);
await
tester
.
pump
();
expect
(
find
.
text
(
'text input'
),
findsOneWidget
);
expect
(
find
.
byIcon
(
CupertinoIcons
.
search
),
findsNothing
);
expect
(
find
.
byKey
(
prefixIcon
),
findsOneWidget
);
});
testWidgets
(
testWidgets
(
'suffix widget respects visibility mode'
,
'suffix widget respects visibility mode'
,
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
...
...
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