diff --git a/chat-iOS/Views/Chats/ChatsViewBuilder.swift b/chat-iOS/Views/Chats/ChatsViewBuilder.swift index c00a20e..580b1dd 100644 --- a/chat-iOS/Views/Chats/ChatsViewBuilder.swift +++ b/chat-iOS/Views/Chats/ChatsViewBuilder.swift @@ -8,13 +8,13 @@ import UIKit struct ChatsViewBuilder { - static func create() -> UIViewController { + static func create(selectRoomId roomId: String, selectRoomName roomName: String) -> UIViewController { guard let chatsViewController = ChatsViewController.loadFromStoryboard() as? ChatsViewController else { fatalError("fatal: Failed to initialize the ChatsViewController") } let model = ChatsViewModel() let presenter = ChatsViewPresenter(model: model) - chatsViewController.inject(with: presenter) + chatsViewController.inject(with: presenter, selectRoomId: roomId, selectRoomName: roomName) return chatsViewController } } diff --git a/chat-iOS/Views/Chats/ChatsViewController.swift b/chat-iOS/Views/Chats/ChatsViewController.swift index aca0a03..2eb4638 100644 --- a/chat-iOS/Views/Chats/ChatsViewController.swift +++ b/chat-iOS/Views/Chats/ChatsViewController.swift @@ -19,7 +19,9 @@ final class ChatsViewController: UIViewController, UICollectionViewDelegateFlowL @IBOutlet weak var sendButton: UIButton! var transScripts: [Transcript] = Array() - + private var roomId: String = "" + private var roomName: String = "" + let chatsCellID = "chatsCellID" override func viewDidLoad() { @@ -93,9 +95,11 @@ final class ChatsViewController: UIViewController, UICollectionViewDelegateFlowL self.presenter.didTapSendButton(messageText: text) } - func inject(with presenter: ChatsViewPresenterProtocol) { + func inject(with presenter: ChatsViewPresenterProtocol, selectRoomId roomId: String, selectRoomName roomName: String) { self.presenter = presenter self.presenter.view = self + self.roomId = roomId + self.roomName = roomName } } diff --git a/chat-iOS/Views/SelectChat/SelectChatViewController.swift b/chat-iOS/Views/SelectChat/SelectChatViewController.swift index b2b0eb4..a9ee2f2 100644 --- a/chat-iOS/Views/SelectChat/SelectChatViewController.swift +++ b/chat-iOS/Views/SelectChat/SelectChatViewController.swift @@ -80,9 +80,12 @@ extension SelectChatViewController: SelectChatViewPresenterOutput { } func transitionToChatsViewController(selectedRoom room: Room) { - //TODO:- 画面遷移時に加えて値の引き渡しをする - let chatsViewController = ChatsViewBuilder.create() + + guard let roomId = room.id else { return } + guard let roomName = room.name else { return } + let chatsViewController = ChatsViewBuilder.create(selectRoomId: roomId, selectRoomName: roomName) self.navigationController?.pushViewController(chatsViewController, animated: true) + } }