Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Dismiss picker on view disappearing (#126)
Browse files Browse the repository at this point in the history
* Dismiss picker on view disappearing
[ci skip]

* Update icon when dismissing by tapping anywhere

* fixed #124

* Disable usage of swipe to back when picker is open

* Use isUserInteractionEnabled

* Use interactivePopGestureRecognizer.isEnabled

* Fix picker arrow when dismissing somehow
  • Loading branch information
mammuth authored and nerdsupremacist committed May 11, 2017
1 parent dcd2224 commit 6219514
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion TUM Campus App/CafeteriaViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ extension CafeteriaViewController {
pickerView.show()
barItem?.action = #selector(CafeteriaViewController.hideCafeterias(_:))
barItem?.image = UIImage(named: "collapse")
navigationController?.interactivePopGestureRecognizer?.isEnabled = false

}

func hideCafeterias(_ send: AnyObject?) {
pickerView.dismiss()
barItem?.action = #selector(CafeteriaViewController.showCafeterias(_:))
barItem?.image = UIImage(named: "expand")
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}

func setUpPickerView() {
Expand All @@ -112,10 +115,11 @@ extension CafeteriaViewController {
items.append(item!)
}
pickerView = AYSlidingPickerView.sharedInstance()
pickerView.mainView = view
pickerView.mainView = navigationController?.view ?? view
pickerView.items = items
pickerView.selectedIndex = 0
pickerView.closeOnSelection = true
pickerView.didDismissHandler = { self.hideCafeterias(nil) }
barItem = UIBarButtonItem(image: UIImage(named: "expand"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(CafeteriaViewController.showCafeterias(_:)))
navigationItem.rightBarButtonItem = barItem
}
Expand Down
5 changes: 4 additions & 1 deletion TUM Campus App/MovieDetailTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ extension MovieDetailTableViewController {
pickerView.show()
barItem?.action = #selector(MovieDetailTableViewController.hideMovies(_:))
barItem?.image = UIImage(named: "collapse")
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}

func hideMovies(_ send: AnyObject?) {
pickerView.dismiss()
barItem?.action = #selector(MovieDetailTableViewController.showMovies(_:))
barItem?.image = UIImage(named: "expand")
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}

func setUpPickerView() {
Expand All @@ -105,10 +107,11 @@ extension MovieDetailTableViewController {
items.append(item!)
}
pickerView = AYSlidingPickerView.sharedInstance()
pickerView.mainView = view
pickerView.mainView = navigationController?.view ?? view
pickerView.items = items
pickerView.selectedIndex = 0
pickerView.closeOnSelection = true
pickerView.didDismissHandler = { self.hideMovies(nil) }
barItem = UIBarButtonItem(image: UIImage(named: "expand"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(MovieDetailTableViewController.showMovies(_:)))
navigationItem.rightBarButtonItem = barItem
}
Expand Down
5 changes: 4 additions & 1 deletion TUM Campus App/RoomFinderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ extension RoomFinderViewController {
pickerView.show()
barItem?.action = #selector(RoomFinderViewController.hideMaps(_:))
barItem?.image = UIImage(named: "collapse")
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}

func hideMaps(_ send: AnyObject?) {
pickerView.dismiss()
barItem?.action = #selector(RoomFinderViewController.showMaps(_:))
barItem?.image = UIImage(named: "expand")
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}

}
Expand Down Expand Up @@ -118,10 +120,11 @@ extension RoomFinderViewController {
items.append(item!)
}
pickerView = AYSlidingPickerView.sharedInstance()
pickerView.mainView = view
pickerView.mainView = navigationController?.view ?? view
pickerView.items = items
pickerView.selectedIndex = 0
pickerView.closeOnSelection = true
pickerView.didDismissHandler = { self.hideMaps(nil) }
barItem = UIBarButtonItem(image: UIImage(named: "expand"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(RoomFinderViewController.showMaps(_:)))
navigationItem.rightBarButtonItem = barItem
}
Expand Down
5 changes: 4 additions & 1 deletion TUM Campus App/StudyRoomsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ extension StudyRoomsTableViewController {
pickerView.show()
barItem?.action = #selector(StudyRoomsTableViewController.hideRooms(_:))
barItem?.image = UIImage(named: "collapse")
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}

func hideRooms(_ send: AnyObject?) {
pickerView.dismiss()
barItem?.action = #selector(StudyRoomsTableViewController.showRooms(_:))
barItem?.image = UIImage(named: "expand")
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}

func setUpPickerView() {
Expand All @@ -126,10 +128,11 @@ extension StudyRoomsTableViewController {
items.append(item!)
}
pickerView = AYSlidingPickerView.sharedInstance()
pickerView.mainView = view
pickerView.mainView = navigationController?.view ?? view
pickerView.items = items
pickerView.selectedIndex = 0
pickerView.closeOnSelection = true
pickerView.didDismissHandler = { self.hideRooms(nil) }
barItem = UIBarButtonItem(image: UIImage(named: "expand"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(StudyRoomsTableViewController.showRooms(_:)))
navigationItem.rightBarButtonItem = barItem
}
Expand Down
5 changes: 4 additions & 1 deletion TUM Campus App/TuitionTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ extension TuitionTableViewController {
}
pickerView = AYSlidingPickerView.sharedInstance()
pickerView.items = items
pickerView.mainView = view
pickerView.mainView = navigationController?.view ?? view
pickerView.selectedIndex = 0
pickerView.closeOnSelection = true
pickerView.didDismissHandler = { self.hideSemesters(nil) }
barItem = UIBarButtonItem(image: UIImage(named: "expand"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(TuitionTableViewController.showSemesters(_:)))
navigationItem.rightBarButtonItem = barItem
}
Expand All @@ -86,12 +87,14 @@ extension TuitionTableViewController {
pickerView.show()
barItem?.action = #selector(TuitionTableViewController.hideSemesters(_:))
barItem?.image = UIImage(named: "collapse")
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}

func hideSemesters(_ send: AnyObject?) {
pickerView.dismiss()
barItem?.action = #selector(TuitionTableViewController.showSemesters(_:))
barItem?.image = UIImage(named: "expand")
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}

}

0 comments on commit 6219514

Please sign in to comment.