mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Set slider semantics flag for sliders (#68019)
This commit is contained in:
parent
804c3ff31f
commit
f26fbb6bdd
|
@ -548,6 +548,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox {
|
|||
super.describeSemanticsConfiguration(config);
|
||||
|
||||
config.isSemanticBoundary = isInteractive;
|
||||
config.isSlider = true;
|
||||
if (isInteractive) {
|
||||
config.textDirection = textDirection;
|
||||
config.onIncrease = _increaseAction;
|
||||
|
|
|
@ -1529,6 +1529,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
|
|||
final SemanticsConfiguration config = SemanticsConfiguration();
|
||||
config.isEnabled = isEnabled;
|
||||
config.textDirection = textDirection;
|
||||
config.isSlider = true;
|
||||
if (isEnabled) {
|
||||
config.onIncrease = increaseAction;
|
||||
config.onDecrease = decreaseAction;
|
||||
|
|
|
@ -707,6 +707,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
|||
|
||||
return Semantics(
|
||||
container: true,
|
||||
slider: true,
|
||||
child: FocusableActionDetector(
|
||||
actions: _actionMap,
|
||||
shortcuts: _shortcutMap,
|
||||
|
|
|
@ -318,6 +318,7 @@ void main() {
|
|||
increasedValue: '60%',
|
||||
decreasedValue: '40%',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.isSlider],
|
||||
actions: SemanticsAction.decrease.index | SemanticsAction.increase.index,
|
||||
),
|
||||
],
|
||||
|
@ -341,7 +342,14 @@ void main() {
|
|||
);
|
||||
|
||||
expect(semantics, hasSemantics(
|
||||
TestSemantics.root(),
|
||||
TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
id: 1,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.isSlider],
|
||||
)
|
||||
],
|
||||
),
|
||||
ignoreRect: true,
|
||||
ignoreTransform: true,
|
||||
));
|
||||
|
@ -365,6 +373,7 @@ void main() {
|
|||
);
|
||||
|
||||
expect(tester.getSemantics(find.byType(CupertinoSlider)), matchesSemantics(
|
||||
isSlider: true,
|
||||
hasIncreaseAction: true,
|
||||
hasDecreaseAction: true,
|
||||
value: '50%',
|
||||
|
@ -387,6 +396,7 @@ void main() {
|
|||
);
|
||||
|
||||
expect(tester.getSemantics(find.byType(CupertinoSlider)), matchesSemantics(
|
||||
isSlider: true,
|
||||
hasIncreaseAction: true,
|
||||
hasDecreaseAction: true,
|
||||
value: '60%',
|
||||
|
|
|
@ -1775,6 +1775,7 @@ void main() {
|
|||
children: <Matcher>[
|
||||
matchesSemantics(
|
||||
isEnabled: true,
|
||||
isSlider: true,
|
||||
hasEnabledState: true,
|
||||
hasIncreaseAction: true,
|
||||
hasDecreaseAction: true,
|
||||
|
@ -1784,6 +1785,7 @@ void main() {
|
|||
),
|
||||
matchesSemantics(
|
||||
isEnabled: true,
|
||||
isSlider: true,
|
||||
hasEnabledState: true,
|
||||
hasIncreaseAction: true,
|
||||
hasDecreaseAction: true,
|
||||
|
|
|
@ -1345,7 +1345,7 @@ void main() {
|
|||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
id: 4,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider],
|
||||
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
|
||||
value: '50%',
|
||||
increasedValue: '55%',
|
||||
|
@ -1403,6 +1403,7 @@ void main() {
|
|||
SemanticsFlag.hasEnabledState,
|
||||
// isFocusable is delayed by 1 frame.
|
||||
SemanticsFlag.isFocusable,
|
||||
SemanticsFlag.isSlider,
|
||||
],
|
||||
value: '50%',
|
||||
increasedValue: '55%',
|
||||
|
@ -1443,6 +1444,7 @@ void main() {
|
|||
id: 4,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isSlider,
|
||||
],
|
||||
value: '50%',
|
||||
increasedValue: '55%',
|
||||
|
@ -1508,7 +1510,7 @@ void main() {
|
|||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
id: 4,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider],
|
||||
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
|
||||
value: '50%',
|
||||
increasedValue: '60%',
|
||||
|
@ -1562,7 +1564,7 @@ void main() {
|
|||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
id: 5,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState],
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isSlider],
|
||||
value: '50%',
|
||||
increasedValue: '60%',
|
||||
decreasedValue: '40%',
|
||||
|
@ -1623,7 +1625,7 @@ void main() {
|
|||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
id: 4,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider],
|
||||
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
|
||||
value: '40',
|
||||
increasedValue: '60',
|
||||
|
|
|
@ -468,6 +468,7 @@ Matcher matchesSemantics({
|
|||
bool hasToggledState = false,
|
||||
bool isToggled = false,
|
||||
bool hasImplicitScrolling = false,
|
||||
bool isSlider = false,
|
||||
// Actions //
|
||||
bool hasTapAction = false,
|
||||
bool hasLongPressAction = false,
|
||||
|
@ -519,6 +520,7 @@ Matcher matchesSemantics({
|
|||
if (hasToggledState) SemanticsFlag.hasToggledState,
|
||||
if (isToggled) SemanticsFlag.isToggled,
|
||||
if (hasImplicitScrolling) SemanticsFlag.hasImplicitScrolling,
|
||||
if (isSlider) SemanticsFlag.isSlider
|
||||
];
|
||||
|
||||
final List<SemanticsAction> actions = <SemanticsAction>[
|
||||
|
|
Loading…
Reference in a new issue