diff --git a/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/Contents.json b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/Contents.json new file mode 100644 index 0000000000..6bb7945f7e --- /dev/null +++ b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "space_private_icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "space_private_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "space_private_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_private_icon.imageset/space_private_icon.png b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon.png new file mode 100644 index 0000000000..10bc95ab82 Binary files /dev/null and b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon.png differ diff --git a/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon@2x.png b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon@2x.png new file mode 100644 index 0000000000..cae6344e11 Binary files /dev/null and b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon@2x.png differ diff --git a/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon@3x.png b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon@3x.png new file mode 100644 index 0000000000..eaf48592a8 Binary files /dev/null and b/Riot/Assets/Images.xcassets/Spaces/space_private_icon.imageset/space_private_icon@3x.png differ diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 63b974866e..bad6db43d8 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1730,6 +1730,7 @@ Tap the + to start adding people."; "spaces_coming_soon_detail" = "This feature hasn’t been implemented here, but it’s on the way. For now, you can do that with Element on your computer."; "space_participants_action_remove" = "Remove from this space"; "space_participants_action_ban" = "Ban from this space"; +"space_home_show_all_rooms" = "Show all rooms"; "space_private_join_rule" = "Private space"; "space_public_join_rule" = "Public space"; diff --git a/Riot/Generated/Images.swift b/Riot/Generated/Images.swift index c681c2fbeb..83b830e6c6 100644 --- a/Riot/Generated/Images.swift +++ b/Riot/Generated/Images.swift @@ -195,6 +195,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 spacePrivateIcon = ImageAsset(name: "space_private_icon") internal static let spaceRoomIcon = ImageAsset(name: "space_room_icon") internal static let spaceTypeIcon = ImageAsset(name: "space_type_icon") internal static let spaceUserIcon = ImageAsset(name: "space_user_icon") diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index f23c03d2ac..db36f708a7 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -4903,6 +4903,10 @@ public class VectorL10n: NSObject { public static var spaceFeatureUnavailableTitle: String { return VectorL10n.tr("Vector", "space_feature_unavailable_title") } + /// Show all rooms + public static var spaceHomeShowAllRooms: String { + return VectorL10n.tr("Vector", "space_home_show_all_rooms") + } /// Ban from this space public static var spaceParticipantsActionBan: String { return VectorL10n.tr("Vector", "space_participants_action_ban") diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index a219ab3c9d..cdd7d014ee 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -1610,7 +1610,7 @@ + (RecentsDataSourceState *)computeStateWithCells:(NSArray + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewController.swift b/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewController.swift index 8f9710e56f..7b9bebea44 100644 --- a/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewController.swift +++ b/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewController.swift @@ -114,6 +114,17 @@ class SpaceMenuViewController: UIViewController { } private func setupViews() { + setupTableView() + + if self.spaceId == SpaceListViewModel.Constants.homeSpaceId { + let avatarViewData = AvatarViewData(matrixItemId: self.spaceId, displayName: nil, avatarUrl: nil, mediaManager: session.mediaManager, fallbackImage: .image(Asset.Images.spaceHomeIcon.image, .center)) + self.avatarView.fill(with: avatarViewData) + self.titleLabel.text = VectorL10n.titleHome + self.subtitleLabel.text = VectorL10n.settingsTitle + + return + } + guard let space = self.session.spaceService.getSpace(withId: self.spaceId), let summary = space.summary else { MXLog.error("[SpaceMenuViewController] setupViews: no space found") return @@ -130,7 +141,6 @@ class SpaceMenuViewController: UIViewController { self.closeButton.layer.masksToBounds = true self.closeButton.layer.cornerRadius = self.closeButton.bounds.height / 2 - setupTableView() } private func setupTableView() { @@ -139,6 +149,7 @@ class SpaceMenuViewController: UIViewController { self.tableView.estimatedRowHeight = Constants.estimatedRowHeight self.tableView.allowsSelection = true self.tableView.register(cellType: SpaceMenuListViewCell.self) + self.tableView.register(cellType: SpaceMenuSwitchViewCell.self) self.tableView.tableFooterView = UIView() } @@ -235,12 +246,15 @@ extension SpaceMenuViewController: UITableViewDataSource { } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(for: indexPath, cellType: SpaceMenuListViewCell.self) - let viewData = viewModel.menuItems[indexPath.row] - cell.update(theme: self.theme) - cell.fill(with: viewData) + let cell = viewData.style == .toggle ? tableView.dequeueReusableCell(for: indexPath, cellType: SpaceMenuSwitchViewCell.self) : + tableView.dequeueReusableCell(for: indexPath, cellType: SpaceMenuListViewCell.self) + + if let cell = cell as? SpaceMenuCell { + cell.update(theme: self.theme) + cell.update(with: viewData) + } return cell } diff --git a/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModel.swift b/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModel.swift index be6ad25148..39e38934d8 100644 --- a/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModel.swift +++ b/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModel.swift @@ -19,25 +19,19 @@ import Foundation /// View model used by `SpaceMenuViewController` class SpaceMenuViewModel: SpaceMenuViewModelType { - // MARK: - Enum - - enum ActionId: String { - case members = "members" - case rooms = "rooms" - case leave = "leave" - } - // MARK: - Properties weak var coordinatorDelegate: SpaceMenuModelViewModelCoordinatorDelegate? weak var viewDelegate: SpaceMenuViewModelViewDelegate? - var menuItems: [SpaceMenuListItemViewData] = [ - SpaceMenuListItemViewData(actionId: ActionId.members.rawValue, style: .normal, title: VectorL10n.roomDetailsPeople, icon: UIImage(named: "space_menu_members")), - SpaceMenuListItemViewData(actionId: ActionId.rooms.rawValue, style: .normal, title: VectorL10n.spacesExploreRooms, icon: UIImage(named: "space_menu_rooms")), - SpaceMenuListItemViewData(actionId: ActionId.leave.rawValue, style: .destructive, title: VectorL10n.leave, icon: UIImage(named: "space_menu_leave")) + private let spaceMenuItems: [SpaceMenuListItemViewData] = [ + SpaceMenuListItemViewData(action: .exploreSpaceMembers, style: .normal, title: VectorL10n.roomDetailsPeople, icon: Asset.Images.spaceMenuMembers.image, value: nil), + SpaceMenuListItemViewData(action: .exploreSpaceRooms, style: .normal, title: VectorL10n.spacesExploreRooms, icon: Asset.Images.spaceMenuRooms.image, value: nil), + SpaceMenuListItemViewData(action: .leaveSpace, style: .destructive, title: VectorL10n.leave, icon: Asset.Images.spaceMenuLeave.image, value: nil) ] + var menuItems: [SpaceMenuListItemViewData] = [] + private let session: MXSession private let spaceId: String @@ -46,6 +40,14 @@ class SpaceMenuViewModel: SpaceMenuViewModelType { init(session: MXSession, spaceId: String) { self.session = session self.spaceId = spaceId + + if spaceId != SpaceListViewModel.Constants.homeSpaceId { + self.menuItems = spaceMenuItems + } else { + self.menuItems = [ + SpaceMenuListItemViewData(action: .showAllRoomsInHomeSpace, style: .toggle, title: VectorL10n.spaceHomeShowAllRooms, icon: nil, value: MXKAppSettings.standard().showAllRoomsInHomeSpace) + ] + } } // MARK: - Public @@ -55,7 +57,7 @@ class SpaceMenuViewModel: SpaceMenuViewModelType { case .dismiss: self.coordinatorDelegate?.spaceMenuViewModelDidDismiss(self) case .selectRow(at: let indexPath): - self.processAction(with: menuItems[indexPath.row].actionId) + self.processAction(with: menuItems[indexPath.row].action, at: indexPath) case .leaveSpaceAndKeepRooms: self.leaveSpaceAndKeepRooms() case .leaveSpaceAndLeaveRooms: @@ -65,13 +67,16 @@ class SpaceMenuViewModel: SpaceMenuViewModelType { // MARK: - Private - private func processAction(with actionStringId: String) { - let actionId = ActionId(rawValue: actionStringId) - switch actionId { - case .leave: + private func processAction(with action: SpaceMenuListItemAction, at indexPath: IndexPath) { + switch action { + case .showAllRoomsInHomeSpace: + MXKAppSettings.standard().showAllRoomsInHomeSpace = !MXKAppSettings.standard().showAllRoomsInHomeSpace + self.menuItems[indexPath.row].value = MXKAppSettings.standard().showAllRoomsInHomeSpace + self.viewDelegate?.spaceMenuViewModel(self, didUpdateViewState: .deselect) + case .leaveSpace: self.leaveSpace() default: - self.coordinatorDelegate?.spaceMenuViewModel(self, didSelectItemWithId: actionStringId) + self.coordinatorDelegate?.spaceMenuViewModel(self, didSelectItemWith: action) } } diff --git a/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModelType.swift b/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModelType.swift index edaef39b37..7f9511f7b3 100644 --- a/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModelType.swift +++ b/Riot/Modules/Spaces/SpaceMenu/SpaceMenuViewModelType.swift @@ -22,7 +22,7 @@ protocol SpaceMenuViewModelViewDelegate: AnyObject { protocol SpaceMenuModelViewModelCoordinatorDelegate: AnyObject { func spaceMenuViewModelDidDismiss(_ viewModel: SpaceMenuViewModelType) - func spaceMenuViewModel(_ viewModel: SpaceMenuViewModelType, didSelectItemWithId itemId: String) + func spaceMenuViewModel(_ viewModel: SpaceMenuViewModelType, didSelectItemWith action: SpaceMenuListItemAction) } /// Protocol describing the view model used by `SpaceMenuViewController` diff --git a/changelog.d/4570.feature b/changelog.d/4570.feature new file mode 100644 index 0000000000..e1a38944f1 --- /dev/null +++ b/changelog.d/4570.feature @@ -0,0 +1 @@ +M10.4.1 Home space data filtering \ No newline at end of file diff --git a/changelog.d/4886.bugfix b/changelog.d/4886.bugfix new file mode 100644 index 0000000000..ad58b6c36d --- /dev/null +++ b/changelog.d/4886.bugfix @@ -0,0 +1 @@ +Fixed private space invite should use lock icon instead of planet \ No newline at end of file