52 lines
1.6 KiB
Swift
52 lines
1.6 KiB
Swift
import UIKit
|
|
|
|
class ModalViewController: UIViewController {
|
|
|
|
let navBar = SPFakeBarView(style: .stork)
|
|
var lightStatusBar: Bool = false
|
|
override var preferredStatusBarStyle: UIStatusBarStyle {
|
|
return self.lightStatusBar ? .lightContent : .default
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.view.backgroundColor = UIColor.white
|
|
self.modalPresentationCapturesStatusBarAppearance = true
|
|
|
|
self.navBar.titleLabel.text = "View"
|
|
self.navBar.leftButton.setTitle("Cancel", for: .normal)
|
|
self.navBar.leftButton.addTarget(self, action: #selector(self.dismissAction), for: .touchUpInside)
|
|
self.view.addSubview(self.navBar)
|
|
}
|
|
|
|
@objc func dismissAction() {
|
|
self.dismiss()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
self.lightStatusBar = true
|
|
UIView.animate(withDuration: 0.3) { () -> Void in
|
|
self.setNeedsStatusBarAppearanceUpdate()
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ModalViewController: SPStorkControllerConfirmDelegate {
|
|
|
|
var needConfirm: Bool {
|
|
return false
|
|
}
|
|
|
|
func confirm(_ completion: @escaping (Bool) -> ()) {
|
|
let alertController = UIAlertController(title: "Need dismiss?", message: "It test confirm option for SPStorkController", preferredStyle: .actionSheet)
|
|
alertController.addAction(title: "Confirm", complection: {
|
|
completion(true)
|
|
})
|
|
alertController.addCancelAction(title: "Cancel") {
|
|
completion(false)
|
|
}
|
|
self.present(alertController)
|
|
}
|
|
}
|