This file contains hidden or 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
class SectionHeader: UICollectionReusableView { | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
accessibilityTraits.insert(.header) | |
} | |
} |
This file contains hidden or 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
import UIKit | |
class RatingView: UIView { | |
private(set) var value: Int = 1 | |
override var accessibilityTraits: UIAccessibilityTraits { | |
get { return .adjustable } | |
set {} | |
} |
This file contains hidden or 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
import UIKit | |
class ViewController: UIViewController { | |
override func accessibilityPerformEscape() -> Bool { | |
dismiss(animated: true) | |
return true | |
} | |
} |
This file contains hidden or 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
struct PresentationViewModel { | |
let title: String | |
let summary: String | |
let date: String | |
init(presentation: Presentation) { | |
title = presentation.title | |
summary = presentation.summary | |
date = DateFormatter.short.string(from: presentation.date) | |
} |
This file contains hidden or 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
class PresentationCell: UITableViewCell { | |
var viewModel: PresentationViewModel? { | |
didSet { | |
accessibilityLabel = viewModel?.label | |
accessibilityValue = viewModel?.value | |
} | |
} | |
override func awakeFromNib() { | |
super.awakeFromNib() |
This file contains hidden or 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
protocol UIAccessibility: AnyObject { | |
var isAccessibilityElement: Bool { get set } | |
var accessibilityTraits: UIAccessibilityTraits { get set } | |
var accessibilityLabel: String? { get set } | |
var accessibilityValue: String? { get set } | |
} |
This file contains hidden or 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
let elements = statistics.enumerated().map { | |
let frame = CGRect(x: 0, y: CGFloat($0 * Layout.barHeight), width: bounds.width, height: Layout.barHeight) | |
let element = UIAccessibilityElement(accessibilityContainer: self) | |
element.accessibilityLabel = $1.time | |
element.accessibilityValue = "\(Int($1.value)), \($1.status)" | |
element.accessibilityFrameInContainerSpace = frame | |
return element | |
} | |
self.accessibilityElements = elements |
This file contains hidden or 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
self.isAccessibilityElement = true | |
self.accessibilityLabel = "\(date), \(value) - \(status)" | |
self.accessibilityTraits |= UIAccessibilityTraitButton |
This file contains hidden or 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
import Bond | |
import ReactiveKit | |
class UserProfileViewModel { | |
let refreshing = Observable<Bool>(false) | |
let username = Observable<String>("") | |
let photos = Observable<[Photos]>([]) | |
private let userViewModel: UserViewModel | |
private let photosViewModel: PhotosViewModel |
This file contains hidden or 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
class ItemsViewController: UIViewController { | |
@IBOutlet private weak var tableView: UITableView! | |
private let activityIndicator = ActivityIndicatorView() | |
private var viewModel: ItemsViewModel | |
init(viewModel: ItemsViewModel) { | |
self.viewModel = viewModel | |
super.init(nibName: nil, bundle: nil) | |
} | |