From d200ce7305a2a304d260b95f37581f4dbfda5598 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 11:38:58 +0900 Subject: [PATCH 01/34] =?UTF-8?q?CreateChatRoom=E3=81=AE=E5=90=84=E7=A8=AE?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewBuilder.swift | 20 ++++++++++++++ .../CreateChatRoomViewController.swift | 26 ++++++++++++++++++ .../CreateChatRoomViewModel.swift | 18 +++++++++++++ .../CreateChatRoomViewPresenter.swift | 24 +++++++++++++++++ .../Storyboards/CreateChatRoom.storyboard | 27 +++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 chat-iOS/Views/CreateChatRoom/CreateChatRoomViewBuilder.swift create mode 100644 chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift create mode 100644 chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift create mode 100644 chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift create mode 100644 chat-iOS/Views/Storyboards/CreateChatRoom.storyboard diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewBuilder.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewBuilder.swift new file mode 100644 index 0000000..10b96b7 --- /dev/null +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewBuilder.swift @@ -0,0 +1,20 @@ +// +// CreateChatRoomViewBuilder.swift +// chat-iOS +// +// Created by jun on 2020/07/18. +// + +import UIKit + +struct CreateChatRoomViewBuilder { + static func create() -> UIViewController { + guard let CreateChatRoomViewController = CreateChatRoomViewController.loadFromStoryboard() as? CreateChatRoomViewController else { + fatalError("fatal: Failed to initialize the CreateChatRoomViewController") + } + let model = CreateChatRoomModel() + let presenter = CreateChatRoomViewPresenter(model: model) + CreateChatRoomViewController.inject(with: presenter) + return CreateChatRoomViewController + } +} diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift new file mode 100644 index 0000000..2e9cbf4 --- /dev/null +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -0,0 +1,26 @@ +// +// File.swift +// chat-iOS +// +// Created by jun on 2020/07/18. +// + +import UIKit + +final class CreateChatRoomViewController: UIViewController { + private var presenter: CreateChatRoomViewPresenterProtocol! + + override func viewDidLoad() { + super.viewDidLoad() + } + + func inject(with presenter: CreateChatRoomViewPresenterProtocol) { + self.presenter = presenter + self.presenter.view = self + } +} + +extension CreateChatRoomViewController: CreateChatRoomViewPresenterOutput { + +} + diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift new file mode 100644 index 0000000..9543bb2 --- /dev/null +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift @@ -0,0 +1,18 @@ +// +// CreateChatRoomViewModel.swift +// chat-iOS +// +// Created by jun on 2020/07/18. +// + +protocol CreateChatRoomModelProtocol { + var presenter: CreateChatRoomModelOutput! { get set } +} + +protocol CreateChatRoomModelOutput { + +} + +final class CreateChatRoomModel: CreateChatRoomModelProtocol { + var presenter: CreateChatRoomModelOutput! +} diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift new file mode 100644 index 0000000..86f5b77 --- /dev/null +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift @@ -0,0 +1,24 @@ +// +// CreateChatRoomViewPresenter.swift +// chat-iOS +// +// Created by jun on 2020/07/18. +// + +protocol CreateChatRoomViewPresenterProtocol { + var view: CreateChatRoomViewPresenterOutput! { get set } +} + +protocol CreateChatRoomViewPresenterOutput { + +} + +final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, CreateChatRoomModelOutput { + var view: CreateChatRoomViewPresenterOutput! + private var model: CreateChatRoomModelProtocol + + init(model: CreateChatRoomModelProtocol) { + self.model = model + } +} + diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard new file mode 100644 index 0000000..13164e0 --- /dev/null +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + From f1519003cbdf812675871bc74ab7863edbb6f1a8 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 12:12:07 +0900 Subject: [PATCH 02/34] =?UTF-8?q?Storyboard=E3=81=AB=E9=83=A8=E5=93=81?= =?UTF-8?q?=E3=81=AE=E9=85=8D=E7=BD=AE=E3=82=92=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Storyboards/CreateChatRoom.storyboard | 138 +++++++++++++++++- 1 file changed, 137 insertions(+), 1 deletion(-) diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index 13164e0..b9dbe05 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -5,6 +5,7 @@ + @@ -15,13 +16,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + From f17d77a09773c0a8b23a055cf7b13c0024e8e211 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 12:22:01 +0900 Subject: [PATCH 03/34] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0?= =?UTF-8?q?=E3=82=BB=E3=83=AB=E3=82=92=E4=BD=9C=E3=81=A3=E3=81=A6=E9=83=A8?= =?UTF-8?q?=E5=93=81=E3=82=92=E6=8E=A5=E7=B6=9A=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 4 ++- .../selectedUserCollectionViewCell.swift | 19 ++++++++++++++ .../serchUserTableviewCell.swift | 25 +++++++++++++++++++ .../Storyboards/CreateChatRoom.storyboard | 20 ++++++++++++--- 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift create mode 100644 chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index 2e9cbf4..c18d58c 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -10,6 +10,9 @@ import UIKit final class CreateChatRoomViewController: UIViewController { private var presenter: CreateChatRoomViewPresenterProtocol! + @IBOutlet weak var serchUserTableview: UITableView! + @IBOutlet weak var selectedUserCollectionView: UICollectionView! + override func viewDidLoad() { super.viewDidLoad() } @@ -23,4 +26,3 @@ final class CreateChatRoomViewController: UIViewController { extension CreateChatRoomViewController: CreateChatRoomViewPresenterOutput { } - diff --git a/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift b/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift new file mode 100644 index 0000000..fb4f59f --- /dev/null +++ b/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift @@ -0,0 +1,19 @@ +// +// selectedUserCollectionViewCell.swift +// chat-iOS +// +// Created by jun on 2020/07/18. +// + +import UIKit + +class SelectedUserCollectionViewCell: UICollectionViewCell { + @IBOutlet weak var profileImageView: UIImageView! + @IBOutlet weak var userNameLabel: UILabel! + @IBOutlet weak var deleteUserButton: UIButton! + + override func awakeFromNib() { + super.awakeFromNib() + + } +} diff --git a/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift new file mode 100644 index 0000000..ec6adcf --- /dev/null +++ b/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift @@ -0,0 +1,25 @@ +// +// serchUserTableviewCell.swift +// chat-iOS +// +// Created by jun on 2020/07/18. +// + +import UIKit + +class SerchUserTableviewCell: UITableViewCell { + + @IBOutlet weak var radioImageView: UIImageView! + @IBOutlet weak var profileImageView: UIImageView! + @IBOutlet weak var userNameLabel: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + } +} diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index b9dbe05..5d14db8 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -21,10 +21,10 @@ - + - + @@ -62,6 +62,11 @@ + + + + + @@ -85,7 +90,7 @@ - + @@ -132,6 +137,11 @@ + + + + + @@ -151,6 +161,10 @@ + + + + From eaca76e994f199a07c69b1ef19e7cc5490cc23ca Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 12:27:08 +0900 Subject: [PATCH 04/34] =?UTF-8?q?=E5=90=84cell=E3=81=AEsetup=E3=82=92?= =?UTF-8?q?=E6=9B=B8=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../selectedUserCollectionViewCell.swift | 22 +++++++++++++++++-- .../serchUserTableviewCell.swift | 22 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift b/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift index fb4f59f..0d247b8 100644 --- a/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift @@ -13,7 +13,25 @@ class SelectedUserCollectionViewCell: UICollectionViewCell { @IBOutlet weak var deleteUserButton: UIButton! override func awakeFromNib() { - super.awakeFromNib() - + super.awakeFromNib() + + self.setupProfileImageView() + self.setupUserNameLabel() + self.setupDeleteUserButton() + } + + private func setupProfileImageView() { + self.profileImageView.layer.cornerRadius = self.profileImageView.frame.width / 2 + self.profileImageView.layer.masksToBounds = true + } + + private func setupUserNameLabel() { + self.userNameLabel.adjustsFontSizeToFitWidth = true + self.userNameLabel.minimumScaleFactor = 0.4 + } + + private func setupDeleteUserButton() { + self.deleteUserButton.layer.cornerRadius = self.deleteUserButton.frame.width / 2 + self.deleteUserButton.layer.masksToBounds = true } } diff --git a/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift index ec6adcf..b2ad07e 100644 --- a/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift @@ -14,8 +14,26 @@ class SerchUserTableviewCell: UITableViewCell { @IBOutlet weak var userNameLabel: UILabel! override func awakeFromNib() { - super.awakeFromNib() - + super.awakeFromNib() + + self.setupRadioImageView() + self.setupProfileImageView() + self.setupUserNameLabel() + } + + private func setupRadioImageView() { + self.radioImageView.layer.cornerRadius = self.radioImageView.frame.width / 2 + self.radioImageView.layer.masksToBounds = true + } + + private func setupProfileImageView() { + self.profileImageView.layer.cornerRadius = self.profileImageView.frame.width / 2 + self.profileImageView.layer.masksToBounds = true + } + + private func setupUserNameLabel() { + self.userNameLabel.adjustsFontSizeToFitWidth = true + self.userNameLabel.minimumScaleFactor = 0.4 } override func setSelected(_ selected: Bool, animated: Bool) { From ae1492c749a10585c01edc2926ade85d93245f84 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 12:42:56 +0900 Subject: [PATCH 05/34] =?UTF-8?q?CreateChatRoomViewController=E3=81=AE?= =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=88=E3=82=A2=E3=83=83=E3=83=95=E3=82=9A?= =?UTF-8?q?=E3=82=92=E8=A1=8C=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 51 +++++++++++++++++++ .../Storyboards/CreateChatRoom.storyboard | 5 +- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index c18d58c..b19ea31 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -10,11 +10,35 @@ import UIKit final class CreateChatRoomViewController: UIViewController { private var presenter: CreateChatRoomViewPresenterProtocol! + @IBOutlet weak var userNameSearchBar: UISearchBar! @IBOutlet weak var serchUserTableview: UITableView! @IBOutlet weak var selectedUserCollectionView: UICollectionView! + + var searchedUsers: [User] = Array() + var selectedUsers: [User] = Array() override func viewDidLoad() { super.viewDidLoad() + + self.setupUserSearchBar() + self.setupSerchUserTableview() + self.setupSelectedUserCollectionView() + } + + private func setupUserSearchBar() { + self.userNameSearchBar.placeholder = "Search by name" + self.userNameSearchBar.delegate = self + } + + private func setupSerchUserTableview() { + self.serchUserTableview.rowHeight = 75 + self.serchUserTableview.delegate = self + self.serchUserTableview.dataSource = self + self.serchUserTableview.tableFooterView = UIView() + } + + private func setupSelectedUserCollectionView() { + self.selectedUserCollectionView.isHidden = true } func inject(with presenter: CreateChatRoomViewPresenterProtocol) { @@ -26,3 +50,30 @@ final class CreateChatRoomViewController: UIViewController { extension CreateChatRoomViewController: CreateChatRoomViewPresenterOutput { } + +extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + self.searchedUsers.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } + + +} + +extension CreateChatRoomViewController: UISearchBarDelegate { + func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { + guard self.userNameSearchBar.isFirstResponder else { return } + self.userNameSearchBar.resignFirstResponder() + } + + func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { + guard let searchBarText = searchBar.text else { return } + guard self.userNameSearchBar.isFirstResponder else { return } + self.userNameSearchBar.resignFirstResponder() + + print("searchText = \(searchBarText)") + } +} diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index 5d14db8..f19306b 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -21,7 +21,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -164,6 +164,7 @@ + From fc1e95367caf4f27497118bef43431299a123062 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 12:43:48 +0900 Subject: [PATCH 06/34] =?UTF-8?q?Search=E3=81=AE=E3=82=B9=E3=83=98?= =?UTF-8?q?=E3=82=9A=E3=83=AB=E3=81=8B=E3=82=99=E9=96=93=E9=81=95=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chat-iOS/App/Routes.swift | 2 +- ...hUserTableviewCell.swift => searchUserTableviewCell.swift} | 4 ++-- chat-iOS/Views/Storyboards/CreateChatRoom.storyboard | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename chat-iOS/Views/CreateChatRoom/{serchUserTableviewCell.swift => searchUserTableviewCell.swift} (93%) diff --git a/chat-iOS/App/Routes.swift b/chat-iOS/App/Routes.swift index 89bacad..7b573c0 100755 --- a/chat-iOS/App/Routes.swift +++ b/chat-iOS/App/Routes.swift @@ -12,7 +12,7 @@ struct Routes { //TODO:- ログインをしてるかの処理を書くこと let isAuthenticated = true - if isAuthenticated { return MainTabBarViewBuilder.create() } + if isAuthenticated { return CreateChatRoomViewBuilder.create() } return UINavigationController(rootViewController: AuthTopViewBuilder.create()) } } diff --git a/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/searchUserTableviewCell.swift similarity index 93% rename from chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift rename to chat-iOS/Views/CreateChatRoom/searchUserTableviewCell.swift index b2ad07e..b2bfd08 100644 --- a/chat-iOS/Views/CreateChatRoom/serchUserTableviewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/searchUserTableviewCell.swift @@ -1,5 +1,5 @@ // -// serchUserTableviewCell.swift +// searchUserTableviewCell.swift // chat-iOS // // Created by jun on 2020/07/18. @@ -7,7 +7,7 @@ import UIKit -class SerchUserTableviewCell: UITableViewCell { +class SearchUserTableviewCell: UITableViewCell { @IBOutlet weak var radioImageView: UIImageView! @IBOutlet weak var profileImageView: UIImageView! diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index f19306b..f573e18 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -21,7 +21,7 @@ - + From 9cdb665fddc88fdbaaa71291bb13426b388589a5 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 13:03:20 +0900 Subject: [PATCH 07/34] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E5=90=8D=E3=81=AE=E6=9C=80=E5=88=9D=E3=81=8C=E5=A4=A7=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=9F=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...earchUserTableviewCell.swift => SearchUserTableviewCell.swift} | 0 ...lectionViewCell.swift => SelectedUserCollectionViewCell.swift} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename chat-iOS/Views/CreateChatRoom/{searchUserTableviewCell.swift => SearchUserTableviewCell.swift} (100%) rename chat-iOS/Views/CreateChatRoom/{selectedUserCollectionViewCell.swift => SelectedUserCollectionViewCell.swift} (100%) diff --git a/chat-iOS/Views/CreateChatRoom/searchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift similarity index 100% rename from chat-iOS/Views/CreateChatRoom/searchUserTableviewCell.swift rename to chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift diff --git a/chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift similarity index 100% rename from chat-iOS/Views/CreateChatRoom/selectedUserCollectionViewCell.swift rename to chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift From 30e3bbf054b0b5347f1a388c7c2384782d26fb90 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 13:19:22 +0900 Subject: [PATCH 08/34] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=ABcell=E3=82=92=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 17 ++++++++++++++--- .../SearchUserTableviewCell.swift | 2 +- .../SelectedUserCollectionViewCell.swift | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index b19ea31..0029e14 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -14,8 +14,11 @@ final class CreateChatRoomViewController: UIViewController { @IBOutlet weak var serchUserTableview: UITableView! @IBOutlet weak var selectedUserCollectionView: UICollectionView! - var searchedUsers: [User] = Array() + var searchedUsers: [User] = [User(id: "1212", displayName: "Bob", profileImageURL: "http..."), User(id: "1212", displayName: "Joe", profileImageURL: "http...")] var selectedUsers: [User] = Array() + + private let searchedUsersCellID = "SearchUserTableviewCell" + private let selectedUsersCellID = "SelectedUserCollectionViewCell" override func viewDidLoad() { super.viewDidLoad() @@ -57,10 +60,18 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return UITableViewCell() + guard let cell = self.serchUserTableview.dequeueReusableCell(withIdentifier: self.searchedUsersCellID, for: indexPath) + as? SearchUserTableviewCell else { return UITableViewCell() } + + cell.userNameLabel.text = self.searchedUsers[indexPath.item].displayName + + return cell } - + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + self.serchUserTableview.deselectRow(at: indexPath, animated: true) + } + } extension CreateChatRoomViewController: UISearchBarDelegate { diff --git a/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift index b2bfd08..1d7631e 100644 --- a/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift @@ -1,5 +1,5 @@ // -// searchUserTableviewCell.swift +// SearchUserTableviewCell.swift // chat-iOS // // Created by jun on 2020/07/18. diff --git a/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift index 0d247b8..ea992c6 100644 --- a/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift @@ -1,5 +1,5 @@ // -// selectedUserCollectionViewCell.swift +// SelectedUserCollectionViewCell.swift // chat-iOS // // Created by jun on 2020/07/18. From a9015c4f9b16245c1d7373f294a31a809c2e1e15 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 13:27:14 +0900 Subject: [PATCH 09/34] =?UTF-8?q?=E3=83=86=E3=82=99=E3=83=8F=E3=82=99?= =?UTF-8?q?=E3=83=83=E3=82=AF=E7=94=A8=E3=81=ABimage=E3=82=92=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoom/CreateChatRoomViewController.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index 0029e14..15e304c 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -64,6 +64,14 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour as? SearchUserTableviewCell else { return UITableViewCell() } cell.userNameLabel.text = self.searchedUsers[indexPath.item].displayName + //TODO:Firestoreから取得した後で表示し直すこと + if #available(iOS 13.0, *) { + cell.profileImageView.image = UIImage(systemName: "bolt.circle.fill") + cell.radioImageView.image = UIImage(systemName: "checkmark.seal.fill") + cell.radioImageView.tintColor = .systemGreen + } else { + // Fallback on earlier versions + } return cell } From 6cd9b4aadde60082b6dbd1e57b67134bb4587b30 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 19:35:23 +0900 Subject: [PATCH 10/34] =?UTF-8?q?serchUserTableview=E3=82=92=E9=81=B8?= =?UTF-8?q?=E6=8A=9E=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E3=83=86?= =?UTF-8?q?=E3=82=99=E3=83=BC=E3=82=BF=E3=82=92tableview=E3=81=A8collectio?= =?UTF-8?q?nview=E3=81=AB=E5=8F=8D=E6=98=A0=E3=81=95=E3=81=9B=E3=82=8B?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E6=9B=B8=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 67 +++++++++++++++++-- .../CreateChatRoomViewModel.swift | 25 ++++++- .../CreateChatRoomViewPresenter.swift | 27 +++++++- .../Storyboards/CreateChatRoom.storyboard | 6 +- 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index 15e304c..176517e 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -14,8 +14,8 @@ final class CreateChatRoomViewController: UIViewController { @IBOutlet weak var serchUserTableview: UITableView! @IBOutlet weak var selectedUserCollectionView: UICollectionView! - var searchedUsers: [User] = [User(id: "1212", displayName: "Bob", profileImageURL: "http..."), User(id: "1212", displayName: "Joe", profileImageURL: "http...")] - var selectedUsers: [User] = Array() + var searchedUsersArray: [User] = [User(id: "1212", displayName: "Bob", profileImageURL: "http..."), User(id: "1324", displayName: "Joe", profileImageURL: "http...")] + var selectedUsersArray: [User] = Array() private let searchedUsersCellID = "SearchUserTableviewCell" private let selectedUsersCellID = "SelectedUserCollectionViewCell" @@ -42,6 +42,9 @@ final class CreateChatRoomViewController: UIViewController { private func setupSelectedUserCollectionView() { self.selectedUserCollectionView.isHidden = true + self.selectedUserCollectionView.collectionViewLayout.invalidateLayout() + self.selectedUserCollectionView.delegate = self + self.selectedUserCollectionView.dataSource = self } func inject(with presenter: CreateChatRoomViewPresenterProtocol) { @@ -51,19 +54,38 @@ final class CreateChatRoomViewController: UIViewController { } extension CreateChatRoomViewController: CreateChatRoomViewPresenterOutput { - + func reloadSerchUserTableview_updateSelectedUsersArray(updatedSelectedUsersArray: [User]) { + self.selectedUsersArray = updatedSelectedUsersArray + + DispatchQueue.main.async { + self.serchUserTableview.reloadData() + } + } + func reloadSelectedUserCollectionView_updateSelectedUsersArray(updatedSelectedUsersArray: [User]) { + self.selectedUsersArray = updatedSelectedUsersArray + + DispatchQueue.main.async { + if self.selectedUserCollectionView.isHidden { self.selectedUserCollectionView.isHidden = false } + self.selectedUserCollectionView.reloadData() + } + } + func hiddenSelectedUsersCollectionView() { + DispatchQueue.main.async { + self.selectedUserCollectionView.isHidden = true + } + } } extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - self.searchedUsers.count + self.searchedUsersArray.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { guard let cell = self.serchUserTableview.dequeueReusableCell(withIdentifier: self.searchedUsersCellID, for: indexPath) as? SearchUserTableviewCell else { return UITableViewCell() } - cell.userNameLabel.text = self.searchedUsers[indexPath.item].displayName + cell.userNameLabel.text = self.searchedUsersArray[indexPath.item].displayName //TODO:Firestoreから取得した後で表示し直すこと if #available(iOS 13.0, *) { cell.profileImageView.image = UIImage(systemName: "bolt.circle.fill") @@ -78,10 +100,45 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { self.serchUserTableview.deselectRow(at: indexPath, animated: true) + self.presenter.didSelectedSerchUserTableview(selectedUser: self.searchedUsersArray[indexPath.item]) } } +extension CreateChatRoomViewController: UICollectionViewDelegate, UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return self.selectedUsersArray.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: selectedUsersCellID, for: indexPath) as! SelectedUserCollectionViewCell + + cell.userNameLabel.text = self.selectedUsersArray[indexPath.item].displayName + + //TODO:Firestoreから取得した後で表示し直すこと + if #available(iOS 13.0, *) { + cell.profileImageView.image = UIImage(systemName: "bolt.circle.fill") + } else { + // Fallback on earlier versions + } + + return cell + } + + func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: 90, height: 90) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: -10.0) + } +} + + extension CreateChatRoomViewController: UISearchBarDelegate { func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { guard self.userNameSearchBar.isFirstResponder else { return } diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift index 9543bb2..9d76c15 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift @@ -7,12 +7,35 @@ protocol CreateChatRoomModelProtocol { var presenter: CreateChatRoomModelOutput! { get set } + + func isContaintsUser(user: User) -> Bool + func removeSelectedUserFromSelectedUserArray(user: User) + func appendUserToSelectedUserArray(user: User) } protocol CreateChatRoomModelOutput { - + func successRemoveSelectedUser(updatedSelectedUsersArray: [User]) + func successAppendUser(updatedSelectedUsersArray: [User]) } final class CreateChatRoomModel: CreateChatRoomModelProtocol { var presenter: CreateChatRoomModelOutput! + private var selectedUsersArray: [User] = Array() + + func isContaintsUser(user: User) -> Bool { + if self.selectedUsersArray.filter({ $0.id == user.id ?? "" }).isEmpty { return false } + return true + } + + func removeSelectedUserFromSelectedUserArray(user: User) { + self.selectedUsersArray = self.selectedUsersArray.filter({ $0.id != user.id }) + + self.presenter.successRemoveSelectedUser(updatedSelectedUsersArray: self.selectedUsersArray) + } + + func appendUserToSelectedUserArray(user: User) { + self.selectedUsersArray.append(user) + + self.presenter.successAppendUser(updatedSelectedUsersArray: self.selectedUsersArray) + } } diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift index 86f5b77..8f9c6d8 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift @@ -7,10 +7,14 @@ protocol CreateChatRoomViewPresenterProtocol { var view: CreateChatRoomViewPresenterOutput! { get set } + + func didSelectedSerchUserTableview(selectedUser: User) } protocol CreateChatRoomViewPresenterOutput { - + func reloadSerchUserTableview_updateSelectedUsersArray(updatedSelectedUsersArray: [User]) + func reloadSelectedUserCollectionView_updateSelectedUsersArray(updatedSelectedUsersArray: [User]) + func hiddenSelectedUsersCollectionView() } final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, CreateChatRoomModelOutput { @@ -19,6 +23,25 @@ final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, Cr init(model: CreateChatRoomModelProtocol) { self.model = model + self.model.presenter = self + } + + func didSelectedSerchUserTableview(selectedUser: User) { + if self.model.isContaintsUser(user: selectedUser) { + self.model.removeSelectedUserFromSelectedUserArray(user: selectedUser) + return + } + self.model.appendUserToSelectedUserArray(user: selectedUser) + } + + func successRemoveSelectedUser(updatedSelectedUsersArray: [User]) { + self.view.reloadSerchUserTableview_updateSelectedUsersArray(updatedSelectedUsersArray: updatedSelectedUsersArray) + self.view.reloadSelectedUserCollectionView_updateSelectedUsersArray(updatedSelectedUsersArray: updatedSelectedUsersArray) + if updatedSelectedUsersArray.isEmpty { self.view.hiddenSelectedUsersCollectionView()} + } + + func successAppendUser(updatedSelectedUsersArray: [User]) { + self.view.reloadSerchUserTableview_updateSelectedUsersArray(updatedSelectedUsersArray: updatedSelectedUsersArray) + self.view.reloadSelectedUserCollectionView_updateSelectedUsersArray(updatedSelectedUsersArray: updatedSelectedUsersArray) } } - diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index f573e18..d30c386 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -83,15 +83,15 @@ - + - - + + From 53e978396564f20e6a1d1a92c8efe335a834839e Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 19:50:23 +0900 Subject: [PATCH 11/34] =?UTF-8?q?radioImageView=E3=81=AB=E7=B5=90=E6=9E=9C?= =?UTF-8?q?=E3=82=92=E5=8F=8D=E6=98=A0=E3=81=95=E3=81=9B=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 8 +++++-- .../SearchUserTableviewCell.swift | 24 ++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index 176517e..fa07427 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -86,11 +86,15 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour as? SearchUserTableviewCell else { return UITableViewCell() } cell.userNameLabel.text = self.searchedUsersArray[indexPath.item].displayName + if !self.selectedUsersArray.filter({ $0.id == searchedUsersArray[indexPath.item].id ?? ""}).isEmpty { + cell.changeFillImageRadioImageView() + } else { + cell.changeNotFillImageRadioImageView() + } + //TODO:Firestoreから取得した後で表示し直すこと if #available(iOS 13.0, *) { cell.profileImageView.image = UIImage(systemName: "bolt.circle.fill") - cell.radioImageView.image = UIImage(systemName: "checkmark.seal.fill") - cell.radioImageView.tintColor = .systemGreen } else { // Fallback on earlier versions } diff --git a/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift index 1d7631e..776eaa8 100644 --- a/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift @@ -35,9 +35,27 @@ class SearchUserTableviewCell: UITableViewCell { self.userNameLabel.adjustsFontSizeToFitWidth = true self.userNameLabel.minimumScaleFactor = 0.4 } + + public func changeFillImageRadioImageView() { + if #available(iOS 13.0, *) { + self.radioImageView.image = UIImage(systemName: "checkmark.seal.fill") + self.radioImageView.tintColor = .systemGreen + } else { + // Fallback on earlier versions + } + } + + public func changeNotFillImageRadioImageView() { + if #available(iOS 13.0, *) { + self.radioImageView.image = UIImage(systemName: "checkmark.seal") + self.radioImageView.tintColor = .systemGray + } else { + // Fallback on earlier versions + } + } - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) - } + } } From 64d01bd44e28548925a027f0240203bd70244c75 Mon Sep 17 00:00:00 2001 From: TappediOS Date: Sat, 18 Jul 2020 21:40:06 +0900 Subject: [PATCH 12/34] =?UTF-8?q?selectedUserCollectionView=E3=81=AEcell?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 6 ++--- .../Storyboards/CreateChatRoom.storyboard | 26 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index fa07427..fb818bc 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -134,11 +134,11 @@ extension CreateChatRoomViewController: UICollectionViewDelegate, UICollectionVi } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: 90, height: 90) + return CGSize(width: 85, height: 90) } - + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: -10.0) + return UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10) } } diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index d30c386..1e05704 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -78,43 +78,43 @@ - + - + - - + + - - + + - + - + From 8972caa289a6c5a32cf1b4a17faec7ac97eeed7d Mon Sep 17 00:00:00 2001 From: TappediOS Date: Thu, 23 Jul 2020 12:19:54 +0900 Subject: [PATCH 32/34] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=88=E3=82=99?= =?UTF-8?q?=E3=82=92=E4=B8=80=E9=83=A8=E6=95=B4=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/CreateChatRoom/CreateChatRoomViewController.swift | 1 - chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift | 2 +- .../Views/CreateChatRoom/SelectedUserCollectionViewCell.swift | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index 0a870f7..1a88086 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -173,7 +173,6 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour self.serchUserTableview.deselectRow(at: indexPath, animated: true) self.presenter.didSelectedSerchUserTableview(selectedUser: searchedUsersArray[indexPath.item]) } - } extension CreateChatRoomViewController: UICollectionViewDelegate, UICollectionViewDataSource { diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift index be6f9aa..26d210d 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewModel.swift @@ -92,7 +92,7 @@ final class CreateChatRoomModel: CreateChatRoomModelProtocol { } func createChatRoom() { - //TODO:- 以下2行は自分自身の情報にする + //TODO:- 以下2行は自分自身の情報にする。Auth()から取得する。 let uid = "J5AH7imn7esru3RKZPu6" let name = "Bob" let memberIDs = [uid] + self.selectedUsersArray.compactMap { $0.id } diff --git a/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift index a8bb876..d17b90a 100644 --- a/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift @@ -37,8 +37,9 @@ class SelectedUserCollectionViewCell: UICollectionViewCell { self.deleteUserButton.layer.masksToBounds = true } + /// ボタンがタプされた時にクロージャで削除する + /// - Parameter sender: UIButton @IBAction func tapDeleteUserButton(_ sender: Any) { self.deleteUserButtonAction?() } - } From 6023a3d7f330cc1621df9b65ea85383739894a9d Mon Sep 17 00:00:00 2001 From: TappediOS Date: Fri, 24 Jul 2020 13:39:46 +0900 Subject: [PATCH 33/34] =?UTF-8?q?cell=E3=81=AE=E5=87=A6=E7=90=86=E3=81=A8?= =?UTF-8?q?=E9=85=8D=E5=88=97=E3=81=AE=E5=8F=96=E5=BE=97=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChatRoomViewController.swift | 15 +++++-------- .../CreateChatRoomViewPresenter.swift | 22 +++++++++++++------ .../SelectedUserCollectionViewCell.swift | 4 ++++ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift index 1a88086..4c0ccb6 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewController.swift @@ -153,10 +153,9 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour guard let cell = self.serchUserTableview.dequeueReusableCell(withIdentifier: self.searchedUsersCellID, for: indexPath) as? SearchUserTableviewCell else { return UITableViewCell() } - let selectedUsersArray: [User] = self.presenter.getSelectedUsersArray() - let searchedUsersArray: [User] = self.presenter.getSearchedUsersArray() - let isSelected = !selectedUsersArray.filter({ $0.id == searchedUsersArray[indexPath.item].id ?? ""}).isEmpty - cell.configure(with: searchedUsersArray[indexPath.item], isSelected: isSelected) + let user = presenter.searchedUsers[indexPath.item] + let isSelected = presenter.isSelected(user: user) + cell.configure(with: user, isSelected: isSelected) //TODO:Firestoreから取得した後で表示し直すこと if #available(iOS 13.0, *) { @@ -169,7 +168,7 @@ extension CreateChatRoomViewController: UITableViewDelegate, UITableViewDataSour } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let searchedUsersArray: [User] = self.presenter.getSearchedUsersArray() + let searchedUsersArray: [User] = self.presenter.searchedUsers self.serchUserTableview.deselectRow(at: indexPath, animated: true) self.presenter.didSelectedSerchUserTableview(selectedUser: searchedUsersArray[indexPath.item]) } @@ -182,10 +181,8 @@ extension CreateChatRoomViewController: UICollectionViewDelegate, UICollectionVi func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: selectedUsersCellID, for: indexPath) as! SelectedUserCollectionViewCell - let selectedUsersArray: [User] = self.presenter.getSelectedUsersArray() - - cell.userNameLabel.text = selectedUsersArray[indexPath.item].displayName - + + cell.configure(with: self.presenter.selectedUsers[indexPath.item]) cell.deleteUserButtonAction = { [weak self] in self?.presenter.didTapSelectedUserCollectionViewCellDeleteUserButton(index: indexPath.item) } diff --git a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift index 0ba56f8..43bc8df 100644 --- a/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift +++ b/chat-iOS/Views/CreateChatRoom/CreateChatRoomViewPresenter.swift @@ -9,6 +9,10 @@ protocol CreateChatRoomViewPresenterProtocol { var view: CreateChatRoomViewPresenterOutput! { get set } var numberOfSearchedUsers: Int { get } var numberOfSelectedUsers: Int { get } + var searchedUsers: [User] { get } + var selectedUsers: [User] { get } + + func isSelected(user: User) -> Bool func didSelectedSerchUserTableview(selectedUser: User) func didTapSelectedUserCollectionViewCellDeleteUserButton(index: Int) @@ -17,9 +21,6 @@ protocol CreateChatRoomViewPresenterProtocol { func didTapCreateRoomutton() func didSearchBarSearchButtonClicked(searchText: String) - - func getSelectedUsersArray() -> [User] - func getSearchedUsersArray() -> [User] } protocol CreateChatRoomViewPresenterOutput: class { @@ -46,6 +47,14 @@ final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, Cr return model.selectedUsersArray.count } + var searchedUsers: [User] { + return model.searchedUsersArray + } + + var selectedUsers: [User] { + return model.selectedUsersArray + } + init(model: CreateChatRoomModelProtocol) { self.model = model self.model.presenter = self @@ -72,7 +81,7 @@ final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, Cr } func didTapCreateRoomutton() { - guard !self.getSelectedUsersArray().isEmpty else { return } + guard !self.selectedUsers.isEmpty else { return } self.model.createChatRoom() } @@ -82,8 +91,7 @@ final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, Cr self.model.searchUser(searchText: searchText) } - func getSelectedUsersArray() -> [User] { return self.model.selectedUsersArray } - func getSearchedUsersArray() -> [User] { return self.model.searchedUsersArray } + func isSelected(user: User) -> Bool { return self.selectedUsers.firstIndex { user.id == $0.id } != nil } func successSearchUser() { self.view.reloadSerchUserTableview() @@ -93,7 +101,7 @@ final class CreateChatRoomViewPresenter: CreateChatRoomViewPresenterProtocol, Cr func successRemoveSelectedUser() { self.view.reloadSelectedUserCollectionView() self.view.reloadSerchUserTableview() - if getSelectedUsersArray().isEmpty { self.view.hiddenSelectedUsersCollectionView()} + if self.selectedUsers.isEmpty { self.view.hiddenSelectedUsersCollectionView()} } func successAppendUser() { diff --git a/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift index d17b90a..472beb0 100644 --- a/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/SelectedUserCollectionViewCell.swift @@ -37,6 +37,10 @@ class SelectedUserCollectionViewCell: UICollectionViewCell { self.deleteUserButton.layer.masksToBounds = true } + func configure(with user: User) { + self.userNameLabel.text = user.displayName + } + /// ボタンがタプされた時にクロージャで削除する /// - Parameter sender: UIButton @IBAction func tapDeleteUserButton(_ sender: Any) { From 9c71c2ba3c90531d161297ca76dcfa8bcf56e37c Mon Sep 17 00:00:00 2001 From: TappediOS Date: Fri, 24 Jul 2020 13:50:07 +0900 Subject: [PATCH 34/34] =?UTF-8?q?radioImageView=E3=81=8B=E3=82=99=E8=A6=8B?= =?UTF-8?q?=E3=81=AB=E3=81=8F=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift | 1 + chat-iOS/Views/Storyboards/CreateChatRoom.storyboard | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift index 876eada..9ebf767 100644 --- a/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift +++ b/chat-iOS/Views/CreateChatRoom/SearchUserTableviewCell.swift @@ -22,6 +22,7 @@ class SearchUserTableviewCell: UITableViewCell { } private func setupRadioImageView() { + self.radioImageView.contentMode = .scaleAspectFill self.radioImageView.layer.cornerRadius = self.radioImageView.frame.width / 2 self.radioImageView.layer.masksToBounds = true } diff --git a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard index 02a6159..7212d8c 100644 --- a/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard +++ b/chat-iOS/Views/Storyboards/CreateChatRoom.storyboard @@ -115,6 +115,7 @@