Skip to content

Commit

Permalink
画面遷移時にパラメーターの受け渡しを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
geekshu625 committed Jul 22, 2020
1 parent 0296a9c commit ebb7fd7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions chat-iOS/Views/Chats/ChatsViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
8 changes: 6 additions & 2 deletions chat-iOS/Views/Chats/ChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}
}

Expand Down
7 changes: 5 additions & 2 deletions chat-iOS/Views/SelectChat/SelectChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

}

0 comments on commit ebb7fd7

Please sign in to comment.