Skip to content

Instantly share code, notes, and snippets.

@uknowmeright
Last active January 7, 2019 21:53
Show Gist options
  • Save uknowmeright/c50602efd8179f3edc9a46ca70155bef to your computer and use it in GitHub Desktop.
Save uknowmeright/c50602efd8179f3edc9a46ca70155bef to your computer and use it in GitHub Desktop.
navigation class #tags: navigation, IOS, Swift, Class
//
// AppNavigation.swift
//
// Created by Paul Lehn on 12/20/17.
// Copyright © 2017 Paul Lehn. All rights reserved.
//
import Foundation
import Firebase
import SideMenu
class AppNavigation{
class func showForgotPassword(_ sourceViewController: UIViewController){
let storyboard = UIStoryboard(name: "SignUp", bundle: nil)
let theViewController = storyboard.instantiateViewController(withIdentifier: "ForgotPasswordViewController") as? ForgotPasswordViewController
sourceViewController.present(theViewController!, animated: true, completion: nil)
}
class func showSignUpEmail(_ email: String? = nil, _ facebookDict: Dictionary<String, Any>? = nil){
let storyboard = UIStoryboard(name: "SignUp", bundle: nil)
let theViewController = storyboard.instantiateViewController(withIdentifier: "SignUpEmailViewController") as? SignUpEmailViewController
if email != nil{
//theViewController?.email = email
}
theViewController?.facebookDict = facebookDict
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = theViewController!
}
class func showEditGoal(sourceViewController : UIViewController, goal: Goal, _ delegate: EditGoalDelegate? = nil){
let storyboard = UIStoryboard(name: "Goals", bundle: nil)
let popoverContent = storyboard.instantiateViewController(withIdentifier: "EditGoalViewController") as! EditGoalViewController
popoverContent.theEditGoalDelegate = delegate
popoverContent.theGoal = goal
let nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.popover
let popover = nav.popoverPresentationController
popoverContent.preferredContentSize = CGSize(width: UIScreen.main.bounds.width * 0.9, height: UIScreen.main.bounds.height * 0.9)
popover?.delegate = sourceViewController as? UIPopoverPresentationControllerDelegate
popover?.sourceView = sourceViewController.view
popover?.sourceRect = CGRect(x: UIScreen.main.bounds.width * 0.5, y: 0, width: 0, height: 0)
sourceViewController.present(nav, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment