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 | |
protocol AccessibilityModel { | |
/// Whether the view should be an accessibility element | |
var isAccessibilityElement: Bool { get } | |
/// An optional accessibility label. This is read out by VoiceOver as | |
/// soon as the VoiceOver cursor focuses on the accessibility element. | |
/// |
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 CellViewModel: AccessibilityModel { | |
// Standard view model properties | |
// that we use to populate a cell | |
let titleString: String | |
let subtitleString: String | |
let actionString: String | |
// AccessibilityModel properties |
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
extension UIView { | |
func updateAccessibility(with accessibilityModel: AccessibilityModel) { | |
self.isAccessibilityElement = accessibilityModel.isAccessibilityElement | |
self.accessibilityLabel = accessibilityModel.accessibilityLabel | |
self.accessibilityHint = accessibilityModel.accessibilityHint | |
self.accessibilityIdentifier = accessibilityModel.accessibilityIdentifier | |
self.accessibilityTraits = accessibilityModel.accessibilityTraits | |
} |
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
final class Cell: UICollectionViewCell { | |
@IBOutlet private var titleLabel: UILabel! | |
@IBOutlet private var subtitleLabel: UILabel! | |
@IBOutlet private var actionLabel: UILabel! | |
func configure(with viewModel: CellViewModel) { | |
// Populate labels with the view model like always | |
self.titleLabel.text = viewModel.titleString |
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 CustomCell: UICollectionViewCell { | |
@IBOutlet private var contentView: UIView! // Subview of `self` | |
@IBOutlet private var titleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var subtitleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var actionLabel: UIView! // Subview of `contentView` | |
} |
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 CustomCell: UICollectionViewCell { | |
@IBOutlet private var contentView: UIView! // Subview of `self` | |
@IBOutlet private var titleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var subtitleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var actionLabel: UIView! // Subview of `contentView` | |
private func setupAccessibility() { | |
contentView.isAccessibilityElement = 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
class CustomCell: UICollectionViewCell { | |
@IBOutlet private var contentView: UIView! // Subview of `self` | |
@IBOutlet private var titleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var subtitleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var actionLabel: UIView! // Subview of `contentView` | |
private func setupAccessibility() { | |
contentView.isAccessibilityElement = 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
let manager = CLLocationManager() | |
manager.requestWhenInUseAuthorization() | |
manager.requestAlwaysAuthorization() |
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
// - Significant change monitoring: | |
manager.startMonitoringSignificantLocationChanges() | |
// - Visit monitoring: | |
manager.startMonitoringVisits() | |
// - Region monitoring: | |
manager.startMonitoring(for: CLCircularRegion()) |
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
manager.allowsBackgroundLocationUpdates = true |
OlderNewer