mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-23 03:36:34 +10:00
show cancel if skills dirty
This commit is contained in:
@@ -18,7 +18,6 @@ class YepNavigationController: UINavigationController, UIGestureRecognizerDelega
|
||||
|
||||
delegate = self
|
||||
}
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
@@ -77,14 +76,52 @@ class YepNavigationController: UINavigationController, UIGestureRecognizerDelega
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
||||
// Get the new view controller using segue.destinationViewController.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/20327165/popviewcontroller-strange-behaviour
|
||||
// 很难work,无法重载
|
||||
//// MARK: UINavigationBarDelegate
|
||||
//
|
||||
//extension UINavigationController {
|
||||
//
|
||||
//// func navigationBar(navigationBar: UINavigationBar, shouldPopItem item: UINavigationItem) -> Bool {
|
||||
//// return true
|
||||
//// }
|
||||
//}
|
||||
//
|
||||
//extension YepNavigationController: UINavigationBarDelegate {
|
||||
//
|
||||
// //override
|
||||
// func navigationBar(navigationBar: UINavigationBar, shouldPopItem item: UINavigationItem) -> Bool {
|
||||
//
|
||||
// let forcePop: () -> Void = {
|
||||
// self.dirtyAction = nil
|
||||
// self.forcePopAction?()
|
||||
// self.forcePopAction = nil
|
||||
// }
|
||||
//
|
||||
// if let dirtyAction = dirtyAction {
|
||||
//
|
||||
// YepAlert.confirmOrCancel(title: NSLocalizedString("Notice", comment: ""), message: NSLocalizedString("Save before pop?", comment: ""), confirmTitle: NSLocalizedString("OK", comment: ""), cancelTitle: NSLocalizedString("Cancel", comment: ""), inViewController: self.topViewController, withConfirmAction: {
|
||||
//
|
||||
// dirtyAction()
|
||||
//
|
||||
// forcePop()
|
||||
//
|
||||
// }, cancelAction: {
|
||||
// forcePop()
|
||||
// })
|
||||
//
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// return true
|
||||
// //return super.navigationBar(navigationBar, shouldPopItem: item)
|
||||
// }
|
||||
//
|
||||
// func navigationBar(navigationBar: UINavigationBar, didPopItem item: UINavigationItem) {
|
||||
//// self.forcePopAction?()
|
||||
//// self.forcePopAction = nil
|
||||
// self.popViewControllerAnimated(true)
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -11,6 +11,17 @@ import UIKit
|
||||
class RegisterPickSkillsViewController: BaseViewController {
|
||||
|
||||
var isRegister = true
|
||||
var isDirty = false {
|
||||
didSet {
|
||||
if !isRegister {
|
||||
let backBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: "cancel")
|
||||
navigationItem.leftBarButtonItem = backBarButtonItem
|
||||
}
|
||||
|
||||
navigationItem.rightBarButtonItem?.enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
var afterChangeSkillsAction: ((masterSkills: [Skill], learningSkills: [Skill]) -> Void)?
|
||||
|
||||
@IBOutlet weak var skillsCollectionView: UICollectionView!
|
||||
@@ -39,8 +50,9 @@ class RegisterPickSkillsViewController: BaseViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let doneBarButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "saveSkills:")
|
||||
navigationItem.rightBarButtonItem = doneBarButton
|
||||
let doneBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "saveSkills:")
|
||||
navigationItem.rightBarButtonItem = doneBarButtonItem
|
||||
navigationItem.rightBarButtonItem?.enabled = false
|
||||
|
||||
if !isRegister {
|
||||
navigationItem.titleView = NavigationTitleLabel(title: NSLocalizedString("Change Skills", comment: ""))
|
||||
@@ -70,7 +82,15 @@ class RegisterPickSkillsViewController: BaseViewController {
|
||||
}
|
||||
}
|
||||
|
||||
func cancel() {
|
||||
navigationController?.popViewControllerAnimated(true)
|
||||
}
|
||||
|
||||
@IBAction func saveSkills(sender: AnyObject) {
|
||||
doSaveSkills()
|
||||
}
|
||||
|
||||
func doSaveSkills() {
|
||||
|
||||
YepHUD.showActivityIndicator()
|
||||
|
||||
@@ -236,6 +256,10 @@ class RegisterPickSkillsViewController: BaseViewController {
|
||||
|
||||
self.updateSkillsCollectionView()
|
||||
|
||||
if !self.isDirty {
|
||||
self.isDirty = success
|
||||
}
|
||||
|
||||
return success
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user