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
f5ebf41b
Unverified
Commit
f5ebf41b
authored
Sep 13, 2022
by
Taha Tesser
Committed by
GitHub
Sep 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the TimePicker hour/minute field's input actions (#97361)
parent
f8f69575
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+13
-0
time_picker_test.dart
packages/flutter/test/material/time_picker_test.dart
+20
-0
No files found.
packages/flutter/lib/src/material/time_picker.dart
View file @
f5ebf41b
...
...
@@ -1429,6 +1429,7 @@ class _TimePickerInputState extends State<_TimePickerInput> with RestorationMixi
if
(
newHour
!=
null
)
{
_selectedTime
.
value
=
TimeOfDay
(
hour:
newHour
,
minute:
_selectedTime
.
value
.
minute
);
widget
.
onChanged
(
_selectedTime
.
value
);
FocusScope
.
of
(
context
).
requestFocus
();
}
}
...
...
@@ -1445,6 +1446,7 @@ class _TimePickerInputState extends State<_TimePickerInput> with RestorationMixi
if
(
newMinute
!=
null
)
{
_selectedTime
.
value
=
TimeOfDay
(
hour:
_selectedTime
.
value
.
hour
,
minute:
int
.
parse
(
value
!));
widget
.
onChanged
(
_selectedTime
.
value
);
FocusScope
.
of
(
context
).
unfocus
();
}
}
...
...
@@ -1521,6 +1523,7 @@ class _TimePickerInputState extends State<_TimePickerInput> with RestorationMixi
selectedTime:
_selectedTime
.
value
,
style:
hourMinuteStyle
,
autofocus:
widget
.
autofocusHour
,
inputAction:
TextInputAction
.
next
,
validator:
_validateHour
,
onSavedSubmitted:
_handleHourSavedSubmitted
,
onChanged:
_handleHourChanged
,
...
...
@@ -1554,6 +1557,7 @@ class _TimePickerInputState extends State<_TimePickerInput> with RestorationMixi
selectedTime:
_selectedTime
.
value
,
style:
hourMinuteStyle
,
autofocus:
widget
.
autofocusMinute
,
inputAction:
TextInputAction
.
done
,
validator:
_validateMinute
,
onSavedSubmitted:
_handleMinuteSavedSubmitted
,
minuteLabelText:
widget
.
minuteLabelText
,
...
...
@@ -1602,6 +1606,7 @@ class _HourTextField extends StatelessWidget {
required
this
.
selectedTime
,
required
this
.
style
,
required
this
.
autofocus
,
required
this
.
inputAction
,
required
this
.
validator
,
required
this
.
onSavedSubmitted
,
required
this
.
onChanged
,
...
...
@@ -1612,6 +1617,7 @@ class _HourTextField extends StatelessWidget {
final
TimeOfDay
selectedTime
;
final
TextStyle
style
;
final
bool
?
autofocus
;
final
TextInputAction
inputAction
;
final
FormFieldValidator
<
String
>
validator
;
final
ValueChanged
<
String
?>
onSavedSubmitted
;
final
ValueChanged
<
String
>
onChanged
;
...
...
@@ -1625,6 +1631,7 @@ class _HourTextField extends StatelessWidget {
selectedTime:
selectedTime
,
isHour:
true
,
autofocus:
autofocus
,
inputAction:
inputAction
,
style:
style
,
semanticHintText:
hourLabelText
??
MaterialLocalizations
.
of
(
context
).
timePickerHourLabel
,
validator:
validator
,
...
...
@@ -1639,6 +1646,7 @@ class _MinuteTextField extends StatelessWidget {
required
this
.
selectedTime
,
required
this
.
style
,
required
this
.
autofocus
,
required
this
.
inputAction
,
required
this
.
validator
,
required
this
.
onSavedSubmitted
,
required
this
.
minuteLabelText
,
...
...
@@ -1648,6 +1656,7 @@ class _MinuteTextField extends StatelessWidget {
final
TimeOfDay
selectedTime
;
final
TextStyle
style
;
final
bool
?
autofocus
;
final
TextInputAction
inputAction
;
final
FormFieldValidator
<
String
>
validator
;
final
ValueChanged
<
String
?>
onSavedSubmitted
;
final
String
?
minuteLabelText
;
...
...
@@ -1660,6 +1669,7 @@ class _MinuteTextField extends StatelessWidget {
selectedTime:
selectedTime
,
isHour:
false
,
autofocus:
autofocus
,
inputAction:
inputAction
,
style:
style
,
semanticHintText:
minuteLabelText
??
MaterialLocalizations
.
of
(
context
).
timePickerMinuteLabel
,
validator:
validator
,
...
...
@@ -1673,6 +1683,7 @@ class _HourMinuteTextField extends StatefulWidget {
required
this
.
selectedTime
,
required
this
.
isHour
,
required
this
.
autofocus
,
required
this
.
inputAction
,
required
this
.
style
,
required
this
.
semanticHintText
,
required
this
.
validator
,
...
...
@@ -1684,6 +1695,7 @@ class _HourMinuteTextField extends StatefulWidget {
final
TimeOfDay
selectedTime
;
final
bool
isHour
;
final
bool
?
autofocus
;
final
TextInputAction
inputAction
;
final
TextStyle
style
;
final
String
semanticHintText
;
final
FormFieldValidator
<
String
>
validator
;
...
...
@@ -1799,6 +1811,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
],
focusNode:
focusNode
,
textAlign:
TextAlign
.
center
,
textInputAction:
widget
.
inputAction
,
keyboardType:
TextInputType
.
number
,
style:
widget
.
style
.
copyWith
(
color:
timePickerTheme
.
hourMinuteTextColor
??
colorScheme
.
onSurface
),
controller:
controller
.
value
,
...
...
packages/flutter/test/material/time_picker_test.dart
View file @
f5ebf41b
...
...
@@ -1291,6 +1291,26 @@ void _testsInput() {
await
finishPicker
(
tester
);
expect
(
result
,
equals
(
const
TimeOfDay
(
hour:
6
,
minute:
45
)));
});
testWidgets
(
'Can switch between hour/minute fields using keyboard input action'
,
(
WidgetTester
tester
)
async
{
await
startPicker
(
tester
,
(
TimeOfDay
?
time
)
{
},
entryMode:
TimePickerEntryMode
.
input
);
final
Finder
hourFinder
=
find
.
byType
(
TextField
).
first
;
final
TextField
hourField
=
tester
.
widget
(
hourFinder
);
await
tester
.
tap
(
hourFinder
);
expect
(
hourField
.
focusNode
!.
hasFocus
,
isTrue
);
await
tester
.
enterText
(
find
.
byType
(
TextField
).
first
,
'08'
);
final
Finder
minuteFinder
=
find
.
byType
(
TextField
).
last
;
final
TextField
minuteField
=
tester
.
widget
(
minuteFinder
);
expect
(
hourField
.
focusNode
!.
hasFocus
,
isFalse
);
expect
(
minuteField
.
focusNode
!.
hasFocus
,
isTrue
);
expect
(
tester
.
testTextInput
.
setClientArgs
![
'inputAction'
],
equals
(
'TextInputAction.done'
));
await
tester
.
testTextInput
.
receiveAction
(
TextInputAction
.
done
);
expect
(
hourField
.
focusNode
!.
hasFocus
,
isFalse
);
expect
(
minuteField
.
focusNode
!.
hasFocus
,
isFalse
);
});
}
final
Finder
findDialPaint
=
find
.
descendant
(
...
...
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