mirror of
https://github.com/sparrowcode/AlertKit.git
synced 2026-06-16 12:44:37 +00:00
Update example.
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user