Skip to content

Commit

Permalink
Merge pull request #37 from uw-it-aca/bug/MUWM-4718
Browse files Browse the repository at this point in the history
Bug/muwm 4718
  • Loading branch information
abztrakt committed Jul 21, 2020
2 parents 83938b5 + a7a12d4 commit 0f3f2a1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
33 changes: 21 additions & 12 deletions myuw-ios/ApplicationController.swift
Expand Up @@ -17,7 +17,8 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN
let tabAcademics = UINavigationController(rootViewController: AcademicsWebView())
let tabHuskyExp = UINavigationController(rootViewController: HuskyExpWebView())
let tabTeaching = UINavigationController(rootViewController: TeachingWebView())
var tabAccounts = UINavigationController(rootViewController: AccountsWebView())
let tabAccounts = UINavigationController(rootViewController: AccountsWebView())
let tabProfile = UINavigationController(rootViewController: ProfileWebView())
let tabNotices = UINavigationController(rootViewController: NoticesWebView())
let tabCalendar = UINavigationController(rootViewController: CalendarWebView())
let tabResources = UINavigationController(rootViewController: ResourcesWebView())
Expand Down Expand Up @@ -65,6 +66,10 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN
let tabAccountsBarItem = UITabBarItem(title: "Accounts", image: UIImage(named: "ic_accounts"), selectedImage: UIImage(named: "selectedImage2.png"))
tabAccounts.tabBarItem = tabAccountsBarItem

// Profile tab
let tabProfileBarItem = UITabBarItem(title: "Profile", image: UIImage(named: "ic_person"), selectedImage: UIImage(named: "selectedImage2.png"))
tabProfile.tabBarItem = tabProfileBarItem

// Notices tab
let tabNoticesBarItem = UITabBarItem(title: "Notices", image: UIImage(named: "ic_warning"), selectedImage: UIImage(named: "selectedImage2.png"))
tabNotices.tabBarItem = tabNoticesBarItem
Expand All @@ -85,27 +90,26 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN

// remove the more "edit" button
self.moreNavigationController.tabBarController?.customizableViewControllers = []
self.moreNavigationController.navigationBar.topItem?.rightBarButtonItem = nil
self.moreNavigationController.tabBarController?.customizableViewControllers?.removeAll()

// MARK: - Tab View Controllers

// build bottom tab navigation based on user affiliations
var controllers = [tabHome, tabAccounts, tabCalendar, tabResources]
var controllers = [tabHome, tabAccounts, tabProfile, tabCalendar, tabResources]

// insert academics tab for students or applicant
if User.userAffiliations.contains("student") || User.userAffiliations.contains("applicant") {
controllers.insert(tabAcademics, at: 1)
}

// insert teaching tab for instructor
if User.userAffiliations.contains("instructor") {
controllers.insert(tabTeaching, at: 1)
}

// insert husky exp tab for seattle undergrad
if (User.userAffiliations.contains("undergrad") && User.userAffiliations.contains("seattle")) || User.userAffiliations.contains("hxt_viewer") {
controllers.insert(tabHuskyExp, at: 2)
controllers.insert(tabHuskyExp, at: 1)
}

// insert teaching tab for instructor
if User.userAffiliations.contains("instructor") {
controllers.insert(tabTeaching, at: 2)
}

// insert notices tab for student
Expand All @@ -126,7 +130,6 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN
if self.selectedViewController == moreNavigationController {
// remove the more "edit" button
self.moreNavigationController.tabBarController?.customizableViewControllers = []
self.moreNavigationController.navigationBar.topItem?.rightBarButtonItem = nil
self.moreNavigationController.tabBarController?.customizableViewControllers?.removeAll()
}

Expand All @@ -150,7 +153,6 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN

// remove the more "edit" button
self.moreNavigationController.tabBarController?.customizableViewControllers = []
self.moreNavigationController.navigationBar.topItem?.rightBarButtonItem = nil
self.moreNavigationController.tabBarController?.customizableViewControllers?.removeAll()

