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
c2bb9289
Unverified
Commit
c2bb9289
authored
Oct 26, 2020
by
Justin McCandless
Committed by
GitHub
Oct 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper light/dark colors, and test that text is not color of background (#67679)
parent
bacc03da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
search.dart
packages/flutter/lib/src/material/search.dart
+3
-1
search_test.dart
packages/flutter/test/material/search_test.dart
+58
-0
No files found.
packages/flutter/lib/src/material/search.dart
View file @
c2bb9289
...
@@ -199,7 +199,9 @@ abstract class SearchDelegate<T> {
...
@@ -199,7 +199,9 @@ abstract class SearchDelegate<T> {
final
ThemeData
theme
=
Theme
.
of
(
context
)!;
final
ThemeData
theme
=
Theme
.
of
(
context
)!;
assert
(
theme
!=
null
);
assert
(
theme
!=
null
);
return
theme
.
copyWith
(
return
theme
.
copyWith
(
primaryColor:
Colors
.
white
,
primaryColor:
theme
.
brightness
==
Brightness
.
dark
?
theme
.
primaryColor
:
Colors
.
white
,
primaryIconTheme:
theme
.
primaryIconTheme
.
copyWith
(
color:
Colors
.
grey
),
primaryIconTheme:
theme
.
primaryIconTheme
.
copyWith
(
color:
Colors
.
grey
),
primaryColorBrightness:
Brightness
.
light
,
primaryColorBrightness:
Brightness
.
light
,
primaryTextTheme:
theme
.
textTheme
,
primaryTextTheme:
theme
.
textTheme
,
...
...
packages/flutter/test/material/search_test.dart
View file @
c2bb9289
...
@@ -691,6 +691,56 @@ void main() {
...
@@ -691,6 +691,56 @@ void main() {
semantics
.
dispose
();
semantics
.
dispose
();
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
});
});
// Regression test for: https://github.com/flutter/flutter/issues/66781
testWidgets
(
'text in search bar contrasts background (light mode)'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
themeData
=
ThemeData
.
light
();
final
_TestSearchDelegate
delegate
=
_TestSearchDelegate
(
defaultAppBarTheme:
true
,
);
const
String
query
=
'search query'
;
await
tester
.
pumpWidget
(
TestHomePage
(
delegate:
delegate
,
passInInitialQuery:
true
,
initialQuery:
query
,
themeData:
themeData
,
));
await
tester
.
tap
(
find
.
byTooltip
(
'Search'
));
await
tester
.
pumpAndSettle
();
final
AppBar
appBar
=
tester
.
widget
<
AppBar
>(
find
.
byType
(
AppBar
));
expect
(
appBar
.
backgroundColor
,
Colors
.
white
);
final
TextField
textField
=
tester
.
widget
<
TextField
>(
find
.
byType
(
TextField
));
expect
(
textField
.
style
!.
color
,
themeData
.
textTheme
.
bodyText1
!.
color
);
expect
(
textField
.
style
!.
color
,
isNot
(
equals
(
Colors
.
white
)));
});
// Regression test for: https://github.com/flutter/flutter/issues/66781
testWidgets
(
'text in search bar contrasts background (dark mode)'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
themeData
=
ThemeData
.
dark
();
final
_TestSearchDelegate
delegate
=
_TestSearchDelegate
(
defaultAppBarTheme:
true
,
);
const
String
query
=
'search query'
;
await
tester
.
pumpWidget
(
TestHomePage
(
delegate:
delegate
,
passInInitialQuery:
true
,
initialQuery:
query
,
themeData:
themeData
,
));
await
tester
.
tap
(
find
.
byTooltip
(
'Search'
));
await
tester
.
pumpAndSettle
();
final
AppBar
appBar
=
tester
.
widget
<
AppBar
>(
find
.
byType
(
AppBar
));
expect
(
appBar
.
backgroundColor
,
themeData
.
primaryColor
);
final
TextField
textField
=
tester
.
widget
<
TextField
>(
find
.
byType
(
TextField
));
expect
(
textField
.
style
!.
color
,
themeData
.
textTheme
.
bodyText1
!.
color
);
expect
(
textField
.
style
!.
color
,
isNot
(
equals
(
themeData
.
primaryColor
)));
});
}
}
class
TestHomePage
extends
StatelessWidget
{
class
TestHomePage
extends
StatelessWidget
{
...
@@ -700,16 +750,19 @@ class TestHomePage extends StatelessWidget {
...
@@ -700,16 +750,19 @@ class TestHomePage extends StatelessWidget {
required
this
.
delegate
,
required
this
.
delegate
,
this
.
passInInitialQuery
=
false
,
this
.
passInInitialQuery
=
false
,
this
.
initialQuery
,
this
.
initialQuery
,
this
.
themeData
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
List
<
String
?>?
results
;
final
List
<
String
?>?
results
;
final
SearchDelegate
<
String
>
delegate
;
final
SearchDelegate
<
String
>
delegate
;
final
bool
passInInitialQuery
;
final
bool
passInInitialQuery
;
final
ThemeData
?
themeData
;
final
String
?
initialQuery
;
final
String
?
initialQuery
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
MaterialApp
(
theme:
themeData
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
...
@@ -749,11 +802,13 @@ class _TestSearchDelegate extends SearchDelegate<String> {
...
@@ -749,11 +802,13 @@ class _TestSearchDelegate extends SearchDelegate<String> {
this
.
suggestions
=
'Suggestions'
,
this
.
suggestions
=
'Suggestions'
,
this
.
result
=
'Result'
,
this
.
result
=
'Result'
,
this
.
actions
=
const
<
Widget
>[],
this
.
actions
=
const
<
Widget
>[],
this
.
defaultAppBarTheme
=
false
,
TextStyle
?
searchFieldStyle
,
TextStyle
?
searchFieldStyle
,
String
?
searchHint
,
String
?
searchHint
,
TextInputAction
textInputAction
=
TextInputAction
.
search
,
TextInputAction
textInputAction
=
TextInputAction
.
search
,
})
:
super
(
searchFieldLabel:
searchHint
,
textInputAction:
textInputAction
,
searchFieldStyle:
searchFieldStyle
);
})
:
super
(
searchFieldLabel:
searchHint
,
textInputAction:
textInputAction
,
searchFieldStyle:
searchFieldStyle
);
final
bool
defaultAppBarTheme
;
final
String
suggestions
;
final
String
suggestions
;
final
String
result
;
final
String
result
;
final
List
<
Widget
>
actions
;
final
List
<
Widget
>
actions
;
...
@@ -761,6 +816,9 @@ class _TestSearchDelegate extends SearchDelegate<String> {
...
@@ -761,6 +816,9 @@ class _TestSearchDelegate extends SearchDelegate<String> {
@override
@override
ThemeData
appBarTheme
(
BuildContext
context
)
{
ThemeData
appBarTheme
(
BuildContext
context
)
{
if
(
defaultAppBarTheme
)
{
return
super
.
appBarTheme
(
context
);
}
final
ThemeData
theme
=
Theme
.
of
(
context
)!;
final
ThemeData
theme
=
Theme
.
of
(
context
)!;
return
theme
.
copyWith
(
return
theme
.
copyWith
(
inputDecorationTheme:
InputDecorationTheme
(
hintStyle:
TextStyle
(
color:
hintTextColor
)),
inputDecorationTheme:
InputDecorationTheme
(
hintStyle:
TextStyle
(
color:
hintTextColor
)),
...
...
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