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