IOS-2008 improves IOS-2008
authorXavier Algarra <xavier@pep-project.org>
Mon, 02 Mar 2020 03:05:06 +0100
branchIOS-2008
changeset 120115666af38c256
parent 12010 f0d5f115b6a4
child 12012 6c4b831d0b3c
IOS-2008 improves
pEpForiOS/UI/EmailDisplay/EmailDetailView/EmailDetailViewController.swift
pEpForiOS/UI/Settings/Setting/AccountSettings/AccountSettingsTableViewController.swift
pEpForiOS/UI/Settings/Setting/ExtraKeysSetting/ExtraKeysSettingViewController.swift
pEpForiOS/UI/Settings/Setting/SetOwnKey/SetOwnKeyViewController.swift
pEpForiOS/UI/Settings/Setting/SettingDefaultAccountTableViewController.swift
pEpForiOS/UI/Settings/Setting/TrustSetting/ResetTrustViewController.swift
pEpForiOS/UI/Settings/Setting/TrustedServerSetting/TrustedServerSettingsViewController.swift
pEpForiOS/UI/SplitView/PrimarySplitViewController.swift
pEpForiOS/UI/SplitView/SplitViewHandlingProtocol.swift
pEpForiOS/UI/Util/Extensions/UIViewController/UIViewController+Extension.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailDetailView/EmailDetailViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailDetailView/EmailDetailViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     1.3 @@ -43,13 +43,13 @@
     1.4      /// IndexPath to show on load
     1.5      var firstItemToShow: IndexPath?
     1.6      
     1.7 -    override var collapsedBehavior: CollapsedBehavior {
     1.8 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
     1.9          get {
    1.10              return .needed
    1.11          }
    1.12      }
    1.13      
    1.14 -    override var separatedBehavior: SeparatedBehavior {
    1.15 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    1.16          get {
    1.17              return .detail
    1.18          }
     2.1 --- a/pEpForiOS/UI/Settings/Setting/AccountSettings/AccountSettingsTableViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     2.2 +++ b/pEpForiOS/UI/Settings/Setting/AccountSettings/AccountSettingsTableViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     2.3 @@ -47,13 +47,13 @@
     2.4      var oauth2ReauthIndexPath: IndexPath?
     2.5      var viewModel: AccountSettingsViewModel? = nil
     2.6  
     2.7 -    override var collapsedBehavior: CollapsedBehavior {
     2.8 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
     2.9          get {
    2.10              return .needed
    2.11          }
    2.12      }
    2.13      
    2.14 -    override var separatedBehavior: SeparatedBehavior {
    2.15 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    2.16          get {
    2.17              return .detail
    2.18          }
     3.1 --- a/pEpForiOS/UI/Settings/Setting/ExtraKeysSetting/ExtraKeysSettingViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     3.2 +++ b/pEpForiOS/UI/Settings/Setting/ExtraKeysSetting/ExtraKeysSettingViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     3.3 @@ -16,13 +16,13 @@
     3.4  
     3.5      private var viewModel: ExtraKeysSettingViewModel?
     3.6  
     3.7 -    override var collapsedBehavior: CollapsedBehavior {
     3.8 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
     3.9          get {
    3.10              return .needed
    3.11          }
    3.12      }
    3.13      
    3.14 -    override var separatedBehavior: SeparatedBehavior {
    3.15 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    3.16          get {
    3.17              return .detail
    3.18          }
     4.1 --- a/pEpForiOS/UI/Settings/Setting/SetOwnKey/SetOwnKeyViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     4.2 +++ b/pEpForiOS/UI/Settings/Setting/SetOwnKey/SetOwnKeyViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     4.3 @@ -13,14 +13,15 @@
     4.4      @IBOutlet weak var emailTextField: UITextField!
     4.5      @IBOutlet weak var errorTextField: UILabel!
     4.6      @IBOutlet weak var setOwnKeyButton: UIButton!
     4.7 +    
     4.8  
     4.9 -    override var collapsedBehavior: CollapsedBehavior {
    4.10 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
    4.11          get {
    4.12              return .needed
    4.13          }
    4.14      }
    4.15      
    4.16 -    override var separatedBehavior: SeparatedBehavior{
    4.17 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    4.18          get {
    4.19              return .detail
    4.20          }
     5.1 --- a/pEpForiOS/UI/Settings/Setting/SettingDefaultAccountTableViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     5.2 +++ b/pEpForiOS/UI/Settings/Setting/SettingDefaultAccountTableViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     5.3 @@ -25,13 +25,13 @@
     5.4          title = NSLocalizedString("Default Account", comment: "Default account view title")
     5.5      }
     5.6  
     5.7 -    override var collapsedBehavior: CollapsedBehavior {
     5.8 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
     5.9          get {
    5.10              return .needed
    5.11          }
    5.12      }
    5.13      
    5.14 -    override var separatedBehavior: SeparatedBehavior {
    5.15 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    5.16          get {
    5.17              return .detail
    5.18          }
     6.1 --- a/pEpForiOS/UI/Settings/Setting/TrustSetting/ResetTrustViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     6.2 +++ b/pEpForiOS/UI/Settings/Setting/TrustSetting/ResetTrustViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     6.3 @@ -17,13 +17,13 @@
     6.4  
     6.5      private let searchController = UISearchController(searchResultsController: nil)
     6.6  
     6.7 -    override var collapsedBehavior: CollapsedBehavior {
     6.8 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
     6.9          get {
    6.10              return .needed
    6.11          }
    6.12      }
    6.13      
    6.14 -    override var separatedBehavior: SeparatedBehavior {
    6.15 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    6.16          get {
    6.17              return .detail
    6.18          }
     7.1 --- a/pEpForiOS/UI/Settings/Setting/TrustedServerSetting/TrustedServerSettingsViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     7.2 +++ b/pEpForiOS/UI/Settings/Setting/TrustedServerSetting/TrustedServerSettingsViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     7.3 @@ -12,13 +12,13 @@
     7.4  class TrustedServerSettingsViewController: BaseTableViewController {
     7.5      var viewModel = TrustedServerSettingsViewModel()
     7.6      
     7.7 -    override var collapsedBehavior: CollapsedBehavior {
     7.8 +    override var collapsedBehavior: CollapsedSplitViewBehavior {
     7.9          get {
    7.10              return .needed
    7.11          }
    7.12      }
    7.13      
    7.14 -    override var separatedBehavior: SeparatedBehavior {
    7.15 +    override var separatedBehavior: SeparatedSplitViewBehavior {
    7.16          get {
    7.17              return .detail
    7.18          }
     8.1 --- a/pEpForiOS/UI/SplitView/PrimarySplitViewController.swift	Mon Mar 02 02:48:09 2020 +0100
     8.2 +++ b/pEpForiOS/UI/SplitView/PrimarySplitViewController.swift	Mon Mar 02 03:05:06 2020 +0100
     8.3 @@ -23,7 +23,6 @@
     8.4          if let navigationController = secondaryViewController as? UINavigationController,
     8.5              let top = navigationController.topViewController, top.collapsedBehavior == .needed,
     8.6              let primaryNavigationController = primaryViewController as? UINavigationController {
     8.7 -            
     8.8              navigationController.popViewController(animated: false)
     8.9              primaryNavigationController.pushViewController(top, animated: false)
    8.10              if let vc = top as? SplitViewHandlingProtocol {
     9.1 --- a/pEpForiOS/UI/SplitView/SplitViewHandlingProtocol.swift	Mon Mar 02 02:48:09 2020 +0100
     9.2 +++ b/pEpForiOS/UI/SplitView/SplitViewHandlingProtocol.swift	Mon Mar 02 03:05:06 2020 +0100
     9.3 @@ -8,16 +8,36 @@
     9.4  
     9.5  import Foundation
     9.6  
     9.7 -/// Protocol that split View will use to communicate when something will hapen
     9.8 +/// Protocol that split View will use to communicate when something will happen
     9.9  protocol SplitViewHandlingProtocol {
    9.10      /// method called when the split view will change the display status
    9.11 -    /// - Parameter newStatus: the new status
    9.12 +    /// - Parameter newStatus: the new status 
    9.13      /// - Parameter SplitViewController: the splitview itself
    9.14      func splitViewControllerWill(SplitViewController: PEPSplitViewController, newStatus: SplitViewStatus)
    9.15  }
    9.16  
    9.17 +@objc protocol SplitViewControllerBehaviorProtocol {
    9.18 +    /// Attribute that can be overwritten with the default behaviour of the splitview when  this will collapse
    9.19 +    var collapsedBehavior: CollapsedSplitViewBehavior { get }
    9.20 +    
    9.21 +    /// Attribute that can be overwritten with the default behaviour of the splitview when this will separate
    9.22 +    var separatedBehavior: SeparatedSplitViewBehavior { get }
    9.23 +}
    9.24 +
    9.25  /// enum that will be used by splitViewHandling to communicate the dufferent status
    9.26  public enum SplitViewStatus {
    9.27      case collapse
    9.28      case separate
    9.29  }
    9.30 +
    9.31 +/// Options availabe when the splitView will collapse
    9.32 +@objc public enum CollapsedSplitViewBehavior: Int {
    9.33 +    case disposable = 0
    9.34 +    case needed = 1
    9.35 +}
    9.36 +
    9.37 +/// Options availabe when the splitView will separate
    9.38 +@objc public enum SeparatedSplitViewBehavior: Int {
    9.39 +    case master = 0
    9.40 +    case detail = 1
    9.41 +}
    10.1 --- a/pEpForiOS/UI/Util/Extensions/UIViewController/UIViewController+Extension.swift	Mon Mar 02 02:48:09 2020 +0100
    10.2 +++ b/pEpForiOS/UI/Util/Extensions/UIViewController/UIViewController+Extension.swift	Mon Mar 02 03:05:06 2020 +0100
    10.3 @@ -115,28 +115,15 @@
    10.4      func showNavigationBar() {
    10.5              navigationController?.setNavigationBarHidden(false, animated: false)
    10.6      }
    10.7 -    
    10.8 -    /// attribute that can be overwritten with the default behaviour of the splitview when will collapse
    10.9 -    @objc public var collapsedBehavior: CollapsedBehavior {
   10.10 -        get {
   10.11 -            return .disposable
   10.12 -        }
   10.13 +}
   10.14 +
   10.15 +// MARK: - SplitViewControllerBehaviorProtocol
   10.16 +extension UIViewController: SplitViewControllerBehaviorProtocol {
   10.17 +    var collapsedBehavior: CollapsedSplitViewBehavior {
   10.18 +        return .disposable
   10.19      }
   10.20      
   10.21 -    /// attribute that can be overwritten with the default behaviour of the splitview when will separate
   10.22 -    @objc public var separatedBehavior: SeparatedBehavior {
   10.23 -        get {
   10.24 -            return .master
   10.25 -        }
   10.26 +    var separatedBehavior: SeparatedSplitViewBehavior {
   10.27 +        return .master
   10.28      }
   10.29  }
   10.30 -
   10.31 -@objc public enum CollapsedBehavior: Int {
   10.32 -    case disposable = 0
   10.33 -    case needed = 1
   10.34 -}
   10.35 -
   10.36 -@objc public enum SeparatedBehavior: Int {
   10.37 -    case master = 0
   10.38 -    case detail = 1
   10.39 -}