Skip to content

Commit

Permalink
chore: improve some accessibility modifiers, add Text, LocalizedStrin…
Browse files Browse the repository at this point in the history
…g, and Label structures
  • Loading branch information
helbertgs committed Sep 21, 2024
1 parent cf0bfc2 commit 277e9a1
Show file tree
Hide file tree
Showing 28 changed files with 757 additions and 115 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public struct AccessibilityActionResult {
public init() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

class AccessibilityActionStorage<Value> : AnyAccessibilityAction {
var action: Value
var category: AccessibilityActionCategory?
var label: Text?
var image: Image?
var handler: Any?
var seed: Int

init(action: Value, category: AccessibilityActionCategory?, label: Text?, image: Image?, handler: Any?, seed: Int) {
self.action = action
self.category = category
self.label = label
self.image = image
self.handler = handler
self.seed = seed
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

public struct AccessibilityAttachment {
var properties: AccessibilityProperties
var platformElement: (any PlatformAccessibilityElementProtocol)?

init(properties: AccessibilityProperties, platformElement: (any PlatformAccessibilityElementProtocol)?) {
self.properties = properties
self.platformElement = platformElement
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import Foundation

/// A view modifier that adds accessibility properties to the view
public struct AccessibilityAttachmentModifier {
public init() {
let storage: MutableBox<AccessibilityAttachment>
let behavior: AccessibilityChildBehavior?

public init(storage: MutableBox<AccessibilityAttachment>, behavior: AccessibilityChildBehavior?) {
self.storage = storage
self.behavior = behavior
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

class AccessibilityProperties {
let storage: [ObjectIdentifier: Any]

init(storage: [ObjectIdentifier: Any]) {
self.storage = storage
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

class AccessibilityPropertiesEntry<Value> {
let typedValue: Value

init(typedValue: Value) {
self.typedValue = typedValue
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

struct AccessibilityScrollAction {
init() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

class AccessibilityVoidAction {
var kind: AccessibilityActionKind

init(kind: AccessibilityActionKind) {
self.kind = kind
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

class AnyAccessibilityAction {
var bridged: Bool = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Foundation

protocol PlatformAccessibilityElementProtocol {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ extension View {
/// Creates a new accessibility element, or modifies the AccessibilityChildBehavior of the existing accessibility element.
/// - Parameter children: The behavior to use when creating or transforming an accessibility element. The default is ignore
nonisolated public func accessibilityElement(children: AccessibilityChildBehavior = .ignore) -> some View {
modifier(EmptyModifier())
fatalError()
}

/// Replaces the existing accessibility element’s children with one or more new synthetic accessibility elements.
/// - Parameter children: A ViewBuilder that represents the replacement child views the framework uses to generate accessibility elements.
nonisolated public func accessibilityChildren<V>(@ViewBuilder children: () -> V) -> some View where V : View {
modifier(EmptyModifier())
fatalError()
}

/// Replaces one or more accessibility elements for this view with new accessibility elements.
/// - Parameter representation: A hidden view that the accessibility system uses to generate accessibility elements.
nonisolated public func accessibilityRepresentation<V>(@ViewBuilder representation: () -> V) -> some View where V : View {
modifier(EmptyModifier())
fatalError()
}

// MARK: - Identifying elements

/// Uses the string you specify to identify the view.
/// Use this value for testing. It isn’t visible to the user.
nonisolated public func accessibilityIdentifier(_ identifier: String) -> ModifiedContent<Self, AccessibilityAttachmentModifier> {
modifier(AccessibilityAttachmentModifier())
fatalError()
}

/// Uses the string you specify to identify the view.
Expand All @@ -36,21 +36,21 @@ extension View {
/// - identifier: The accessibility identifier to apply.
/// - isEnabled: If true the accessibility identifier is applied; otherwise the accessibility identifier is unchanged.
nonisolated public func accessibilityIdentifier(_ identifier: String, isEnabled: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> {
modifier(AccessibilityAttachmentModifier())
fatalError()
}

// MARK: - Hiding elements

/// Specifies whether to hide this view from system accessibility features.
nonisolated public func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> {
modifier(AccessibilityAttachmentModifier())
fatalError()
}

/// Specifies whether to hide this view from system accessibility features.
/// - Parameters:
/// - hidden: Whether to hide this view from accessibility features.
/// - isEnabled: If true the accessibility hidden state is applied; otherwise the accessibility hidden state is unchanged.
nonisolated public func accessibilityHidden(_ hidden: Bool, isEnabled: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> {
modifier(AccessibilityAttachmentModifier())
fatalError()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ extension View {
/// - Parameter active: A true value ignores the system Smart Invert setting. A false value follows the system setting.
/// - Returns: The modified view.
nonisolated public func accessibilityIgnoresInvertColors(_ active: Bool = true) -> some View {
modifier(EmptyModifier())
fatalError()
}

// MARK: - Enlarging content

/// Adds a default large content view to be shown by the large content viewer.
/// - Returns: The modified view.
nonisolated public func accessibilityShowsLargeContentViewer() -> some View {
modifier(EmptyModifier())
fatalError()
}

/// Adds a custom large content view to be shown by the large content viewer.
/// - Returns: The modified view.
nonisolated public func accessibilityShowsLargeContentViewer<V>(@ViewBuilder _ largeContentView: () -> V) -> some View where V : View {
modifier(EmptyModifier())
fatalError()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public struct AccessibilityActionKind : Equatable, Sendable {

// MARK: - Creating an action type

public init(named name: String) {
public init(named name: Text) {
self = .init(kind: .custom(name))
}

Expand All @@ -47,7 +47,7 @@ extension AccessibilityActionKind {
case delete
case magicTap
case showMenu
case custom(String)
case custom(Text)

static func == (_ lhs: ActionKind, _ rhs: ActionKind) -> Bool {
return switch (lhs, rhs) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

class AccessibilityAdjustableAction : AnyAccessibilityAction {
var continuous: Bool?

init(continuous: Bool?) {
self.continuous = continuous
}
}
Loading

0 comments on commit 277e9a1

Please sign in to comment.