Unverified Commit f5415a42 authored by Bernardo Ferrari's avatar Bernardo Ferrari Committed by GitHub

`SemanticsFlag`/`SemanticsAction` enum migration (part 2) (#123817)

`SemanticsFlag`/`SemanticsAction` enum migration (part 2)
parent f6c2b10e
...@@ -669,7 +669,8 @@ class SemanticsData with Diagnosticable { ...@@ -669,7 +669,8 @@ class SemanticsData with Diagnosticable {
properties.add(DoubleProperty('elevation', elevation, defaultValue: 0.0)); properties.add(DoubleProperty('elevation', elevation, defaultValue: 0.0));
properties.add(DoubleProperty('thickness', thickness, defaultValue: 0.0)); properties.add(DoubleProperty('thickness', thickness, defaultValue: 0.0));
final List<String> actionSummary = <String>[ final List<String> actionSummary = <String>[
for (final SemanticsAction action in SemanticsAction.values.values) // ignore: deprecated_member_use
for (final SemanticsAction action in SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList)
if ((actions & action.index) != 0) if ((actions & action.index) != 0)
describeEnum(action), describeEnum(action),
]; ];
...@@ -680,7 +681,8 @@ class SemanticsData with Diagnosticable { ...@@ -680,7 +681,8 @@ class SemanticsData with Diagnosticable {
properties.add(IterableProperty<String?>('customActions', customSemanticsActionSummary, ifEmpty: null)); properties.add(IterableProperty<String?>('customActions', customSemanticsActionSummary, ifEmpty: null));
final List<String> flagSummary = <String>[ final List<String> flagSummary = <String>[
for (final SemanticsFlag flag in SemanticsFlag.values.values) // ignore: deprecated_member_use
for (final SemanticsFlag flag in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList)
if ((flags & flag.index) != 0) if ((flags & flag.index) != 0)
describeEnum(flag), describeEnum(flag),
]; ];
...@@ -2755,7 +2757,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -2755,7 +2757,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
.toList(); .toList();
properties.add(IterableProperty<String>('actions', actions, ifEmpty: null)); properties.add(IterableProperty<String>('actions', actions, ifEmpty: null));
properties.add(IterableProperty<String?>('customActions', customSemanticsActions, ifEmpty: null)); properties.add(IterableProperty<String?>('customActions', customSemanticsActions, ifEmpty: null));
final List<String> flags = SemanticsFlag.values.values.where((SemanticsFlag flag) => hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList(); // ignore: deprecated_member_use
final List<String> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.where((SemanticsFlag flag) => hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList();
properties.add(IterableProperty<String>('flags', flags, ifEmpty: null)); properties.add(IterableProperty<String>('flags', flags, ifEmpty: null));
properties.add(FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible')); properties.add(FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible'));
properties.add(FlagProperty('isHidden', value: hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN')); properties.add(FlagProperty('isHidden', value: hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN'));
......
...@@ -346,7 +346,8 @@ void _defineTests() { ...@@ -346,7 +346,8 @@ void _defineTests() {
), ),
), ),
)); ));
final Set<SemanticsAction> allActions = SemanticsAction.values.values.toSet() // ignore: deprecated_member_use
final Set<SemanticsAction> allActions = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList.toSet()
..remove(SemanticsAction.customAction) // customAction is not user-exposed. ..remove(SemanticsAction.customAction) // customAction is not user-exposed.
..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed ..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed
...@@ -444,7 +445,8 @@ void _defineTests() { ...@@ -444,7 +445,8 @@ void _defineTests() {
), ),
), ),
)); ));
List<SemanticsFlag> flags = SemanticsFlag.values.values.toList(); // ignore: deprecated_member_use
List<SemanticsFlag> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties] // [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed. // therefore it has to be removed.
flags flags
...@@ -498,7 +500,8 @@ void _defineTests() { ...@@ -498,7 +500,8 @@ void _defineTests() {
), ),
), ),
)); ));
flags = SemanticsFlag.values.values.toList(); // ignore: deprecated_member_use
flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties] // [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed. // therefore it has to be removed.
flags flags
......
...@@ -520,7 +520,8 @@ void main() { ...@@ -520,7 +520,8 @@ void main() {
), ),
); );
final Set<SemanticsAction> allActions = SemanticsAction.values.values.toSet() // ignore: deprecated_member_use
final Set<SemanticsAction> allActions = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList.toSet()
..remove(SemanticsAction.moveCursorForwardByWord) ..remove(SemanticsAction.moveCursorForwardByWord)
..remove(SemanticsAction.moveCursorBackwardByWord) ..remove(SemanticsAction.moveCursorBackwardByWord)
..remove(SemanticsAction.customAction) // customAction is not user-exposed. ..remove(SemanticsAction.customAction) // customAction is not user-exposed.
...@@ -612,7 +613,8 @@ void main() { ...@@ -612,7 +613,8 @@ void main() {
liveRegion: true, liveRegion: true,
), ),
); );
final List<SemanticsFlag> flags = SemanticsFlag.values.values.toList(); // ignore: deprecated_member_use
final List<SemanticsFlag> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
flags flags
..remove(SemanticsFlag.hasToggledState) ..remove(SemanticsFlag.hasToggledState)
..remove(SemanticsFlag.isToggled) ..remove(SemanticsFlag.isToggled)
......
...@@ -633,7 +633,8 @@ class SemanticsTester { ...@@ -633,7 +633,8 @@ class SemanticsTester {
static String _flagsToSemanticsFlagExpression(dynamic flags) { static String _flagsToSemanticsFlagExpression(dynamic flags) {
Iterable<SemanticsFlag> list; Iterable<SemanticsFlag> list;
if (flags is int) { if (flags is int) {
list = SemanticsFlag.values.values // ignore: deprecated_member_use
list = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList
.where((SemanticsFlag flag) => (flag.index & flags) != 0); .where((SemanticsFlag flag) => (flag.index & flags) != 0);
} else { } else {
list = flags as List<SemanticsFlag>; list = flags as List<SemanticsFlag>;
...@@ -648,7 +649,8 @@ class SemanticsTester { ...@@ -648,7 +649,8 @@ class SemanticsTester {
static String _actionsToSemanticsActionExpression(dynamic actions) { static String _actionsToSemanticsActionExpression(dynamic actions) {
Iterable<SemanticsAction> list; Iterable<SemanticsAction> list;
if (actions is int) { if (actions is int) {
list = SemanticsAction.values.values // ignore: deprecated_member_use
list = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList
.where((SemanticsAction action) => (action.index & actions) != 0); .where((SemanticsAction action) => (action.index & actions) != 0);
} else { } else {
list = actions as List<SemanticsAction>; list = actions as List<SemanticsAction>;
......
...@@ -613,10 +613,12 @@ void main() { ...@@ -613,10 +613,12 @@ void main() {
int actions = 0; int actions = 0;
int flags = 0; int flags = 0;
const CustomSemanticsAction action = CustomSemanticsAction(label: 'test'); const CustomSemanticsAction action = CustomSemanticsAction(label: 'test');
for (final int index in SemanticsAction.values.keys) { // ignore: deprecated_member_use
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) {
actions |= index; actions |= index;
} }
for (final int index in SemanticsFlag.values.keys) { // ignore: deprecated_member_use
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) {
flags |= index; flags |= index;
} }
final SemanticsData data = SemanticsData( final SemanticsData data = SemanticsData(
...@@ -895,10 +897,12 @@ void main() { ...@@ -895,10 +897,12 @@ void main() {
int actions = 0; int actions = 0;
int flags = 0; int flags = 0;
const CustomSemanticsAction action = CustomSemanticsAction(label: 'test'); const CustomSemanticsAction action = CustomSemanticsAction(label: 'test');
for (final int index in SemanticsAction.values.keys) { // ignore: deprecated_member_use
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) {
actions |= index; actions |= index;
} }
for (final int index in SemanticsFlag.values.keys) { // ignore: deprecated_member_use
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) {
flags |= index; flags |= index;
} }
final SemanticsData data = SemanticsData( final SemanticsData data = SemanticsData(
...@@ -1081,10 +1085,12 @@ void main() { ...@@ -1081,10 +1085,12 @@ void main() {
testWidgets('only matches given flags and actions', (WidgetTester tester) async { testWidgets('only matches given flags and actions', (WidgetTester tester) async {
int allActions = 0; int allActions = 0;
int allFlags = 0; int allFlags = 0;
for (final int index in SemanticsAction.values.keys) { // ignore: deprecated_member_use
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) {
allActions |= index; allActions |= index;
} }
for (final int index in SemanticsFlag.values.keys) { // ignore: deprecated_member_use
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) {
allFlags |= index; allFlags |= index;
} }
final SemanticsData emptyData = SemanticsData( final SemanticsData emptyData = SemanticsData(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment