Merge pull request #43 from TouchInstinct/feature/baseMVVM
add extension for StoryboardProtocol
This commit is contained in:
commit
4c55b6c1d0
|
|
@ -15,7 +15,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.3.3</string>
|
||||
<string>0.3.4</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
protocol BaseViewModel {
|
||||
public protocol BaseViewModel {
|
||||
// Nothing
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,49 +23,54 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
|
||||
protocol ConfigurableController {
|
||||
public protocol ConfigurableController {
|
||||
|
||||
associatedtype ViewModelT
|
||||
|
||||
var viewModel: ViewModelT { get }
|
||||
public var viewModel: ViewModelT { get }
|
||||
|
||||
func bindViews(with _: ViewModelT)
|
||||
public func bindViews()
|
||||
|
||||
func addViews()
|
||||
public func addViews()
|
||||
|
||||
func setAppearance()
|
||||
public func setAppearance()
|
||||
|
||||
func configureBarButtons()
|
||||
public func configureBarButtons()
|
||||
|
||||
func localize()
|
||||
public func localize()
|
||||
|
||||
func initialLoadView()
|
||||
public func initialLoadView()
|
||||
|
||||
}
|
||||
|
||||
extension ConfigurableController where Self: UIViewController {
|
||||
|
||||
func addViews() {
|
||||
public func bindViews() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
func setAppearance() {
|
||||
public func addViews() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
func configureBarButtons() {
|
||||
public func setAppearance() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
func localize() {
|
||||
public func configureBarButtons() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
func initialLoadView() {
|
||||
public func localize() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public func initialLoadView() {
|
||||
addViews()
|
||||
setAppearance()
|
||||
configureBarButtons()
|
||||
localize()
|
||||
bindViews()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
protocol ModuleConfigurator {
|
||||
public protocol ModuleConfigurator {
|
||||
|
||||
associatedtype ViewControllerT
|
||||
|
||||
func configure(input: ViewControllerT)
|
||||
public func configure(input: ViewControllerT)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,3 +50,15 @@ public protocol StoryboardProtocol {
|
|||
static func instantiateViewController(_: ViewControllerIdentifier) -> UIViewController
|
||||
|
||||
}
|
||||
|
||||
public extension StoryboardProtocol {
|
||||
|
||||
public static func instantiate<T: UIViewController>(_ identificator: Self.ViewControllerIdentifier) -> T {
|
||||
guard let controller = instantiateViewController(identificator) as? T else {
|
||||
assertionFailure("\(T.self) not created")
|
||||
return T()
|
||||
}
|
||||
return controller
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue