Settings: Switch to UIKit

This commit is contained in:
James Magahern
2021-06-29 18:09:42 -07:00
parent c60df21c54
commit 656cf55b96
9 changed files with 424 additions and 26 deletions

View File

@@ -0,0 +1,47 @@
//
// GenericContentView.swift
// GenericContentView
//
// Created by James Magahern on 6/29/21.
//
import UIKit
class GenericContentView<View, Configuration> : UIView, UIContentView
where View: UIView, Configuration: UIContentConfiguration
{
typealias Applicator = (Configuration, View) -> Void
var insets: UIEdgeInsets = .zero
let applicator: Applicator
let view: View
var configuration: UIContentConfiguration {
didSet {
guard let config = configuration as? Configuration else { return }
apply(config)
}
}
init(configuration: Configuration, view: View, applicator: @escaping Applicator) {
self.configuration = configuration
self.view = view
self.applicator = applicator
super.init(frame: .zero)
addSubview(view)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
view.frame = bounds.inset(by: insets)
}
internal func apply(_ configuration: Configuration) {
applicator(configuration, view)
}
}