Skip to content

Commit 51ba11b

Browse files
committed
画面遷移時にパラメーターの受け渡しを追加
1 parent 0296a9c commit 51ba11b

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

chat-iOS/Views/Chats/ChatsViewBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import UIKit
99

1010
struct ChatsViewBuilder {
11-
static func create() -> UIViewController {
11+
static func create(withRoomId roomId: String, withRoomName roomName: String) -> UIViewController {
1212
guard let chatsViewController = ChatsViewController.loadFromStoryboard() as? ChatsViewController else {
1313
fatalError("fatal: Failed to initialize the ChatsViewController")
1414
}
1515
let model = ChatsViewModel()
16-
let presenter = ChatsViewPresenter(model: model)
16+
let presenter = ChatsViewPresenter(model: model, withRoomId: roomId, withRoomName: roomName)
1717
chatsViewController.inject(with: presenter)
1818
return chatsViewController
1919
}

chat-iOS/Views/Chats/ChatsViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class ChatsViewController: UIViewController, UICollectionViewDelegateFlowL
1919
@IBOutlet weak var sendButton: UIButton!
2020

2121
var transScripts: [Transcript] = Array()
22-
22+
2323
let chatsCellID = "chatsCellID"
2424

2525
override func viewDidLoad() {

chat-iOS/Views/Chats/ChatsViewPresenter.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ protocol ChatsViewPresenterOutput: class {
2020
final class ChatsViewPresenter: ChatsViewPresenterProtocol, ChatsViewModelOutput {
2121
weak var view: ChatsViewPresenterOutput!
2222
private var model: ChatsViewModelProtocol
23+
private var roomId: String
24+
private var roomName: String
2325

24-
init(model: ChatsViewModelProtocol) {
26+
init(model: ChatsViewModelProtocol, withRoomId roomId: String, withRoomName roomName: String) {
2527
self.model = model
28+
self.roomId = roomId
29+
self.roomName = roomName
2630
self.model.presenter = self
2731
}
2832

chat-iOS/Views/SelectChat/SelectChatViewController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ extension SelectChatViewController: SelectChatViewPresenterOutput {
8080
}
8181

8282
func transitionToChatsViewController(selectedRoom room: Room) {
83-
//TODO:- 画面遷移時に加えて値の引き渡しをする
84-
let chatsViewController = ChatsViewBuilder.create()
83+
84+
guard let roomId = room.id else { return }
85+
guard let roomName = room.name else { return }
86+
let chatsViewController = ChatsViewBuilder.create(withRoomId: roomId, withRoomName: roomName)
8587
self.navigationController?.pushViewController(chatsViewController, animated: true)
88+
8689
}
8790

8891
}

0 commit comments

Comments
 (0)