Skip to content

Commit

Permalink
traits
Browse files Browse the repository at this point in the history
  • Loading branch information
crescentheaded committed Mar 3, 2024
1 parent e1fa61a commit d70a793
Show file tree
Hide file tree
Showing 12 changed files with 690 additions and 515 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@Tutorial(time: <#number#>) {
@Intro(title: "<#text#>") {
<#text#>

@Image(source: <#file#>, alt: "<#accessible description#>")
}

@Section(title: "<#text#>") {
@ContentAndMedia {
<#text#>

@Image(source: <#file#>, alt: "<#accessible description#>")
}

@Steps {
@Step {
<#text#>

@Image(source: <#file#>, alt: "<#accessible description#>")
}

@Step {
<#text#>

@Code(name: "<#display name#>", file: <#filename.swift#>)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
struct ContentView: View {
var body: some View {
VStack {
Text("WWDC 2021")
.accessibilityAddTraits(.isHeader)

Text("SwiftUI Accessibility")
Text("Beyond the Basics")

Image(systemName: "checkmark.seal.fill")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import SwiftUI

struct KeyboardKeyView: View {
var soundFile: String
var body: some View {
Rectangle()
.fill(.white)
.frame(width: 35, height: 80)
.onTapGesture(count: 1) {
playSound(sound: soundFile, type: "mp3")
}
.accessibilityDirectTouch(options: .silentOnTouch)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import SwiftUI

var body: some View {
VStack {
SliderTrack(...) // Custom slider implementation.
}
.accessibilityRepresentation {
Slider(value: $value, in: 0...100) {
Text("Label")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import SwiftUI

struct FilterButton: View {
@State var filter: Bool = false

var body: some View {
Button(action: { filter.toggle() }) {
Text("Filter")
}
.background(filter ? darkGreen : lightGreen)
.accessibilityAddTraits(.isToggle)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import UIKit

class ViewController: UIViewController {
let waveformButton = UIButton(type: .custom)

override func viewDidLoad() {
super.viewDidLoad()

waveformButton.accessibilityTraits = .allowsDirectInteraction
waveformButton.accessibilityDirectTouchOptions = .silentOnTouch
waveformButton.addTarget(self, action: #selector(playTone), for: .touchUpInside)

view.addSubview(waveformButton)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import UIKit

private func getHiddenTrait(
forIndex index: UInt64) -> UIAccessibilityTraits {
let traitRaw: UInt64 = 1 << index
return UIAccessibilityTraits(
rawValue: traitRaw)
}

let hiddenTraits = [
19: "pickeritem",
20: "radio button",
23: "status bar item",
25: "inactive",
26: "footer",
28: "tab",
32: "visited",
35: "tap and hold, then move up and down to select index",
38: "draggable",
39: "learning",
40: "pop-up button",
42: "maths",
45: "hide from focus",
50: "folder",
52: "menu item",
53: "double tap to toggle settings",
59: "video playback",
60: "icon",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// optionSet.swift
//
//
// Created by admin on 03.03.2024.
//

import Foundation
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import UIKit

class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

let filterButton = UIButton(type: .custom)

setupButtonView()

filterButton.accessibilityTraits = [.toggleButton]

view.addSubview(filterButton)
}
}
Loading

0 comments on commit d70a793

Please sign in to comment.