Merge pull request #29 from TouchInstinct/feature/storyboards_view_controllers_instantiation
organize storyboard and view controller instantiation
This commit is contained in:
commit
6acbaa441c
|
|
@ -11,12 +11,15 @@
|
|||
78011AB31D48B53600EA16A2 /* ApiRequestParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78011AB21D48B53600EA16A2 /* ApiRequestParameters.swift */; };
|
||||
780D23431DA412470084620D /* CGImage+Alpha.swift in Sources */ = {isa = PBXBuildFile; fileRef = 780D23421DA412470084620D /* CGImage+Alpha.swift */; };
|
||||
780D23461DA416F80084620D /* CGContext+Initializers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 780D23451DA416F80084620D /* CGContext+Initializers.swift */; };
|
||||
7834236A1DB8D0E100A79643 /* StoryboardProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 783423691DB8D0E100A79643 /* StoryboardProtocol.swift */; };
|
||||
783423701DB8D15800A79643 /* StoryboardProtocol+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7834236F1DB8D15800A79643 /* StoryboardProtocol+Extensions.swift */; };
|
||||
7837F60F1CBCF5C0000D74C1 /* EstimatedViewHeightProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7837F60E1CBCF5C0000D74C1 /* EstimatedViewHeightProtocol.swift */; };
|
||||
786D78E81D53C378006B2CEA /* AlamofireRequest+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 786D78E71D53C378006B2CEA /* AlamofireRequest+Extensions.swift */; };
|
||||
786D78EC1D53C46E006B2CEA /* AlamofireManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 786D78EB1D53C46E006B2CEA /* AlamofireManager+Extensions.swift */; };
|
||||
787682FA1CAD40C300532AB3 /* StaticEstimatedViewHeightProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787682F91CAD40C200532AB3 /* StaticEstimatedViewHeightProtocol.swift */; };
|
||||
787783631CA03CA0001CDC9B /* IndexPath+ImmutableIndexPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787783621CA03CA0001CDC9B /* IndexPath+ImmutableIndexPath.swift */; };
|
||||
787783671CA04D4A001CDC9B /* String+SizeCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787783661CA04D4A001CDC9B /* String+SizeCalculation.swift */; };
|
||||
788E86F71DBA556C009BF65A /* StoryboardProtocol+DefaultBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 788E86F61DBA556C009BF65A /* StoryboardProtocol+DefaultBundle.swift */; };
|
||||
788EC15A1CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 788EC1591CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift */; };
|
||||
78A74EA91C6B373700FE9724 /* UIView+DefaultNibName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78A74EA81C6B373700FE9724 /* UIView+DefaultNibName.swift */; };
|
||||
78B036411DA4D7060021D5CC /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78B036401DA4D7060021D5CC /* UIImage+Extensions.swift */; };
|
||||
|
|
@ -69,12 +72,15 @@
|
|||
78011AB21D48B53600EA16A2 /* ApiRequestParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiRequestParameters.swift; sourceTree = "<group>"; };
|
||||
780D23421DA412470084620D /* CGImage+Alpha.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CGImage+Alpha.swift"; sourceTree = "<group>"; };
|
||||
780D23451DA416F80084620D /* CGContext+Initializers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CGContext+Initializers.swift"; sourceTree = "<group>"; };
|
||||
783423691DB8D0E100A79643 /* StoryboardProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryboardProtocol.swift; sourceTree = "<group>"; };
|
||||
7834236F1DB8D15800A79643 /* StoryboardProtocol+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StoryboardProtocol+Extensions.swift"; sourceTree = "<group>"; };
|
||||
7837F60E1CBCF5C0000D74C1 /* EstimatedViewHeightProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EstimatedViewHeightProtocol.swift; sourceTree = "<group>"; };
|
||||
786D78E71D53C378006B2CEA /* AlamofireRequest+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AlamofireRequest+Extensions.swift"; sourceTree = "<group>"; };
|
||||
786D78EB1D53C46E006B2CEA /* AlamofireManager+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AlamofireManager+Extensions.swift"; sourceTree = "<group>"; };
|
||||
787682F91CAD40C200532AB3 /* StaticEstimatedViewHeightProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticEstimatedViewHeightProtocol.swift; sourceTree = "<group>"; };
|
||||
787783621CA03CA0001CDC9B /* IndexPath+ImmutableIndexPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IndexPath+ImmutableIndexPath.swift"; sourceTree = "<group>"; };
|
||||
787783661CA04D4A001CDC9B /* String+SizeCalculation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+SizeCalculation.swift"; sourceTree = "<group>"; };
|
||||
788E86F61DBA556C009BF65A /* StoryboardProtocol+DefaultBundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StoryboardProtocol+DefaultBundle.swift"; sourceTree = "<group>"; };
|
||||
788EC1591CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStoryboard+InstantiateViewController.swift"; sourceTree = "<group>"; };
|
||||
78A74EA81C6B373700FE9724 /* UIView+DefaultNibName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+DefaultNibName.swift"; path = "LeadKit/Extensions/UIView/UIView+DefaultNibName.swift"; sourceTree = SOURCE_ROOT; };
|
||||
78B036401DA4D7060021D5CC /* UIImage+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+Extensions.swift"; sourceTree = "<group>"; };
|
||||
|
|
@ -197,6 +203,16 @@
|
|||
path = CGContext;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7834236C1DB8D13E00A79643 /* StoryboardProtocol */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7834236F1DB8D15800A79643 /* StoryboardProtocol+Extensions.swift */,
|
||||
788E86F61DBA556C009BF65A /* StoryboardProtocol+DefaultBundle.swift */,
|
||||
);
|
||||
name = StoryboardProtocol;
|
||||
path = LeadKit/StoryboardProtocol;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
786D78E61D53C355006B2CEA /* Alamofire */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -314,6 +330,7 @@
|
|||
780D23411DA412330084620D /* CGImage */,
|
||||
780D23441DA416E80084620D /* CGContext */,
|
||||
C372153938A7B7D327F55124 /* UIStoryboard */,
|
||||
7834236C1DB8D13E00A79643 /* StoryboardProtocol */,
|
||||
78D4B5441DA64D31005B0764 /* UIViewController */,
|
||||
786D78E61D53C355006B2CEA /* Alamofire */,
|
||||
);
|
||||
|
|
@ -332,6 +349,7 @@
|
|||
78CFEE501C5C45E500F50370 /* ViewModelProtocol.swift */,
|
||||
787682F91CAD40C200532AB3 /* StaticEstimatedViewHeightProtocol.swift */,
|
||||
7837F60E1CBCF5C0000D74C1 /* EstimatedViewHeightProtocol.swift */,
|
||||
783423691DB8D0E100A79643 /* StoryboardProtocol.swift */,
|
||||
);
|
||||
path = Protocols;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -558,9 +576,11 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
783423701DB8D15800A79643 /* StoryboardProtocol+Extensions.swift in Sources */,
|
||||
7837F60F1CBCF5C0000D74C1 /* EstimatedViewHeightProtocol.swift in Sources */,
|
||||
78CFEE541C5C45E500F50370 /* UIView+LoadFromNib.swift in Sources */,
|
||||
78D4B5461DA64D49005B0764 /* UIViewController+DefaultStoryboardIdentifier.swift in Sources */,
|
||||
7834236A1DB8D0E100A79643 /* StoryboardProtocol.swift in Sources */,
|
||||
78CFEE521C5C45E500F50370 /* UITableView+CellRegistration.swift in Sources */,
|
||||
78B0FC7F1C6B2C4D00358B64 /* Log.swift in Sources */,
|
||||
78D4B54A1DA64EAB005B0764 /* Any+TypeName.swift in Sources */,
|
||||
|
|
@ -577,6 +597,7 @@
|
|||
78C36F7E1D801E3E00E7EBEA /* Double+Rounding.swift in Sources */,
|
||||
78CFEE551C5C45E500F50370 /* NibNameProtocol.swift in Sources */,
|
||||
78CFEE561C5C45E500F50370 /* ReuseIdentifierProtocol.swift in Sources */,
|
||||
788E86F71DBA556C009BF65A /* StoryboardProtocol+DefaultBundle.swift in Sources */,
|
||||
78B036411DA4D7060021D5CC /* UIImage+Extensions.swift in Sources */,
|
||||
786D78E81D53C378006B2CEA /* AlamofireRequest+Extensions.swift in Sources */,
|
||||
78C36F811D8021DD00E7EBEA /* UIColor+Hex.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// StoryboardProtocol.swift
|
||||
// LeadKit
|
||||
//
|
||||
// Created by Ivan Smolin on 20/10/16.
|
||||
// Copyright © 2016 Touch Instinct. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
/**
|
||||
* protocol which helps us organize storyboards and view controllers creation
|
||||
*/
|
||||
public protocol StoryboardProtocol {
|
||||
|
||||
associatedtype StoryboardIdentifier
|
||||
associatedtype ViewControllerIdentifier
|
||||
|
||||
/**
|
||||
- returns: storyboard identifier with associatedtype type
|
||||
*/
|
||||
static var storyboardIdentifier: StoryboardIdentifier { get }
|
||||
|
||||
/**
|
||||
- returns: bundle for storyboard initialization
|
||||
*/
|
||||
static var bundle: Bundle? { get }
|
||||
|
||||
/**
|
||||
method which instantiate UIViewControlle instance for specific view controller identifier
|
||||
|
||||
- parameter _: object which represents view controller identifier
|
||||
|
||||
- returns: UIViewController instance
|
||||
*/
|
||||
static func instantiateViewController(_: ViewControllerIdentifier) -> UIViewController
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// StoryboardProtocol+DefaultBundle.swift
|
||||
// LeadKit
|
||||
//
|
||||
// Created by Ivan Smolin on 21/10/16.
|
||||
// Copyright © 2016 Touch Instinct. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public extension StoryboardProtocol {
|
||||
|
||||
/**
|
||||
- returns: default bundle for storyboard initialization
|
||||
*/
|
||||
public static var bundle: Bundle? {
|
||||
return Bundle.main
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// StoryboardProtocol+Extensions.swift
|
||||
// LeadKit
|
||||
//
|
||||
// Created by Ivan Smolin on 20/10/16.
|
||||
// Copyright © 2016 Touch Instinct. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public extension StoryboardProtocol where
|
||||
StoryboardIdentifier: RawRepresentable, StoryboardIdentifier.RawValue == String,
|
||||
ViewControllerIdentifier: RawRepresentable, ViewControllerIdentifier.RawValue == String {
|
||||
|
||||
/**
|
||||
- returns: UIStoryboradInstance with StoryboardIdentifier name
|
||||
*/
|
||||
public static var uiStoryboard: UIStoryboard {
|
||||
return UIStoryboard(name: storyboardIdentifier.rawValue, bundle: bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
method for instantiating UIViewController from storyboard using view controller identifier
|
||||
|
||||
- parameter _: object which represents view controller identifier
|
||||
|
||||
- returns: UIViewController instance
|
||||
*/
|
||||
public static func instantiateViewController(_ viewController: ViewControllerIdentifier) -> UIViewController {
|
||||
return uiStoryboard.instantiateViewController(withIdentifier: viewController.rawValue)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue