-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Router.swift | ||
// Adamant-ios | ||
// | ||
// Created by Anokhov Pavel on 07.01.2018. | ||
// Copyright © 2018 Adamant. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
// MARK: - Adamant Story struct | ||
struct AdamantStory: Equatable, Hashable { | ||
let name: String | ||
|
||
init(_ name: String) { | ||
self.name = name | ||
} | ||
|
||
static func ==(lhs: AdamantStory, rhs: AdamantStory) -> Bool { | ||
return lhs.name == rhs.name | ||
} | ||
|
||
var hashValue: Int { | ||
return name.hashValue &* 171717 | ||
} | ||
} | ||
|
||
// MARK: - Adamant Scene | ||
struct AdamantScene: Equatable, Hashable { | ||
let identifier: String | ||
let story: AdamantStory | ||
|
||
init(story: AdamantStory, identifier: String) { | ||
self.story = story | ||
self.identifier = identifier | ||
} | ||
|
||
static func ==(lhs: AdamantScene, rhs: AdamantScene) -> Bool { | ||
return lhs.identifier == rhs.identifier | ||
} | ||
|
||
var hashValue: Int { | ||
return identifier.hashValue ^ story.hashValue &* 717171 | ||
} | ||
} | ||
|
||
|
||
|
||
// MARK: - Adamant Router | ||
protocol Router { | ||
func get(story: AdamantStory) -> UIStoryboard | ||
func get(scene: AdamantScene) -> UIViewController | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// SwinjectedRouter.swift | ||
// Adamant-ios | ||
// | ||
// Created by Anokhov Pavel on 07.01.2018. | ||
// Copyright © 2018 Adamant. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import SwinjectStoryboard | ||
|
||
class SwinjectedRouter: Router { | ||
private var storyboards = [AdamantStory: UIStoryboard]() | ||
|
||
func get(story: AdamantStory) -> UIStoryboard { | ||
if let storyboard = storyboards[story] { | ||
return storyboard | ||
} else { | ||
let storyboard = SwinjectStoryboard.create(name: story.name, bundle: nil) | ||
storyboards[story] = storyboard | ||
return storyboard | ||
} | ||
} | ||
|
||
func get(scene: AdamantScene) -> UIViewController { | ||
return get(story: scene.story).instantiateViewController(withIdentifier: scene.identifier) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// LoginRoutes.swift | ||
// Adamant-ios | ||
// | ||
// Created by Anokhov Pavel on 07.01.2018. | ||
// Copyright © 2018 Adamant. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension AdamantStory { | ||
static let Login = AdamantStory("Login") | ||
} | ||
|
||
extension AdamantScene { | ||
static let LoginDetails = AdamantScene(story: .Login, identifier: "LoginViewController") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters