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
843231bb
Unverified
Commit
843231bb
authored
Jul 08, 2020
by
rami-a
Committed by
GitHub
Jul 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Material] Misc fixes for time picker input mode (#60991)
parent
a167610e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
31 deletions
+43
-31
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+27
-26
time_picker_theme_test.dart
packages/flutter/test/material/time_picker_theme_test.dart
+16
-5
No files found.
packages/flutter/lib/src/material/time_picker.dart
View file @
843231bb
...
...
@@ -1430,8 +1430,9 @@ class _TimePickerInputState extends State<_TimePickerInput> {
),
],
)),
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
20.0
),
Container
(
margin:
const
EdgeInsets
.
only
(
top:
8.0
),
height:
_kTimePickerHeaderControlHeight
,
child:
_StringFragment
(
timeOfDayFormat:
timeOfDayFormat
),
),
Expanded
(
child:
Column
(
...
...
@@ -1532,17 +1533,19 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> {
@override
Widget
build
(
BuildContext
context
)
{
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
TimePickerThemeData
timePickerTheme
=
TimePickerTheme
.
of
(
context
);
final
ColorScheme
colorScheme
=
theme
.
colorScheme
;
final
InputDecorationTheme
inputDecorationTheme
=
TimePickerTheme
.
of
(
context
)
.
inputDecorationTheme
;
final
InputDecorationTheme
inputDecorationTheme
=
timePickerTheme
.
inputDecorationTheme
;
InputDecoration
inputDecoration
;
if
(
inputDecorationTheme
!=
null
)
{
inputDecoration
=
const
InputDecoration
().
applyDefaults
(
inputDecorationTheme
);
}
else
{
final
Color
unfocusedFillColor
=
timePickerTheme
.
hourMinuteColor
??
colorScheme
.
onSurface
.
withOpacity
(
0.12
);
inputDecoration
=
InputDecoration
(
contentPadding:
const
EdgeInsetsDirectional
.
only
(
bottom:
16.0
,
start:
3.0
)
,
contentPadding:
EdgeInsets
.
zero
,
filled:
true
,
fillColor:
focusNode
.
hasFocus
?
colorScheme
.
surface
:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)
,
fillColor:
focusNode
.
hasFocus
?
Colors
.
transparent
:
unfocusedFillColor
,
enabledBorder:
const
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Colors
.
transparent
),
),
...
...
@@ -1566,28 +1569,26 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> {
hintText:
focusNode
.
hasFocus
?
null
:
_formattedValue
,
);
return
Column
(
children:
<
Widget
>[
SizedBox
(
height:
_kTimePickerHeaderControlHeight
,
child:
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
1.0
),
child:
TextFormField
(
focusNode:
focusNode
,
textAlign:
TextAlign
.
center
,
keyboardType:
TextInputType
.
number
,
style:
widget
.
style
.
copyWith
(
color:
colorScheme
.
onSurface
),
controller:
controller
,
decoration:
inputDecoration
,
validator:
widget
.
validator
,
onEditingComplete:
()
=>
widget
.
onSavedSubmitted
(
controller
.
text
),
onSaved:
widget
.
onSavedSubmitted
,
onFieldSubmitted:
widget
.
onSavedSubmitted
,
onChanged:
widget
.
onChanged
,
),
),
return
SizedBox
(
height:
_kTimePickerHeaderControlHeight
,
child:
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
1.0
),
child:
TextFormField
(
expands:
true
,
maxLines:
null
,
focusNode:
focusNode
,
textAlign:
TextAlign
.
center
,
keyboardType:
TextInputType
.
number
,
style:
widget
.
style
.
copyWith
(
color:
colorScheme
.
onSurface
),
controller:
controller
,
decoration:
inputDecoration
,
validator:
widget
.
validator
,
onEditingComplete:
()
=>
widget
.
onSavedSubmitted
(
controller
.
text
),
onSaved:
widget
.
onSavedSubmitted
,
onFieldSubmitted:
widget
.
onSavedSubmitted
,
onChanged:
widget
.
onChanged
,
),
]
,
)
,
);
}
}
...
...
packages/flutter/test/material/time_picker_theme_test.dart
View file @
843231bb
...
...
@@ -342,8 +342,8 @@ void main() {
);
});
testWidgets
(
'Time picker uses values from TimePickerThemeData - input mode'
,
(
WidgetTester
tester
)
async
{
final
TimePickerThemeData
timePickerTheme
=
_timePickerTheme
();
testWidgets
(
'Time picker uses values from TimePickerThemeData
with InputDecorationTheme
- input mode'
,
(
WidgetTester
tester
)
async
{
final
TimePickerThemeData
timePickerTheme
=
_timePickerTheme
(
includeInputDecoration:
true
);
final
ThemeData
theme
=
ThemeData
(
timePickerTheme:
timePickerTheme
);
await
tester
.
pumpWidget
(
_TimePickerLauncher
(
themeData:
theme
,
entryMode:
TimePickerEntryMode
.
input
));
await
tester
.
tap
(
find
.
text
(
'X'
));
...
...
@@ -358,12 +358,23 @@ void main() {
expect
(
hourDecoration
.
focusedErrorBorder
,
timePickerTheme
.
inputDecorationTheme
.
focusedErrorBorder
);
expect
(
hourDecoration
.
hintStyle
,
timePickerTheme
.
inputDecorationTheme
.
hintStyle
);
});
testWidgets
(
'Time picker uses values from TimePickerThemeData without InputDecorationTheme - input mode'
,
(
WidgetTester
tester
)
async
{
final
TimePickerThemeData
timePickerTheme
=
_timePickerTheme
();
final
ThemeData
theme
=
ThemeData
(
timePickerTheme:
timePickerTheme
);
await
tester
.
pumpWidget
(
_TimePickerLauncher
(
themeData:
theme
,
entryMode:
TimePickerEntryMode
.
input
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
(
const
Duration
(
seconds:
1
));
final
InputDecoration
hourDecoration
=
_textField
(
tester
,
'7'
).
decoration
;
expect
(
hourDecoration
.
fillColor
,
timePickerTheme
.
hourMinuteColor
);
});
}
final
Color
_selectedColor
=
Colors
.
green
[
100
];
final
Color
_unselectedColor
=
Colors
.
green
[
200
];
TimePickerThemeData
_timePickerTheme
(
)
{
TimePickerThemeData
_timePickerTheme
(
{
bool
includeInputDecoration
=
false
}
)
{
Color
getColor
(
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
selected
)
?
_selectedColor
:
_unselectedColor
;
}
...
...
@@ -385,7 +396,7 @@ TimePickerThemeData _timePickerTheme() {
hourMinuteShape:
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
16.0
))),
dayPeriodShape:
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
16.0
))),
dayPeriodBorderSide:
const
BorderSide
(
color:
Colors
.
blueAccent
),
inputDecorationTheme:
const
InputDecorationTheme
(
inputDecorationTheme:
includeInputDecoration
?
const
InputDecorationTheme
(
filled:
true
,
fillColor:
Colors
.
purple
,
enabledBorder:
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Colors
.
blue
)),
...
...
@@ -393,7 +404,7 @@ TimePickerThemeData _timePickerTheme() {
focusedBorder:
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Colors
.
yellow
)),
focusedErrorBorder:
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Colors
.
red
)),
hintStyle:
TextStyle
(
fontSize:
8
),
),
)
:
null
,
);
}
...
...
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