IOS-1455 SegueHandler IOS-1455
authorXavier Algarra <xavier@pep-project.org>
Mon, 18 Feb 2019 12:51:16 +0100
branchIOS-1455
changeset 7694fe59863e6a62
parent 7693 807e5e635405
child 7695 543e7fe672fe
IOS-1455 SegueHandler
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/UI/Util/SegueHandlerType.swift
subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj/project.pbxproj
subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/SegueHandlerType.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Mon Feb 18 11:35:25 2019 +0100
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Mon Feb 18 12:51:16 2019 +0100
     1.3 @@ -542,6 +542,7 @@
     1.4  		B7DB7FC72215C57F003968DA /* UIView+Autolayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC52215C57F003968DA /* UIView+Autolayout.swift */; };
     1.5  		B7DB7FC82215C57F003968DA /* UIView+Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC62215C57F003968DA /* UIView+Util.swift */; };
     1.6  		B7DB7FCA2215D69C003968DA /* CredentialTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC92215D69C003968DA /* CredentialTextField.swift */; };
     1.7 +		B7DB7FD2221AD332003968DA /* SegueHandlerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FD1221AD332003968DA /* SegueHandlerType.swift */; };
     1.8  		B7F4A793212DDFC500507B76 /* EmailListViewModelTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7F4A792212DDFC500507B76 /* EmailListViewModelTest.swift */; };
     1.9  		F73E4F72217F238300CCFFED /* FolderSectionViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73E4F71217F238300CCFFED /* FolderSectionViewModelTests.swift */; };
    1.10  		F73E4F7A2180744700CCFFED /* FolderCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73E4F792180744700CCFFED /* FolderCellViewModelTests.swift */; };
    1.11 @@ -1151,13 +1152,13 @@
    1.12  		B78CF8241E76D706008C1739 /* FilterTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterTableViewController.swift; path = Filter/FilterTableViewController.swift; sourceTree = "<group>"; };
    1.13  		B78CF8281E76E0F1008C1739 /* FilterViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterViewModel.swift; path = Filter/ViewModel/FilterViewModel.swift; sourceTree = "<group>"; };
    1.14  		B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterCellViewModel.swift; path = Filter/ViewModel/FilterCellViewModel.swift; sourceTree = "<group>"; };
    1.15 -
    1.16  		B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CollapsibleTableViewHeader.swift; path = Folder/CollapsibleTableViewHeader.swift; sourceTree = "<group>"; };
    1.17  		B7DB7FB422148585003968DA /* SecretUITestData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretUITestData.swift; sourceTree = "<group>"; };
    1.18  		B7DB7FC32215C4FF003968DA /* UINavigationController+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extensions.swift"; sourceTree = "<group>"; };
    1.19  		B7DB7FC52215C57F003968DA /* UIView+Autolayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Autolayout.swift"; sourceTree = "<group>"; };
    1.20  		B7DB7FC62215C57F003968DA /* UIView+Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Util.swift"; sourceTree = "<group>"; };
    1.21  		B7DB7FC92215D69C003968DA /* CredentialTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CredentialTextField.swift; sourceTree = "<group>"; };
    1.22 +		B7DB7FD1221AD332003968DA /* SegueHandlerType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegueHandlerType.swift; sourceTree = "<group>"; };
    1.23  		B7F4A792212DDFC500507B76 /* EmailListViewModelTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailListViewModelTest.swift; sourceTree = "<group>"; };
    1.24  		F73E4F71217F238300CCFFED /* FolderSectionViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderSectionViewModelTests.swift; sourceTree = "<group>"; };
    1.25  		F73E4F792180744700CCFFED /* FolderCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderCellViewModelTests.swift; sourceTree = "<group>"; };
    1.26 @@ -2309,6 +2310,7 @@
    1.27  				15265973216234C0006A78DF /* SuggestTableViewController */,
    1.28  				150DF6D12052A99800A9DCF7 /* SecureWebViewController */,
    1.29  				43AAC2281F7A5AED00F435F4 /* BaseTableViewController.swift */,
    1.30 +				B7DB7FD1221AD332003968DA /* SegueHandlerType.swift */,
    1.31  				43AAC2291F7A5AEE00F435F4 /* BaseViewController.swift */,
    1.32  				43C322081EA90192005073FB /* PEP+UI.swift */,
    1.33  				4330278D1F7BABFF00D685F8 /* GradientView.swift */,
    1.34 @@ -3320,6 +3322,7 @@
    1.35  				152A39D421905C3E00D9F8E4 /* SubjectCell.swift in Sources */,
    1.36  				15F835241F34BE1300FCE887 /* AccountUserInput.swift in Sources */,
    1.37  				43122B191DF5B48B00610253 /* EmailService.swift in Sources */,
    1.38 +				B7DB7FD2221AD332003968DA /* SegueHandlerType.swift in Sources */,
    1.39  				0033C08320D7F41600224E61 /* ThreadedEmailViewModelDelegate.swift in Sources */,
    1.40  				43498CDD200D0790006DC947 /* LoginViewModelOAuth2ErrorDelegate.swift in Sources */,
    1.41  				152A39DF21905C3E00D9F8E4 /* WrappedBccViewModel.swift in Sources */,
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pEpForiOS/UI/Util/SegueHandlerType.swift	Mon Feb 18 12:51:16 2019 +0100
     2.3 @@ -0,0 +1,32 @@
     2.4 +//
     2.5 +//  SegueHandlerType.swift
     2.6 +//
     2.7 +//  Pattern for using segues via enumeration.
     2.8 +//  see: https://developer.apple.com/videos/wwdc/2015/?id=411
     2.9 +//
    2.10 +//  Created by Marko Tadic on 8/25/15.
    2.11 +//  Copyright © 2015 AE. All rights reserved.
    2.12 +//
    2.13 +
    2.14 +import UIKit
    2.15 +
    2.16 +public protocol SegueHandlerType {
    2.17 +    associatedtype SegueIdentifier: RawRepresentable
    2.18 +}
    2.19 +
    2.20 +public extension SegueHandlerType where Self: UIViewController, SegueIdentifier.RawValue == String {
    2.21 +    
    2.22 +    public func performSegue(withIdentifier identifier: SegueIdentifier, sender: Any?) {
    2.23 +        performSegue(withIdentifier: identifier.rawValue, sender: sender)
    2.24 +    }
    2.25 +    
    2.26 +    public func segueIdentifier(for segue: UIStoryboardSegue) -> SegueIdentifier {
    2.27 +        guard let
    2.28 +            identifier = segue.identifier,
    2.29 +            let segueIdentifier = SegueIdentifier(rawValue: identifier)
    2.30 +        else {
    2.31 +            return SegueIdentifier(rawValue: "noSegue")!
    2.32 +        }
    2.33 +        return segueIdentifier
    2.34 +    }
    2.35 +}
     3.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj/project.pbxproj	Mon Feb 18 11:35:25 2019 +0100
     3.2 +++ b/subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj/project.pbxproj	Mon Feb 18 12:51:16 2019 +0100
     3.3 @@ -13,7 +13,6 @@
     3.4  		B70A3A77220091D400EDCE61 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = B70A3A75220091D400EDCE61 /* Logger.swift */; };
     3.5  		B7465DBE22119D3A008A1708 /* Thread+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DBD22119D39008A1708 /* Thread+Extension.swift */; };
     3.6  		B7465DC622119EB1008A1708 /* Array+SortingAndSearching.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DC522119EB1008A1708 /* Array+SortingAndSearching.swift */; };
     3.7 -		B7465DC82211A062008A1708 /* SegueHandlerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DC72211A062008A1708 /* SegueHandlerType.swift */; };
     3.8  		B7465DCC2211BEEA008A1708 /* Tuple.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DCB2211BEE9008A1708 /* Tuple.swift */; };
     3.9  		B7465DDF2211C6C8008A1708 /* UIBarButtonItem+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DDE2211C6C8008A1708 /* UIBarButtonItem+Extension.swift */; };
    3.10  		B7465DE12211C6E9008A1708 /* UIImage+GIF.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DE02211C6E9008A1708 /* UIImage+GIF.swift */; };
    3.11 @@ -60,7 +59,6 @@
    3.12  		B70A3A75220091D400EDCE61 /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
    3.13  		B7465DBD22119D39008A1708 /* Thread+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Thread+Extension.swift"; sourceTree = "<group>"; };
    3.14  		B7465DC522119EB1008A1708 /* Array+SortingAndSearching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+SortingAndSearching.swift"; sourceTree = "<group>"; };
    3.15 -		B7465DC72211A062008A1708 /* SegueHandlerType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegueHandlerType.swift; sourceTree = "<group>"; };
    3.16  		B7465DCB2211BEE9008A1708 /* Tuple.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tuple.swift; sourceTree = "<group>"; };
    3.17  		B7465DDE2211C6C8008A1708 /* UIBarButtonItem+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Extension.swift"; sourceTree = "<group>"; };
    3.18  		B7465DE02211C6E9008A1708 /* UIImage+GIF.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+GIF.swift"; sourceTree = "<group>"; };
    3.19 @@ -147,7 +145,6 @@
    3.20  				B7911EC921F88D1900D7F66F /* UITableView+Extension.swift */,
    3.21  				B7911EC721F88D0200D7F66F /* UITextField+Extension.swift */,
    3.22  				B7911EC521F88AF800D7F66F /* UIImage+Extension.swift */,
    3.23 -				B7465DC72211A062008A1708 /* SegueHandlerType.swift */,
    3.24  				B7465DDE2211C6C8008A1708 /* UIBarButtonItem+Extension.swift */,
    3.25  				B7465DE02211C6E9008A1708 /* UIImage+GIF.swift */,
    3.26  				B7465DE42211E08A008A1708 /* UIImageView+Extension.swift */,
    3.27 @@ -337,7 +334,6 @@
    3.28  				B7465DBE22119D3A008A1708 /* Thread+Extension.swift in Sources */,
    3.29  				B7DB7F5022130DE9003968DA /* Weak.swift in Sources */,
    3.30  				B7A46C52220C732E0027CCB5 /* Data+Extensions.swift in Sources */,
    3.31 -				B7465DC82211A062008A1708 /* SegueHandlerType.swift in Sources */,
    3.32  				B7465DE32211C890008A1708 /* CGImageSource+Extension.swift in Sources */,
    3.33  				B7465DE12211C6E9008A1708 /* UIImage+GIF.swift in Sources */,
    3.34  				B70A3A5522005BD400EDCE61 /* Date+Extension.swift in Sources */,
     4.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/SegueHandlerType.swift	Mon Feb 18 11:35:25 2019 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,32 +0,0 @@
     4.4 -//
     4.5 -//  SegueHandlerType.swift
     4.6 -//
     4.7 -//  Pattern for using segues via enumeration.
     4.8 -//  see: https://developer.apple.com/videos/wwdc/2015/?id=411
     4.9 -//
    4.10 -//  Created by Marko Tadic on 8/25/15.
    4.11 -//  Copyright © 2015 AE. All rights reserved.
    4.12 -//
    4.13 -
    4.14 -import UIKit
    4.15 -
    4.16 -public protocol SegueHandlerType {
    4.17 -    associatedtype SegueIdentifier: RawRepresentable
    4.18 -}
    4.19 -
    4.20 -public extension SegueHandlerType where Self: UIViewController, SegueIdentifier.RawValue == String {
    4.21 -    
    4.22 -    public func performSegue(withIdentifier identifier: SegueIdentifier, sender: Any?) {
    4.23 -        performSegue(withIdentifier: identifier.rawValue, sender: sender)
    4.24 -    }
    4.25 -    
    4.26 -    public func segueIdentifier(for segue: UIStoryboardSegue) -> SegueIdentifier {
    4.27 -        guard let
    4.28 -            identifier = segue.identifier,
    4.29 -            let segueIdentifier = SegueIdentifier(rawValue: identifier)
    4.30 -        else {
    4.31 -            return SegueIdentifier(rawValue: "noSegue")!
    4.32 -        }
    4.33 -        return segueIdentifier
    4.34 -    }
    4.35 -}