From a968bab33c4d9ccd299fe60b0a0b46124b605d9e Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Sun, 15 Aug 2021 22:18:16 +0200 Subject: [PATCH] [Spaces] M10.7 Explore rooms #4571 - UI updates after design changes --- .../space_room_icon.imageset/Contents.json | 26 +++ .../space_room_icon.png | Bin 0 -> 447 bytes .../space_room_icon@2x.png | Bin 0 -> 744 bytes .../space_room_icon@3x.png | Bin 0 -> 797 bytes Riot/Assets/en.lproj/Vector.strings | 8 + Riot/Generated/Images.swift | 1 + Riot/Generated/Strings.swift | 32 ++++ ...wSpaceExploreRoomViewController.storyboard | 2 +- .../ShowSpaceExploreRoomViewController.swift | 54 +++++- .../ShowSpaceExploreRoomViewModel.swift | 16 +- .../ShowSpaceExploreRoomViewState.swift | 2 + .../ExploreRoom/SpaceChildSpaceViewCell.swift | 52 ++++++ .../ExploreRoom/SpaceChildSpaceViewCell.xib | 155 ++++++++++++++++++ .../ExploreRoom/SpaceChildViewCell.swift | 30 ++-- .../ExploreRoom/SpaceChildViewCell.xib | 13 +- .../ExploreRoomCoordinator.swift | 45 ++++- ...xploreRoomCoordinatorBridgePresenter.swift | 1 - ...ceChildRoomDetailViewController.storyboard | 60 +++++-- ...owSpaceChildRoomDetailViewController.swift | 62 +++---- 19 files changed, 471 insertions(+), 88 deletions(-) create mode 100644 Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/Contents.json create mode 100644 Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon.png create mode 100644 Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon@2x.png create mode 100644 Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon@3x.png create mode 100644 Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.swift create mode 100644 Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.xib diff --git a/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/Contents.json b/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/Contents.json new file mode 100644 index 0000000000..cb13835ce8 --- /dev/null +++ b/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "space_room_icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "space_room_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "space_room_icon@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon.png b/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ab35d1e4e34eb9f067fa0f7e1657832c79947a89 GIT binary patch literal 447 zcmV;w0YLtVP)r&e+F_1V-88#a8>{+jIk_VV1<)s{vSqboAJ|I00Ji za!~ASFo*K{Kfq%;QTK9w)d_ZtmKqJz=Bedr0vomY06@lMtSN8_QP)4K`^=D__H_bF%a$coZj+-H;LMK zJ+K5OsRt;=+1PoU=9=2Lv;C6+5Cm!!BxyQSQ%~Et0xaPGJTJzC^n~LQ30E_BIIgt- z#Vj3>gzp@cP`Z_c5%1O#lE5up0c`oVI+0(;(j zSGOrmS*J*qSfqOhffM&!-A?;S#PJESEXu_0>0Ge2wSYK36)x=R(b5|G^kbQ`6NIDVHZXeFQzv8&sup|a^+(^LgFbOU6JxBL08 ze#G+it| zv@N}0aLDP&VHsDVD|Kd9t=?3)z#?3KdO?_v!GPJJ ze_a$JDQS7ST6k^T$^MBa1imfA`tKGmzyOO7R8`QJR#>H=ItgP9Fbe2e1sy=W46|G- z0e7i_rnf`2gu$Jvpy};kBcMwaY&bT&9jpY%MCkg literal 0 HcmV?d00001 diff --git a/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon@3x.png b/Riot/Assets/Images.xcassets/Spaces/space_room_icon.imageset/space_room_icon@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..a42b73d919cf13fbdaa0fb7c1d30e0d3fb9c9ba6 GIT binary patch literal 797 zcmV+&1LFLNP)KoE$R*gJSB z2FJT3`F97)>i5!gqI}Lcp52*c%H&abx>va7z`vfE;^J+2SP@8$gDHcj<*BWk`m)v7 ztB6$1x7ppr;&3^Z!%zmRrr!U1VGmn#vwlbbxsI#^MEV#09V6N!fLupb0*2}KFviAI z1d!{8^pl7r{VCVCE&sqxQ%@#01byH z@evA#kap?7CNT{Mr4})9Fo>I?_(T92j$fZ4C8TMvR$9rCSj23Hv1VRZ1fb#YB>n>7 z3bH7lRW!OIA%XY~iWQ%Rqk}{FmPyR79?S>Bi#sQ0v?HmGtrOX_C$WwV6WO#Uv5xCJ zkxh9L>)1MxZJ)&GAbiZ^+yQ+|szYTWJ9>V6DNOg)f==$Ayngb5c0|L`0oTBkc41FK z5r;b{EpLFEkcQ(5C;`98MZ!z;NIlol2TCA%94^?ZrQzrUB@jIhXNK;ahNBOZfQYd{ z3_K3kaP+|vU}uLh7VIoX!_fyyfKAx)3i$kLIQn2UFlaS~+xl3JKJZT5wHp5Qa9bbK bac%es1$nn`Zb2rz00000NkvXXu0mjfq`hI& literal 0 HcmV?d00001 diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index bed70d1e32..83792576b4 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1675,6 +1675,14 @@ Tap the + to start adding people."; "leave_space_message" = "Are you sure you want to leave %@?"; "spaces_explore_rooms" = "Explore rooms"; "spaces_suggested_room" = "Suggested"; +"space_tag" = "space"; +"spaces_empty_space_title" = "This space has no rooms (yet)"; +"spaces_empty_space_detail" = "Some rooms may be hidden because they’re private and you need an invite."; +"spaces_no_result_found_title" = "No results found"; +"spaces_no_room_found_detail" = "Some results may be hidden because they’re private and you need an invite to join them."; +"spaces_no_member_found_detail" = "Looking for someone not in Space name? For now, you can invite them on web or desktop."; +"spaces_coming_soon_title" = "Coming soon"; +"spaces_coming_soon_detail" = "This feature hasn’t been implemented here, but it’s on the way. For now, you can do that on your computer."; // Mark: Avatar diff --git a/Riot/Generated/Images.swift b/Riot/Generated/Images.swift index 5a101cc474..a95972f535 100644 --- a/Riot/Generated/Images.swift +++ b/Riot/Generated/Images.swift @@ -185,6 +185,7 @@ internal enum Asset { internal static let spaceMenuLeave = ImageAsset(name: "space_menu_leave") internal static let spaceMenuMembers = ImageAsset(name: "space_menu_members") internal static let spaceMenuRooms = ImageAsset(name: "space_menu_rooms") + internal static let spaceRoomIcon = ImageAsset(name: "space_room_icon") internal static let spaceUserIcon = ImageAsset(name: "space_user_icon") internal static let spacesMore = ImageAsset(name: "spaces_more") internal static let tabFavourites = ImageAsset(name: "tab_favourites") diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 3332236c31..200b6a9ea2 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -4714,6 +4714,26 @@ internal enum VectorL10n { internal static var spaceFeatureUnavailableTitle: String { return VectorL10n.tr("Vector", "space_feature_unavailable_title") } + /// space + internal static var spaceTag: String { + return VectorL10n.tr("Vector", "space_tag") + } + /// This feature hasn’t been implemented here, but it’s on the way. For now, you can do that on your computer. + internal static var spacesComingSoonDetail: String { + return VectorL10n.tr("Vector", "spaces_coming_soon_detail") + } + /// Coming soon + internal static var spacesComingSoonTitle: String { + return VectorL10n.tr("Vector", "spaces_coming_soon_title") + } + /// Some rooms may be hidden because they’re private and you need an invite. + internal static var spacesEmptySpaceDetail: String { + return VectorL10n.tr("Vector", "spaces_empty_space_detail") + } + /// This space has no rooms (yet) + internal static var spacesEmptySpaceTitle: String { + return VectorL10n.tr("Vector", "spaces_empty_space_title") + } /// Explore rooms internal static var spacesExploreRooms: String { return VectorL10n.tr("Vector", "spaces_explore_rooms") @@ -4726,6 +4746,18 @@ internal enum VectorL10n { internal static var spacesLeftPanelTitle: String { return VectorL10n.tr("Vector", "spaces_left_panel_title") } + /// Looking for someone not in Space name? For now, you can invite them on web or desktop. + internal static var spacesNoMemberFoundDetail: String { + return VectorL10n.tr("Vector", "spaces_no_member_found_detail") + } + /// No results found + internal static var spacesNoResultFoundTitle: String { + return VectorL10n.tr("Vector", "spaces_no_result_found_title") + } + /// Some results may be hidden because they’re private and you need an invite to join them. + internal static var spacesNoRoomFoundDetail: String { + return VectorL10n.tr("Vector", "spaces_no_room_found_detail") + } /// Suggested internal static var spacesSuggestedRoom: String { return VectorL10n.tr("Vector", "spaces_suggested_room") diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.storyboard b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.storyboard index 3dcf75622d..08392bde97 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.storyboard +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.storyboard @@ -24,7 +24,7 @@ - + diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.swift index 4c15c4d9b2..dcc83b7b6e 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewController.swift @@ -26,8 +26,6 @@ final class ShowSpaceExploreRoomViewController: UIViewController { static let estimatedRowHeight: CGFloat = 64 } - // MARK: - Properties - // MARK: Outlets @IBOutlet private var tableView: UITableView! @@ -40,12 +38,27 @@ final class ShowSpaceExploreRoomViewController: UIViewController { private var errorPresenter: MXKErrorPresentation! private var activityPresenter: ActivityIndicatorPresenter! private var titleView: MainTitleView! + private var emptyView: RootTabEmptyView! + private var plusButtonImageView: UIImageView! private var itemDataList: [SpaceExploreRoomListItemViewData] = [] { didSet { tableView.reloadData() } } + + private var emptyViewArtwork: UIImage { + return ThemeService.shared().isCurrentThemeDark() ? Asset.Images.roomsEmptyScreenArtworkDark.image : Asset.Images.roomsEmptyScreenArtwork.image + } + + private var scrollViewHidden = true { + didSet { + UIView.animate(withDuration: 0.2) { + self.tableView.alpha = self.scrollViewHidden ? 0 : 1 + self.emptyView.alpha = self.scrollViewHidden ? 1 : 0 + } + } + } // MARK: - Setup @@ -53,6 +66,7 @@ final class ShowSpaceExploreRoomViewController: UIViewController { let viewController = StoryboardScene.ShowSpaceExploreRoomViewController.initialScene.instantiate() viewController.viewModel = viewModel viewController.theme = ThemeService.shared().theme + viewController.emptyView = RootTabEmptyView.instantiate() return viewController } @@ -74,6 +88,10 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.viewModel.viewDelegate = self self.viewModel.process(viewAction: .loadData) + + self.emptyView.frame = CGRect(x: 0, y: self.searchBar.frame.maxY, width: self.view.bounds.width, height: self.view.bounds.height - self.searchBar.frame.maxY) + self.emptyView.autoresizingMask = [.flexibleHeight, .flexibleWidth] + self.view.insertSubview(self.emptyView, at: 0) } override func viewWillAppear(_ animated: Bool) { @@ -106,6 +124,7 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.titleView.update(theme: theme) self.tableView.backgroundColor = theme.colors.background self.tableView.reloadData() + self.emptyView.update(theme: theme) } private func registerThemeServiceDidChangeThemeNotification() { @@ -123,7 +142,7 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.navigationItem.rightBarButtonItem = cancelBarButtonItem - self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) + self.vc_removeBackTitle() self.titleView = MainTitleView() self.titleView.titleLabel.text = VectorL10n.titleRooms @@ -131,6 +150,10 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.tableView.keyboardDismissMode = .interactive self.setupTableView() + + self.emptyView.fill(with: self.emptyViewArtwork, title: VectorL10n.roomsEmptyViewTitle, informationText: VectorL10n.roomsEmptyViewInformation) + + self.plusButtonImageView = self.vc_addFAB(withImage: Asset.Images.roomsFloatingAction.image, target: self, action: #selector(addRoomAction(semder:))) } private func setupTableView() { @@ -139,6 +162,7 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.tableView.estimatedRowHeight = Constants.estimatedRowHeight self.tableView.allowsSelection = true self.tableView.register(cellType: SpaceChildViewCell.self) + self.tableView.register(cellType: SpaceChildSpaceViewCell.self) self.tableView.tableFooterView = UIView() } @@ -150,6 +174,10 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.titleView.subtitleLabel.text = spaceName case .loaded(let children): self.renderLoaded(children: children) + case .emptySpace: + self.renderEmptySpace() + case .emptyFilterResult: + self.renderEmptyFilterResult() case .error(let error): self.render(error: error) } @@ -162,6 +190,7 @@ final class ShowSpaceExploreRoomViewController: UIViewController { private func renderLoaded(children: [SpaceExploreRoomListItemViewData]) { self.activityPresenter.removeCurrentActivityIndicator(animated: true) self.itemDataList = children + self.scrollViewHidden = false } private func render(error: Error) { @@ -169,6 +198,17 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.errorPresenter.presentError(from: self, forError: error, animated: true, handler: nil) } + private func renderEmptySpace() { + self.emptyView.fill(with: self.emptyViewArtwork, title: VectorL10n.spacesEmptySpaceTitle, informationText: VectorL10n.spacesEmptySpaceTitle) + self.scrollViewHidden = true + self.activityPresenter.removeCurrentActivityIndicator(animated: true) + } + + private func renderEmptyFilterResult() { + self.emptyView.fill(with: self.emptyViewArtwork, title: VectorL10n.spacesNoResultFoundTitle, informationText: VectorL10n.spacesNoRoomFoundDetail) + self.scrollViewHidden = true + self.activityPresenter.removeCurrentActivityIndicator(animated: true) + } // MARK: - Actions @@ -176,6 +216,10 @@ final class ShowSpaceExploreRoomViewController: UIViewController { self.viewModel.process(viewAction: .cancel) } + @objc private func addRoomAction(semder: UIView) { + self.errorPresenter.presentError(from: self, title: VectorL10n.spacesComingSoonTitle, message: VectorL10n.spacesComingSoonDetail, animated: true, handler: nil) + } + // MARK: - UISearchBarDelegate override func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { @@ -195,10 +239,10 @@ extension ShowSpaceExploreRoomViewController: UITableViewDataSource { } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(for: indexPath, cellType: SpaceChildViewCell.self) - let viewData = self.itemDataList[indexPath.row] + let cell = viewData.childInfo.roomType == .space ? tableView.dequeueReusableCell(for: indexPath, cellType: SpaceChildSpaceViewCell.self) : tableView.dequeueReusableCell(for: indexPath, cellType: SpaceChildViewCell.self) + cell.update(theme: self.theme) cell.fill(with: viewData) cell.selectionStyle = .none diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewModel.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewModel.swift index 92a6a55d20..9831497eb8 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewModel.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewModel.swift @@ -42,7 +42,15 @@ final class ShowSpaceExploreRoomViewModel: ShowSpaceExploreRoomViewModelType { } private var filteredItemDataList: [SpaceExploreRoomListItemViewData] = [] { didSet { - self.update(viewState: .loaded(self.filteredItemDataList)) + if self.filteredItemDataList.isEmpty { + if self.itemDataList.isEmpty { + self.update(viewState: .emptySpace) + } else { + self.update(viewState: .emptyFilterResult) + } + } else { + self.update(viewState: .loaded(self.filteredItemDataList)) + } } } @@ -95,7 +103,11 @@ final class ShowSpaceExploreRoomViewModel: ShowSpaceExploreRoomViewModelType { switch response { case .success(let spaceSummary): - self.itemDataList = spaceSummary.childInfos.map({ childInfo in + self.itemDataList = spaceSummary.childInfos.compactMap({ childInfo in + guard childInfo.parentIds.contains(self.spaceId) else { + return nil + } + let avatarViewData = AvatarViewData(avatarUrl: childInfo.avatarUrl, mediaManager: self.session.mediaManager, fallbackImage: .matrixItem(childInfo.childRoomId, childInfo.name)) return SpaceExploreRoomListItemViewData(childInfo: childInfo, avatarViewData: avatarViewData) }) diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewState.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewState.swift index cb7674733c..08ab87a3bc 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewState.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/ShowSpaceExploreRoomViewState.swift @@ -23,5 +23,7 @@ enum ShowSpaceExploreRoomViewState { case loading case spaceNameFound(_ spaceName: String) case loaded(_ children: [SpaceExploreRoomListItemViewData]) + case emptySpace + case emptyFilterResult case error(Error) } diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.swift new file mode 100644 index 0000000000..dc4ef9881c --- /dev/null +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.swift @@ -0,0 +1,52 @@ +// +// Copyright 2021 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit +import Reusable + +class SpaceChildSpaceViewCell: SpaceChildViewCell { + + @IBOutlet private weak var roomsIcon: UIImageView! + @IBOutlet private weak var roomNumberLabel: UILabel! + @IBOutlet private weak var spaceTagView: UIView! + + // MARK: - Life cycle + + override func awakeFromNib() { + super.awakeFromNib() + + self.spaceTagView.layer.masksToBounds = true + self.spaceTagView.layer.cornerRadius = 2 + } + + // MARK: - Public + + override func fill(with viewData: SpaceExploreRoomListItemViewData) { + super.fill(with: viewData) + + self.roomNumberLabel.text = "\(viewData.childInfo.childrenIds.count)" + self.topicLabel.text = VectorL10n.spaceTag + } + + override func update(theme: Theme) { + super.update(theme: theme) + + self.roomNumberLabel.font = theme.fonts.caption1 + self.roomNumberLabel.textColor = theme.colors.tertiaryContent + self.roomsIcon.tintColor = theme.colors.tertiaryContent + self.spaceTagView.backgroundColor = theme.colors.quinaryContent + } +} diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.xib b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.xib new file mode 100644 index 0000000000..2559fbcdae --- /dev/null +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildSpaceViewCell.xib @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.swift index 5d5a05fcee..541fc63809 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.swift @@ -21,15 +21,14 @@ class SpaceChildViewCell: UITableViewCell, Themable, NibReusable { // MARK: - Properties - @IBOutlet private weak var spaceAvatarView: SpaceAvatarView! - @IBOutlet private weak var roomAvatarView: RoomAvatarView! - @IBOutlet private weak var titleLabel: UILabel! - @IBOutlet private weak var titleLabelTrailingMargin: NSLayoutConstraint! - @IBOutlet private weak var selectionView: UIView! - @IBOutlet private weak var userIconView: UIImageView! - @IBOutlet private weak var membersLabel: UILabel! - @IBOutlet private weak var topicLabel: UILabel! - @IBOutlet private weak var suggestedLabel: UILabel! + @IBOutlet internal weak var avatarView: AvatarView! + @IBOutlet internal weak var titleLabel: UILabel! + @IBOutlet internal weak var titleLabelTrailingMargin: NSLayoutConstraint! + @IBOutlet internal weak var selectionView: UIView! + @IBOutlet internal weak var userIconView: UIImageView! + @IBOutlet internal weak var membersLabel: UILabel! + @IBOutlet internal weak var topicLabel: UILabel! + @IBOutlet internal weak var suggestedLabel: UILabel! // MARK: - Private @@ -57,14 +56,8 @@ class SpaceChildViewCell: UITableViewCell, Themable, NibReusable { // MARK: - Public func fill(with viewData: SpaceExploreRoomListItemViewData) { - self.spaceAvatarView.isHidden = viewData.childInfo.roomType != .space - self.roomAvatarView.isHidden = viewData.childInfo.roomType == .space - if viewData.childInfo.roomType == .space { - self.spaceAvatarView.fill(with: viewData.avatarViewData) - } else { - self.roomAvatarView.fill(with: viewData.avatarViewData) - } - self.titleLabel.text = viewData.childInfo.name + self.avatarView.fill(with: viewData.avatarViewData) + self.titleLabel.text = viewData.childInfo.name ?? viewData.childInfo.canonicalAlias self.membersLabel.text = "\(viewData.childInfo.activeMemberCount)" self.topicLabel.text = viewData.childInfo.topic self.suggestedLabel.text = viewData.childInfo.suggested ? VectorL10n.spacesSuggestedRoom : nil @@ -75,8 +68,7 @@ class SpaceChildViewCell: UITableViewCell, Themable, NibReusable { func update(theme: Theme) { self.theme = theme self.backgroundColor = theme.colors.background - self.spaceAvatarView.update(theme: theme) - self.roomAvatarView.update(theme: theme) + self.avatarView.update(theme: theme) self.titleLabel.textColor = theme.colors.primaryContent self.titleLabel.font = theme.fonts.calloutSB self.selectionView.backgroundColor = theme.colors.separator diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.xib b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.xib index 56685566f6..d81bc28e31 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.xib +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoom/SpaceChildViewCell.xib @@ -25,7 +25,7 @@ - + @@ -33,10 +33,6 @@ - - - - @@ -93,27 +89,22 @@ - - - - + - - diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift index b14d870ea7..801e94fa59 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift @@ -79,7 +79,34 @@ final class ExploreRoomCoordinator: ExploreRoomCoordinatorType { if let currentCoordinator = self.roomDetailCoordinator { self.remove(childCoordinator: currentCoordinator) } + + let summary = self.session.roomSummary(withRoomId: item.childInfo.childRoomId) + var isJoined = false + if let summary = summary { + isJoined = summary.membership == .join || summary.membershipTransitionState == .joined + } + if isJoined { + let roomDataSourceManager = MXKRoomDataSourceManager.sharedManager(forMatrixSession: self.session) + roomDataSourceManager?.roomDataSource(forRoom: item.childInfo.childRoomId, create: true, onComplete: { [weak self] roomDataSource in + + let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main) + guard let roomViewController = storyboard.instantiateViewController(withIdentifier: "RoomViewControllerStoryboardId") as? RoomViewController else { + return + } + + self?.navigationRouter.push(roomViewController, animated: true, popCompletion: nil) + roomViewController.displayRoom(roomDataSource) + roomViewController.navigationItem.leftItemsSupplementBackButton = true + }) + } else { + self.showRoomPreview(with: item, from: sourceView) + } + } + + // MARK: - Private methods + + private func showRoomPreview(with item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { let coordinator = self.createShowSpaceRoomDetailCoordinator(session: self.session, childInfo: item.childInfo) coordinator.start() self.add(childCoordinator: coordinator) @@ -98,8 +125,6 @@ final class ExploreRoomCoordinator: ExploreRoomCoordinatorType { self.navigationRouter.present(viewController, animated: true) } } - - // MARK: - Private methods private func createShowSpaceExploreRoomCoordinator(session: MXSession, spaceId: String, spaceName: String?) -> ShowSpaceExploreRoomCoordinator { let coordinator = ShowSpaceExploreRoomCoordinator(session: session, spaceId: spaceId, spaceName: spaceName) @@ -136,6 +161,20 @@ extension ExploreRoomCoordinator: ShowSpaceChildRoomDetailCoordinatorDelegate { } func showSpaceChildRoomDetailCoordinatorDidCancel(_ coordinator: ShowSpaceChildRoomDetailCoordinatorType) { - self.delegate?.exploreRoomCoordinatorDidComplete(self, withSelectedIem: nil, from: nil) + if UIDevice.current.isPhone { + slidingModalPresenter.dismiss(animated: true) { + if let roomDetailCoordinator = self.roomDetailCoordinator { + self.remove(childCoordinator: roomDetailCoordinator) + self.roomDetailCoordinator = nil + } + } + } else { + self.roomDetailCoordinator?.toPresentable().dismiss(animated: true, completion: { + if let roomDetailCoordinator = self.roomDetailCoordinator { + self.remove(childCoordinator: roomDetailCoordinator) + self.roomDetailCoordinator = nil + } + }) + } } } diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift index e06894b52f..d456656a83 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift @@ -102,7 +102,6 @@ extension ExploreRoomCoordinatorBridgePresenter: ExploreRoomCoordinatorDelegate } // MARK: - UIAdaptivePresentationControllerDelegate - extension ExploreRoomCoordinatorBridgePresenter: UIAdaptivePresentationControllerDelegate { func exploreRoomCoordinatorDidComplete(_ presentationController: UIPresentationController) { diff --git a/Riot/Modules/Spaces/SpaceRoomList/SpaceChildRoomDetail/ShowSpaceChildRoomDetailViewController.storyboard b/Riot/Modules/Spaces/SpaceRoomList/SpaceChildRoomDetail/ShowSpaceChildRoomDetailViewController.storyboard index ffecd409b0..c5e98752c9 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/SpaceChildRoomDetail/ShowSpaceChildRoomDetailViewController.storyboard +++ b/Riot/Modules/Spaces/SpaceRoomList/SpaceChildRoomDetail/ShowSpaceChildRoomDetailViewController.storyboard @@ -17,37 +17,54 @@ - + - - + + + - + - +