Update example.

This commit is contained in:
Ivan Vorobei
2020-11-19 09:42:23 +03:00
parent ecd5c17ede
commit 00533ced71
4 changed files with 60 additions and 11 deletions
+3 -7
View File
@@ -23,15 +23,11 @@ import UIKit
import SparrowKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
class AppDelegate: SPAppWindowDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let frame = UIScreen.main.bounds
window = UIWindow(frame: frame)
window?.rootViewController = UINavigationController(rootViewController: UIViewController())
window?.makeKeyAndVisible()
let rootController = PresetsController().wrapToNavigationController(prefersLargeTitles: false)
makeKeyAndVisible(rootController)
return true
}
}
@@ -0,0 +1,45 @@
import UIKit
import SparrowKit
import SPDiffable
// Maybe ding toolbar
class PresetsController: SPDiffableTableController {
init() {
super.init(style: .insetGrouped)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "SPAlert Presets"
setCellProviders(SPDiffableTableCellProviders.default, sections: content)
}
fileprivate var presets: [AlertPreset] {
return [
AlertPreset(name: "Done", preset: .done),
AlertPreset(name: "Heart", preset: .heart)
]
}
var content: [SPDiffableSection] {
let items = presets.map { (preset) -> SPDiffableTableRow in
return SPDiffableTableRow(text: preset.name, accessoryType: .none, selectionStyle: .none) { (_) in
return
}
}
return [
SPDiffableSection(identifier: "presets", header: nil, footer: nil, items: items)
]
}
}
struct AlertPreset {
var name: String
var preset: SPAlertPreset
}
+7 -1
View File
@@ -21,10 +21,16 @@
import UIKit
public enum SPAlertPreset {
public enum SPAlertPreset: CaseIterable {
case done
case heart
case custom(_ image: UIImage)
// MARK: - CaseIterable
public static var allCases: [SPAlertPreset] {
return [.done, .heart]
}
}
+5 -3
View File
@@ -23,9 +23,7 @@ import UIKit
open class SPAlertView: UIView {
// MARK: - Properties
open var dismissByTap: Bool = true
// MARK: - Views
private lazy var titleLabel: UILabel = {
let label = UILabel()
@@ -51,6 +49,10 @@ open class SPAlertView: UIView {
return view
}()
// MARK: - Properties
open var dismissByTap: Bool = true
// MARK: - Initializers
public init(title: String, message: String?, preset: SPAlertPreset) {