Skip to content

Commit ebb7fd7

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

File tree

3 files changed

+13
-6
lines changed

3 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,13 +8,13 @@
88
import UIKit
99

1010
struct ChatsViewBuilder {
11-
static func create() -> UIViewController {
11+
static func create(selectRoomId roomId: String, selectRoomName 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()
1616
let presenter = ChatsViewPresenter(model: model)
17-
chatsViewController.inject(with: presenter)
17+
chatsViewController.inject(with: presenter, selectRoomId: roomId, selectRoomName: roomName)
1818
return chatsViewController
1919
}
2020
}

chat-iOS/Views/Chats/ChatsViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ final class ChatsViewController: UIViewController, UICollectionViewDelegateFlowL
1919
@IBOutlet weak var sendButton: UIButton!
2020

2121
var transScripts: [Transcript] = Array()
22-
22+
private var roomId: String = ""
23+
private var roomName: String = ""
24+
2325
let chatsCellID = "chatsCellID"
2426

2527
override func viewDidLoad() {
@@ -93,9 +95,11 @@ final class ChatsViewController: UIViewController, UICollectionViewDelegateFlowL
9395
self.presenter.didTapSendButton(messageText: text)
9496
}
9597

96-
func inject(with presenter: ChatsViewPresenterProtocol) {
98+
func inject(with presenter: ChatsViewPresenterProtocol, selectRoomId roomId: String, selectRoomName roomName: String) {
9799
self.presenter = presenter
98100
self.presenter.view = self
101+
self.roomId = roomId
102+
self.roomName = roomName
99103
}
100104
}
101105

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(selectRoomId: roomId, selectRoomName: roomName)
8587
self.navigationController?.pushViewController(chatsViewController, animated: true)
88+
8689
}
8790

8891
}

0 commit comments

Comments
 (0)