Skip to content

Commit

Permalink
Add SemanticsFlag for Header (flutter#4752)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored Mar 6, 2018
1 parent 1b7325c commit 7f7634f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class SemanticsFlag {
static const int _kHasEnabledStateIndex = 1 << 6;
static const int _kIsEnabledIndex = 1 << 7;
static const int _kIsInMutuallyExclusiveGroupIndex = 1 << 8;
static const int _kIsHeaderIndex = 1 << 9;

const SemanticsFlag._(this.index);

Expand Down Expand Up @@ -292,6 +293,13 @@ class SemanticsFlag {
/// only one radio button in that group can be marked as [isChecked].
static const SemanticsFlag isInMutuallyExclusiveGroup = const SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex);

/// Whether a semantic node is a header that divides content into sections.
///
/// For example, headers can be used to divide a list of alphabetically
/// sorted words into the sections A, B, C, etc. as can be found in many
/// address book applications.
static const SemanticsFlag isHeader = const SemanticsFlag._(_kIsHeaderIndex);

/// The possible semantics flags.
///
/// The map's key is the [index] of the flag and the value is the flag itself.
Expand All @@ -305,6 +313,7 @@ class SemanticsFlag {
_kHasEnabledStateIndex: hasEnabledState,
_kIsEnabledIndex: isEnabled,
_kIsInMutuallyExclusiveGroupIndex: isInMutuallyExclusiveGroup,
_kIsHeaderIndex: isHeader,
};

@override
Expand All @@ -328,6 +337,8 @@ class SemanticsFlag {
return 'SemanticsFlag.isEnabled';
case _kIsInMutuallyExclusiveGroupIndex:
return 'SemanticsFlag.isInMutuallyExclusiveGroup';
case _kIsHeaderIndex:
return 'SemanticsFlag.isHeader';
}
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/semantics/semantics_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum class SemanticsFlags : int32_t {
kIsFocused = 1 << 5,
kHasEnabledState = 1 << 6,
kIsEnabled = 1 << 7,
kIsInMutuallyExclusiveGroup = 1 << 8,
kIsHeader = 1 << 9,
};

struct SemanticsNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ enum Flag {
IS_FOCUSED(1 << 5),
HAS_ENABLED_STATE(1 << 6),
IS_ENABLED(1 << 7),
IS_IN_MUTUALLY_EXCLUSIVE_GROUP(1 << 8);
IS_IN_MUTUALLY_EXCLUSIVE_GROUP(1 << 8),
IS_HEADER(1 << 9);

Flag(int value) {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ - (UIAccessibilityTraits)accessibilityTraits {
![self node].HasFlag(blink::SemanticsFlags::kIsEnabled)) {
traits |= UIAccessibilityTraitNotEnabled;
}
if ([self node].HasFlag(blink::SemanticsFlags::kIsHeader)) {
traits |= UIAccessibilityTraitHeader;
}
return traits;
}

Expand Down

0 comments on commit 7f7634f

Please sign in to comment.