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
79400b24
Unverified
Commit
79400b24
authored
Oct 01, 2020
by
Rami
Committed by
GitHub
Oct 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Material] Update some semantics for time picker controls (#66652)
parent
9d41ddcb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
5 deletions
+57
-5
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+13
-3
time_picker_test.dart
packages/flutter/test/material/time_picker_test.dart
+44
-2
No files found.
packages/flutter/lib/src/material/time_picker.dart
View file @
79400b24
...
...
@@ -560,6 +560,7 @@ class _DayPeriodControl extends StatelessWidget {
onTap:
Feedback
.
wrapForTap
(()
=>
_setAm
(
context
),
context
),
child:
Semantics
(
selected:
amSelected
,
button:
true
,
child:
Center
(
child:
Text
(
materialLocalizations
.
anteMeridiemAbbreviation
,
...
...
@@ -577,6 +578,7 @@ class _DayPeriodControl extends StatelessWidget {
onTap:
Feedback
.
wrapForTap
(()
=>
_setPm
(
context
),
context
),
child:
Semantics
(
selected:
pmSelected
,
button:
true
,
child:
Center
(
child:
Text
(
materialLocalizations
.
postMeridiemAbbreviation
,
...
...
@@ -1522,6 +1524,7 @@ class _HourTextField extends StatelessWidget {
selectedTime:
selectedTime
,
isHour:
true
,
style:
style
,
semanticHintText:
MaterialLocalizations
.
of
(
context
).
timePickerHourLabel
,
validator:
validator
,
onSavedSubmitted:
onSavedSubmitted
,
onChanged:
onChanged
,
...
...
@@ -1549,6 +1552,7 @@ class _MinuteTextField extends StatelessWidget {
selectedTime:
selectedTime
,
isHour:
false
,
style:
style
,
semanticHintText:
MaterialLocalizations
.
of
(
context
).
timePickerMinuteLabel
,
validator:
validator
,
onSavedSubmitted:
onSavedSubmitted
,
);
...
...
@@ -1561,6 +1565,7 @@ class _HourMinuteTextField extends StatefulWidget {
@required
this
.
selectedTime
,
@required
this
.
isHour
,
@required
this
.
style
,
@required
this
.
semanticHintText
,
@required
this
.
validator
,
@required
this
.
onSavedSubmitted
,
this
.
onChanged
,
...
...
@@ -1569,6 +1574,7 @@ class _HourMinuteTextField extends StatefulWidget {
final
TimeOfDay
selectedTime
;
final
bool
isHour
;
final
TextStyle
style
;
final
String
semanticHintText
;
final
FormFieldValidator
<
String
>
validator
;
final
ValueChanged
<
String
>
onSavedSubmitted
;
final
ValueChanged
<
String
>
onChanged
;
...
...
@@ -1636,10 +1642,14 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> {
);
}
final
Color
unfocusedFillColor
=
timePickerTheme
.
hourMinuteColor
??
colorScheme
.
onSurface
.
withOpacity
(
0.12
);
// If screen reader is in use, make the hint text say hours/minutes.
// Otherwise, remove the hint text when focused because the centered cursor
// appears odd above the hint text.
final
String
hintText
=
MediaQuery
.
of
(
context
).
accessibleNavigation
?
widget
.
semanticHintText
:
(
focusNode
.
hasFocus
?
null
:
_formattedValue
);
inputDecoration
=
inputDecoration
.
copyWith
(
// Remove the hint text when focused because the centered cursor appears
// odd above the hint text.
hintText:
focusNode
.
hasFocus
?
null
:
_formattedValue
,
hintText:
hintText
,
fillColor:
focusNode
.
hasFocus
?
Colors
.
transparent
:
inputDecorationTheme
?.
fillColor
??
unfocusedFillColor
,
);
...
...
packages/flutter/test/material/time_picker_test.dart
View file @
79400b24
...
...
@@ -324,8 +324,22 @@ void _tests() {
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
mediaQueryBoilerplate
(
tester
,
false
);
expect
(
semantics
,
includesNodeWith
(
label:
'AM'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
]));
expect
(
semantics
,
includesNodeWith
(
label:
'PM'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
]));
expect
(
semantics
,
includesNodeWith
(
label:
'AM'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isSelected
,
SemanticsFlag
.
isFocusable
],
),
);
expect
(
semantics
,
includesNodeWith
(
label:
'PM'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isFocusable
],
),
);
semantics
.
dispose
();
});
...
...
@@ -349,6 +363,32 @@ void _tests() {
semantics
.
dispose
();
});
testWidgets
(
'provides semantics information for text fields'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
mediaQueryBoilerplate
(
tester
,
true
,
entryMode:
TimePickerEntryMode
.
input
,
accessibleNavigation:
true
);
expect
(
semantics
,
includesNodeWith
(
label:
'Hour'
,
value:
'07'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isMultiline
],
),
);
expect
(
semantics
,
includesNodeWith
(
label:
'Minute'
,
value:
'00'
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isMultiline
],
),
);
semantics
.
dispose
();
});
testWidgets
(
'can increment and decrement hours'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
...
...
@@ -840,6 +880,7 @@ Future<void> mediaQueryBoilerplate(
double
textScaleFactor
=
1.0
,
TimePickerEntryMode
entryMode
=
TimePickerEntryMode
.
dial
,
String
helpText
,
bool
accessibleNavigation
=
false
,
})
async
{
await
tester
.
pumpWidget
(
Localizations
(
...
...
@@ -852,6 +893,7 @@ Future<void> mediaQueryBoilerplate(
data:
MediaQueryData
(
alwaysUse24HourFormat:
alwaysUse24HourFormat
,
textScaleFactor:
textScaleFactor
,
accessibleNavigation:
accessibleNavigation
,
),
child:
Material
(
child:
Directionality
(
...
...
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