legacy navigation logic
This commit is contained in:
parent
335ec160b5
commit
2d3eb3351b
@ -32,6 +32,26 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
private var previousScreenSize = CGSize.zero
|
||||
|
||||
public var selectedField: UIView?
|
||||
|
||||
public var masterShouldBeAccessible: Bool = false {
|
||||
didSet {
|
||||
if let manager = manager as? MFViewController {
|
||||
manager.masterShouldBeAccessible = masterShouldBeAccessible
|
||||
} else if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self {
|
||||
MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(masterShouldBeAccessible, for: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var supportShouldBeAccessible: Bool = false {
|
||||
didSet {
|
||||
if let manager = manager as? MFViewController {
|
||||
manager.supportShouldBeAccessible = supportShouldBeAccessible
|
||||
} else if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self {
|
||||
MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(supportShouldBeAccessible, for: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the screen width has changed
|
||||
open func screenSizeChanged() -> Bool {
|
||||
@ -105,7 +125,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
pageType = loadObject.pageType
|
||||
self.loadObject = loadObject
|
||||
|
||||
// Verifies all modules needed are loaded.
|
||||
// Verifies all modules needed are loaded. TODO: change to ViewController
|
||||
guard MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) else { return false }
|
||||
|
||||
// Parse the model for the page.
|
||||
@ -146,11 +166,6 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
return true
|
||||
}
|
||||
|
||||
open func set(navigationItem: UINavigationItem) {
|
||||
navigationItem.title = pageModel?.screenHeading
|
||||
navigationItem.accessibilityLabel = pageModel?.screenHeading
|
||||
}
|
||||
|
||||
/// Calls processNewData and then sets the ui to update with updateView
|
||||
open func handleNewDataAndUpdateUI() {
|
||||
handleNewData()
|
||||
@ -161,9 +176,100 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
/// Processes any new data. Called after the page is loaded the first time and on response updates for this page,
|
||||
open func handleNewData() {
|
||||
// TODO atomize the navigation item
|
||||
set(navigationItem: navigationItem)
|
||||
set(navigationController: navigationController)
|
||||
formValidator?.validate()
|
||||
}
|
||||
|
||||
// MARK: - Navigation Item (Move to model base)
|
||||
open func set(navigationController: UINavigationController?) {
|
||||
navigationItem.title = pageModel?.screenHeading
|
||||
navigationItem.accessibilityLabel = pageModel?.screenHeading
|
||||
guard let navigationController = navigationController else {
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate()
|
||||
return
|
||||
}
|
||||
navigationController.setNavigationBarHidden(isNavigationBarHidden(), animated: true)
|
||||
UIColor.setBackgroundColor(forNavigationBar: navigationBarColor(), navigationBar: navigationController.navigationBar, transparent: navigationBarTransparent())
|
||||
|
||||
let tint = navigationBarTintColor() ?? .black
|
||||
navigationController.navigationBar.tintColor = tint
|
||||
|
||||
// Have the navigation title match the tint color
|
||||
navigationController.navigationBar.titleTextAttributes?.updateValue(navigationBarTintColor, forKey: .foregroundColor)
|
||||
|
||||
if navigationController == MVMCoreUISplitViewController.main()?.navigationController {
|
||||
// Update icons if main navigation controller.
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels()
|
||||
let master = masterShouldBeAccessible
|
||||
masterShouldBeAccessible = master
|
||||
let support = supportShouldBeAccessible
|
||||
supportShouldBeAccessible = support
|
||||
|
||||
showBottomProgressBar()
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint)
|
||||
|
||||
// Update separator.
|
||||
MVMCoreUISession.sharedGlobal()?.navigationController?.separatorView?.isHidden = /*self is MVMCoreUITabBarPageControlViewController ||*/ manager != nil || loadObject?.requestParameters?.tabWasPressed ?? false == true
|
||||
}
|
||||
}
|
||||
|
||||
open func navigationBarColor() -> UIColor {
|
||||
return .white
|
||||
}
|
||||
|
||||
open func isNavigationBarHidden() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
open func navigationBarTransparent() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
open func navigationBarTintColor() -> UIColor? {
|
||||
return nil
|
||||
}
|
||||
|
||||
open func isMasterInitiallyAccessible() -> Bool {
|
||||
if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false {
|
||||
return false
|
||||
}
|
||||
return MVMCoreUISession.sharedGlobal()?.launchAppLoadedSuccessfully ?? false
|
||||
}
|
||||
|
||||
open func isSupportInitiallyAccessible() -> Bool {
|
||||
if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false {
|
||||
return false
|
||||
}
|
||||
return (MVMCoreUISession.sharedGlobal()?.launchAppLoadedSuccessfully ?? false) || showRightPanelForScreenBeforeLaunchApp()
|
||||
}
|
||||
|
||||
open func showRightPanelForScreenBeforeLaunchApp() -> Bool {
|
||||
return loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
||||
}
|
||||
|
||||
open func isOverridingRightButton() -> Bool {
|
||||
guard let rightPanelLink = loadObject?.pageJSON?.optionalDictionaryForKey("rightPanelButtonLink") else {
|
||||
return false
|
||||
}
|
||||
MVMCoreActionHandler.shared()?.handleAction(with: rightPanelLink, additionalData: nil, delegateObject: delegateObject())
|
||||
return true
|
||||
}
|
||||
|
||||
open func isOverridingLeftButton() -> Bool {
|
||||
guard let leftPanelLink = loadObject?.pageJSON?.optionalDictionaryForKey("leftPanelButtonLink") else {
|
||||
return false
|
||||
}
|
||||
MVMCoreActionHandler.shared()?.handleAction(with: leftPanelLink, additionalData: nil, delegateObject: delegateObject())
|
||||
return true
|
||||
}
|
||||
|
||||
open func showBottomProgressBar() {
|
||||
if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self,
|
||||
let progressString = loadObject?.pageJSON?.optionalStringForKey(KeyProgressPercent),
|
||||
let progress = Float(progressString) {
|
||||
MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(progress / Float(100))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - View lifecycle
|
||||
open func initialLoad() {
|
||||
@ -215,7 +321,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
|
||||
// Update the navigation bar ui when view is appearing unless in a manager. The manager is expected to handle.
|
||||
if manager == nil {
|
||||
set(navigationItem: navigationItem)
|
||||
set(navigationController: navigationController)
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +356,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
// MARK: - MVMCoreViewManagerViewControllerProtocol
|
||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
||||
if initialLoadFinished {
|
||||
set(navigationItem: manager.navigationItem)
|
||||
set(navigationController: manager.navigationController)
|
||||
}
|
||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||
@ -285,13 +391,10 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
||||
|
||||
// Test to see if needed.
|
||||
open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
||||
|
||||
}
|
||||
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
|
||||
|
||||
}
|
||||
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UITextFieldDelegate (Check if this is still needed)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user