let selectedVC = self.selectedViewController
Expand All @@ -171,6 +173,9 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN
case tabAccounts:
os_log("Clicked tabAccounts, index: %d", log: .app, type: .info, selectedIndex)
UserDefaults.standard.set(selectedIndex, forKey: "lastTabIndex")
case tabProfile:
os_log("Clicked tabProfile, index: %d", log: .app, type: .info, selectedIndex)
UserDefaults.standard.set(selectedIndex, forKey: "lastTabIndex")
case tabNotices:
os_log("Clicked tabNotices, index: %d", log: .app, type: .info, selectedIndex)
UserDefaults.standard.set(selectedIndex, forKey: "lastTabIndex")
Expand All @@ -192,7 +197,6 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN

// remove the more "edit" button
self.moreNavigationController.tabBarController?.customizableViewControllers = []
self.moreNavigationController.navigationBar.topItem?.rightBarButtonItem = nil
self.moreNavigationController.tabBarController?.customizableViewControllers?.removeAll()

let selectedVC = self.selectedViewController
Expand All @@ -203,6 +207,11 @@ class ApplicationController: UITabBarController, UITabBarControllerDelegate, UIN
case tabNotices:
os_log("Clicked tabNotices, index: %d", log: .app, type: .info, selectedIndex)
UserDefaults.standard.set(selectedIndex, forKey: "lastTabIndex")
prevIndex = selectedIndex
case tabProfile:
os_log("Clicked tabProfile, index: %d", log: .app, type: .info, selectedIndex)
UserDefaults.standard.set(selectedIndex, forKey: "lastTabIndex")
prevIndex = selectedIndex
case tabCalendar:
os_log("Clicked tabCalendar, index: %d", log: .app, type: .info, selectedIndex)
UserDefaults.standard.set(selectedIndex, forKey: "lastTabIndex")
Expand Down
19 changes: 6 additions & 13 deletions myuw-ios/HomeWebView.swift
Expand Up @@ -54,20 +54,13 @@ class HomeWebView: WebViewController {
}

@objc func showProfile() {

let profileWebView = UINavigationController(rootViewController: ProfileWebView())

// set style of how view controller is to be presented
if #available(iOS 13.0, *) {
profileWebView.modalPresentationStyle = .automatic
} else {
// fallback on earlier versions
profileWebView.modalPresentationStyle = .formSheet
}

// present the profile view controller
present(profileWebView, animated: true, completion: nil)

// programatically click on a tab

if let tabbarController = UIApplication.shared.delegate?.window!?.rootViewController as? ApplicationController {
//tabbarController.selectedIndex = 3
tabbarController.selectedViewController = tabbarController.tabProfile
}
}

@objc func showSearch() {
Expand Down
13 changes: 3 additions & 10 deletions myuw-ios/ProfileWebView.swift
Expand Up @@ -21,9 +21,6 @@ class ProfileWebView: WebViewController {
// override navigation title
self.navigationItem.title = "Profile"

// add a right button in navbar programatically
let closeButton = UIBarButtonItem(title: "Close", style: .plain, target: self, action: #selector(dismissProfile))

// define custom email button
let signOutButton = UIButton(type: .system)
signOutButton.setImage(UIImage(named: "ic_signout_18"), for: .normal)
Expand All @@ -36,13 +33,9 @@ class ProfileWebView: WebViewController {

let signOutButtonItem = UIBarButtonItem(customView: signOutButton)

self.navigationItem.leftBarButtonItem = signOutButtonItem
self.navigationItem.rightBarButtonItem = closeButton
//self.navigationItem.leftBarButtonItem = signOutButtonItem
self.navigationItem.rightBarButtonItem = signOutButtonItem

}

@objc private func dismissProfile(){
self.dismiss(animated: true, completion: nil)
}


}

0 comments on commit 0f3f2a1

Please sign in to comment.