Skip to content

Commit 1761114

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

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

chat-iOS/Views/Chats/ChatsViewBuilder.swift

Lines changed: 3 additions & 3 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(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)
17-
chatsViewController.inject(with: presenter)
16+
let presenter = ChatsViewPresenter(model: model, withRoomId: roomId)
17+
chatsViewController.inject(with: presenter, withRoomName: roomName)
1818
return chatsViewController
1919
}
2020
}

chat-iOS/Views/Chats/ChatsViewController.swift

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

2121
var transScripts: [Transcript] = Array()
22-
22+
private var roomName: String = ""
23+
2324
let chatsCellID = "chatsCellID"
2425

2526
override func viewDidLoad() {
@@ -93,9 +94,10 @@ final class ChatsViewController: UIViewController, UICollectionViewDelegateFlowL
9394
self.presenter.didTapSendButton(messageText: text)
9495
}
9596

96-
func inject(with presenter: ChatsViewPresenterProtocol) {
97+
func inject(with presenter: ChatsViewPresenterProtocol, withRoomName roomName: String) {
9798
self.presenter = presenter
9899
self.presenter.view = self
100+
self.roomName = roomName
99101
}
100102
}
101103

chat-iOS/Views/Chats/ChatsViewPresenter.swift

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

24-
init(model: ChatsViewModelProtocol) {
25+
init(model: ChatsViewModelProtocol, withRoomId roomId: String) {
2526
self.model = model
27+
self.roomId = roomId
2628
self.model.presenter = self
2729
}
2830

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)