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
0bcca42b
Unverified
Commit
0bcca42b
authored
May 14, 2020
by
Darren Austin
Committed by
GitHub
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honor the InputDecoratorTheme in the text input fields used by the Date Pickers. (#57189)
parent
2da08f4c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
144 additions
and
25 deletions
+144
-25
input_date_picker.dart
...s/flutter/lib/src/material/pickers/input_date_picker.dart
+19
-21
input_date_range_picker.dart
...ter/lib/src/material/pickers/input_date_range_picker.dart
+6
-4
date_picker_test.dart
packages/flutter/test/material/date_picker_test.dart
+57
-0
date_range_picker_test.dart
packages/flutter/test/material/date_range_picker_test.dart
+62
-0
No files found.
packages/flutter/lib/src/material/pickers/input_date_picker.dart
View file @
0bcca42b
...
...
@@ -9,6 +9,7 @@ import '../input_border.dart';
import
'../input_decorator.dart'
;
import
'../material_localizations.dart'
;
import
'../text_form_field.dart'
;
import
'../theme.dart'
;
import
'date_picker_common.dart'
;
import
'date_utils.dart'
as
utils
;
...
...
@@ -219,27 +220,24 @@ class _InputDatePickerFormFieldState extends State<InputDatePickerFormField> {
@override
Widget
build
(
BuildContext
context
)
{
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
return
OrientationBuilder
(
builder:
(
BuildContext
context
,
Orientation
orientation
)
{
assert
(
orientation
!=
null
);
return
TextFormField
(
decoration:
InputDecoration
(
border:
const
UnderlineInputBorder
(),
filled:
true
,
hintText:
widget
.
fieldHintText
??
localizations
.
dateHelpText
,
labelText:
widget
.
fieldLabelText
??
localizations
.
dateInputLabel
,
),
validator:
_validateDate
,
inputFormatters:
<
TextInputFormatter
>[
DateTextInputFormatter
(
localizations
.
dateSeparator
),
],
keyboardType:
TextInputType
.
datetime
,
onSaved:
_handleSaved
,
onFieldSubmitted:
_handleSubmitted
,
autofocus:
widget
.
autofocus
,
controller:
_controller
,
);
});
final
InputDecorationTheme
inputTheme
=
Theme
.
of
(
context
).
inputDecorationTheme
;
return
TextFormField
(
decoration:
InputDecoration
(
border:
inputTheme
.
border
??
const
UnderlineInputBorder
(),
filled:
inputTheme
.
filled
??
true
,
hintText:
widget
.
fieldHintText
??
localizations
.
dateHelpText
,
labelText:
widget
.
fieldLabelText
??
localizations
.
dateInputLabel
,
),
validator:
_validateDate
,
inputFormatters:
<
TextInputFormatter
>[
DateTextInputFormatter
(
localizations
.
dateSeparator
),
],
keyboardType:
TextInputType
.
datetime
,
onSaved:
_handleSaved
,
onFieldSubmitted:
_handleSubmitted
,
autofocus:
widget
.
autofocus
,
controller:
_controller
,
);
}
}
...
...
packages/flutter/lib/src/material/pickers/input_date_range_picker.dart
View file @
0bcca42b
...
...
@@ -9,6 +9,7 @@ import '../input_border.dart';
import
'../input_decorator.dart'
;
import
'../material_localizations.dart'
;
import
'../text_field.dart'
;
import
'../theme.dart'
;
import
'date_utils.dart'
as
utils
;
import
'input_date_picker.dart'
show
DateTextInputFormatter
;
...
...
@@ -230,6 +231,7 @@ class InputDateRangePickerState extends State<InputDateRangePicker> {
@override
Widget
build
(
BuildContext
context
)
{
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
final
InputDecorationTheme
inputTheme
=
Theme
.
of
(
context
).
inputDecorationTheme
;
return
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
...
...
@@ -237,8 +239,8 @@ class InputDateRangePickerState extends State<InputDateRangePicker> {
child:
TextField
(
controller:
_startController
,
decoration:
InputDecoration
(
border:
const
UnderlineInputBorder
(),
filled:
true
,
border:
inputTheme
.
border
??
const
UnderlineInputBorder
(),
filled:
inputTheme
.
filled
??
true
,
hintText:
widget
.
fieldStartHintText
??
localizations
.
dateHelpText
,
labelText:
widget
.
fieldStartLabelText
??
localizations
.
dateRangeStartLabel
,
errorText:
_startErrorText
,
...
...
@@ -254,8 +256,8 @@ class InputDateRangePickerState extends State<InputDateRangePicker> {
child:
TextField
(
controller:
_endController
,
decoration:
InputDecoration
(
border:
const
UnderlineInputBorder
(),
filled:
true
,
border:
inputTheme
.
border
??
const
UnderlineInputBorder
(),
filled:
inputTheme
.
filled
??
true
,
hintText:
widget
.
fieldEndHintText
??
localizations
.
dateHelpText
,
labelText:
widget
.
fieldEndLabelText
??
localizations
.
dateRangeEndLabel
,
errorText:
_endErrorText
,
...
...
packages/flutter/test/material/date_picker_test.dart
View file @
0bcca42b
...
...
@@ -679,6 +679,63 @@ void main() {
expect
(
find
.
text
(
errorInvalidText
),
findsOneWidget
);
});
});
testWidgets
(
'InputDecorationTheme is honored'
,
(
WidgetTester
tester
)
async
{
BuildContext
buttonContext
;
const
InputBorder
border
=
InputBorder
.
none
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
.
light
().
copyWith
(
inputDecorationTheme:
const
InputDecorationTheme
(
filled:
false
,
border:
border
,
),
),
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
RaisedButton
(
onPressed:
()
{
buttonContext
=
context
;
},
child:
const
Text
(
'Go'
),
);
},
),
),
));
await
tester
.
tap
(
find
.
text
(
'Go'
));
expect
(
buttonContext
,
isNotNull
);
showDatePicker
(
context:
buttonContext
,
initialDate:
initialDate
,
firstDate:
firstDate
,
lastDate:
lastDate
,
currentDate:
today
,
initialEntryMode:
DatePickerEntryMode
.
input
,
);
await
tester
.
pumpAndSettle
();
// Get the border and container color from the painter of the _BorderContainer
// (this was cribbed from input_decorator_test.dart).
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
descendant
(
of:
find
.
byWidgetPredicate
((
Widget
w
)
=>
'
${w.runtimeType}
'
==
'_BorderContainer'
),
matching:
find
.
byWidgetPredicate
((
Widget
w
)
=>
w
is
CustomPaint
),
));
final
dynamic
/*_InputBorderPainter*/
inputBorderPainter
=
customPaint
.
foregroundPainter
;
final
dynamic
/*_InputBorderTween*/
inputBorderTween
=
inputBorderPainter
.
border
;
final
Animation
<
double
>
animation
=
inputBorderPainter
.
borderAnimation
as
Animation
<
double
>;
final
InputBorder
actualBorder
=
inputBorderTween
.
evaluate
(
animation
)
as
InputBorder
;
final
Color
containerColor
=
inputBorderPainter
.
blendedColor
as
Color
;
// Border should match
expect
(
actualBorder
,
equals
(
border
));
// It shouldn't be filled, so the color should be transparent
expect
(
containerColor
,
equals
(
Colors
.
transparent
));
});
});
group
(
'Haptic feedback'
,
()
{
...
...
packages/flutter/test/material/date_range_picker_test.dart
View file @
0bcca42b
...
...
@@ -408,5 +408,67 @@ void main() {
expect
(
find
.
text
(
'End Date'
),
findsOneWidget
);
});
});
testWidgets
(
'InputDecorationTheme is honored'
,
(
WidgetTester
tester
)
async
{
// Given a custom paint for an input decoration, extract the border and
// fill color and test them against the expected values.
void
_testInputDecorator
(
CustomPaint
decoratorPaint
,
InputBorder
expectedBorder
,
Color
expectedContainerColor
)
{
final
dynamic
/*_InputBorderPainter*/
inputBorderPainter
=
decoratorPaint
.
foregroundPainter
;
final
dynamic
/*_InputBorderTween*/
inputBorderTween
=
inputBorderPainter
.
border
;
final
Animation
<
double
>
animation
=
inputBorderPainter
.
borderAnimation
as
Animation
<
double
>;
final
InputBorder
actualBorder
=
inputBorderTween
.
evaluate
(
animation
)
as
InputBorder
;
final
Color
containerColor
=
inputBorderPainter
.
blendedColor
as
Color
;
expect
(
actualBorder
,
equals
(
expectedBorder
));
expect
(
containerColor
,
equals
(
expectedContainerColor
));
}
BuildContext
buttonContext
;
const
InputBorder
border
=
InputBorder
.
none
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
.
light
().
copyWith
(
inputDecorationTheme:
const
InputDecorationTheme
(
filled:
false
,
border:
border
,
),
),
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
RaisedButton
(
onPressed:
()
{
buttonContext
=
context
;
},
child:
const
Text
(
'Go'
),
);
},
),
),
));
await
tester
.
tap
(
find
.
text
(
'Go'
));
expect
(
buttonContext
,
isNotNull
);
showDateRangePicker
(
context:
buttonContext
,
initialDateRange:
initialDateRange
,
firstDate:
firstDate
,
lastDate:
lastDate
,
initialEntryMode:
DatePickerEntryMode
.
input
,
);
await
tester
.
pumpAndSettle
();
final
Finder
borderContainers
=
find
.
descendant
(
of:
find
.
byWidgetPredicate
((
Widget
w
)
=>
'
${w.runtimeType}
'
==
'_BorderContainer'
),
matching:
find
.
byWidgetPredicate
((
Widget
w
)
=>
w
is
CustomPaint
),
);
// Test the start date text field
_testInputDecorator
(
tester
.
widget
(
borderContainers
.
first
),
border
,
Colors
.
transparent
);
// Test the end date text field
_testInputDecorator
(
tester
.
widget
(
borderContainers
.
last
),
border
,
Colors
.
transparent
);
});
});
}
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