-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Easy accessibility configuration for views was added
AccessibilitySetting
- Loading branch information
Showing
9 changed files
with
195 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import UIKit | ||
|
||
public extension UI { | ||
enum AccessibilitySetting { | ||
case isElement(Bool) | ||
case identifier(String) | ||
case label(String) | ||
case hint(String) | ||
case value(String) | ||
case traits(UIAccessibilityTraits) | ||
case containerType(UIAccessibilityContainerType) | ||
case elements([Any]) | ||
case elementsHidden(Bool) | ||
case shouldGroupChildren(Bool) | ||
} | ||
} | ||
|
||
internal extension UI.AccessibilitySetting { | ||
func apply(to view: UIView) { | ||
switch self { | ||
case .isElement(let isElement): | ||
view.isAccessibilityElement = isElement | ||
case .identifier(let identifier): | ||
view.accessibilityIdentifier = identifier | ||
case .label(let label): | ||
view.accessibilityLabel = label | ||
case .hint(let hint): | ||
view.accessibilityHint = hint | ||
case .value(let value): | ||
view.accessibilityValue = value | ||
case .traits(let traits): | ||
view.accessibilityTraits = traits | ||
case .containerType(let type): | ||
view.accessibilityContainerType = type | ||
case .elementsHidden(let isHidden): | ||
view.accessibilityElementsHidden = isHidden | ||
case .elements(let elements): | ||
view.accessibilityElements = elements | ||
case .shouldGroupChildren(let shouldGroup): | ||
view.shouldGroupAccessibilityChildren = shouldGroup | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import UIKit | ||
|
||
public extension UIView { | ||
func accessibility(_ settings: [UI.AccessibilitySetting]) { | ||
for setting in settings { | ||
setting.apply(to: self) | ||
} | ||
} | ||
|
||
func accessibility(_ settings: UI.AccessibilitySetting...) { | ||
accessibility(settings) | ||
} | ||
} |
Oops, something went wrong.