moved down common isEnabled/isSelected down to base classes Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
35 lines
881 B
Swift
35 lines
881 B
Swift
//
|
|
// ViewProtocol.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 7/22/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
public protocol ViewProtocol {
|
|
|
|
// Can setup ui here. Should be called in the initialization functions.
|
|
func setup()
|
|
func updateAccessibility()
|
|
}
|
|
|
|
extension ViewProtocol where Self: UIView {
|
|
public func removeFromSuperview(_ view: UIView){
|
|
if view.superview != nil {
|
|
view.removeFromSuperview()
|
|
setNeedsDisplay()
|
|
}
|
|
}
|
|
|
|
public func combineAccessibilityLabel(for views: [UIView]) -> String? {
|
|
let labels = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0})
|
|
return labels.joined(separator: ", ")
|
|
}
|
|
|
|
public func setAccessibilityLabel(for views: [UIView]) {
|
|
accessibilityLabel = combineAccessibilityLabel(for: views)
|
|
}
|
|
}
|