legacy navigation logic
This commit is contained in:
parent
335ec160b5
commit
2d3eb3351b
@ -33,6 +33,26 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
|||||||
|
|
||||||
public var selectedField: UIView?
|
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
|
/// Checks if the screen width has changed
|
||||||
open func screenSizeChanged() -> Bool {
|
open func screenSizeChanged() -> Bool {
|
||||||
return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
||||||
@ -105,7 +125,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
|||||||
pageType = loadObject.pageType
|
pageType = loadObject.pageType
|
||||||
self.loadObject = loadObject
|
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 }
|
guard MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) else { return false }
|
||||||
|
|
||||||
// Parse the model for the page.
|
// Parse the model for the page.
|
||||||
@ -146,11 +166,6 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
|||||||
return true
|
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
|
/// Calls processNewData and then sets the ui to update with updateView
|
||||||
open func handleNewDataAndUpdateUI() {
|
open func handleNewDataAndUpdateUI() {
|
||||||
handleNewData()
|
handleNewData()
|
||||||
@ -161,10 +176,101 @@ 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,
|
/// Processes any new data. Called after the page is loaded the first time and on response updates for this page,
|
||||||
open func handleNewData() {
|
open func handleNewData() {
|
||||||
// TODO atomize the navigation item
|
// TODO atomize the navigation item
|
||||||
set(navigationItem: navigationItem)
|
set(navigationController: navigationController)
|
||||||
formValidator?.validate()
|
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
|
// MARK: - View lifecycle
|
||||||
open func initialLoad() {
|
open func initialLoad() {
|
||||||
observeForResponseJSONUpdates()
|
observeForResponseJSONUpdates()
|
||||||
@ -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.
|
// Update the navigation bar ui when view is appearing unless in a manager. The manager is expected to handle.
|
||||||
if manager == nil {
|
if manager == nil {
|
||||||
set(navigationItem: navigationItem)
|
set(navigationController: navigationController)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +356,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
|||||||
// MARK: - MVMCoreViewManagerViewControllerProtocol
|
// MARK: - MVMCoreViewManagerViewControllerProtocol
|
||||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
||||||
if initialLoadFinished {
|
if initialLoadFinished {
|
||||||
set(navigationItem: manager.navigationItem)
|
set(navigationController: manager.navigationController)
|
||||||
}
|
}
|
||||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||||
@ -285,13 +391,10 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC
|
|||||||
|
|
||||||
// Test to see if needed.
|
// Test to see if needed.
|
||||||
open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
||||||
|
|
||||||
}
|
}
|
||||||
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
|
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
|
||||||
|
|
||||||
}
|
}
|
||||||
open func removeMolecules(_ 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)
|
// MARK: - UITextFieldDelegate (Check if this is still needed)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user