From a7dd15c797e1ee75fe1b381937471b7417dac68e Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 6 May 2021 12:07:08 +0200 Subject: [PATCH] Add space beta announce cell. --- Riot/Assets/en.lproj/Vector.strings | 9 +- Riot/Generated/Strings.swift | 20 +++- Riot/Modules/Spaces/BetaAnnounceCell.swift | 94 ++++++++++++++++ Riot/Modules/Spaces/BetaAnnounceCell.xib | 124 +++++++++++++++++++++ 4 files changed, 243 insertions(+), 4 deletions(-) create mode 100644 Riot/Modules/Spaces/BetaAnnounceCell.swift create mode 100644 Riot/Modules/Spaces/BetaAnnounceCell.xib diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 7634d331e..0fd0f7060 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1619,8 +1619,13 @@ Tap the + to start adding people."; // Mark: - Spaces "space_feature_unavailable_title" = "Not available"; -"space_feature_unavailable_general_info" = "Spaces are only available in Beta on Web, desktop or Android"; +"space_feature_unavailable_general_info" = "Spaces are a beta feature, for now only available on web, desktop and Android.\n\n"; "space_feature_unavailable_invite_info" = "You’re trying to manage a Space invite. Please use your computer to manage the space invite"; "space_feature_unavailable_open_space" = "You’re trying to open a Space. Please use your computer to open the space"; "space_feature_unavailable_space_link_info" = "You’re trying to open a link to a Space. Please use your computer to open the link"; -"space_feature_unavailable_share_link_action" = "Share link"; +"space_feature_unavailable_share_link_action" = "Send link"; + +"space_beta_announce_badge" = "BETA"; +"space_beta_announce_title" = "Meet Spaces"; +"space_beta_announce_subtitle" = "The new version of communities"; +"space_beta_announce_information" = "Spaces are new ways to group rooms and people. You can try them out now on Android, or on your computer."; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 542efffcc..decfcbb94 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -4494,7 +4494,23 @@ internal enum VectorL10n { internal static var socialLoginListTitleSignUp: String { return VectorL10n.tr("Vector", "social_login_list_title_sign_up") } - /// Spaces are only available in Beta on Web, desktop or Android + /// BETA + internal static var spaceBetaAnnounceBadge: String { + return VectorL10n.tr("Vector", "space_beta_announce_badge") + } + /// Spaces are new ways to group rooms and people. You can try them out now on Android, or on your computer. + internal static var spaceBetaAnnounceInformation: String { + return VectorL10n.tr("Vector", "space_beta_announce_information") + } + /// The new version of communities + internal static var spaceBetaAnnounceSubtitle: String { + return VectorL10n.tr("Vector", "space_beta_announce_subtitle") + } + /// Meet Spaces + internal static var spaceBetaAnnounceTitle: String { + return VectorL10n.tr("Vector", "space_beta_announce_title") + } + /// Spaces are a beta feature, for now only available on web, desktop and Android.\n\n internal static var spaceFeatureUnavailableGeneralInfo: String { return VectorL10n.tr("Vector", "space_feature_unavailable_general_info") } @@ -4506,7 +4522,7 @@ internal enum VectorL10n { internal static var spaceFeatureUnavailableOpenSpace: String { return VectorL10n.tr("Vector", "space_feature_unavailable_open_space") } - /// Share link + /// Send link internal static var spaceFeatureUnavailableShareLinkAction: String { return VectorL10n.tr("Vector", "space_feature_unavailable_share_link_action") } diff --git a/Riot/Modules/Spaces/BetaAnnounceCell.swift b/Riot/Modules/Spaces/BetaAnnounceCell.swift new file mode 100644 index 000000000..dac6dca86 --- /dev/null +++ b/Riot/Modules/Spaces/BetaAnnounceCell.swift @@ -0,0 +1,94 @@ +// +// 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 + +@objc protocol BetaAnnounceCellDelegate: class { + func betaAnnounceCellDidTapCloseButton(_ cell: BetaAnnounceCell) +} + +/// BetaAnnounceCell enables to show coming beta feature +final class BetaAnnounceCell: UITableViewCell, Themable { + + // MARK: - Constants + + private enum Constants { + static let cardBackgroundViewCornersRadius: CGFloat = 8.0 + } + + // MARK: - Properties + + @IBOutlet private weak var cardBackgroundView: UIView! + @IBOutlet private weak var closeButton: CloseButton! + @IBOutlet private weak var badgeView: UIView! + @IBOutlet private weak var badgeLabel: UILabel! + @IBOutlet private weak var titleLabel: UILabel! + @IBOutlet private weak var subtitleLabel: UILabel! + @IBOutlet private weak var informationLabel: UILabel! + + @objc weak var delegate: BetaAnnounceCellDelegate? + + // MARK: - Life cycle + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + + self.badgeLabel.text = VectorL10n.spaceBetaAnnounceBadge + self.titleLabel.text = VectorL10n.spaceBetaAnnounceTitle + self.subtitleLabel.text = VectorL10n.spaceBetaAnnounceSubtitle + self.informationLabel.text = VectorL10n.spaceBetaAnnounceInformation + + self.badgeView.layer.masksToBounds = true + self.cardBackgroundView.layer.masksToBounds = true + } + + override func layoutSubviews() { + super.layoutSubviews() + + self.cardBackgroundView.layer.cornerRadius = Constants.cardBackgroundViewCornersRadius + self.badgeView.layer.cornerRadius = self.badgeView.frame.height/2 + } + + // MARK: - Public + + func update(theme: Theme) { + self.closeButton.update(theme: theme) + self.titleLabel.textColor = theme.textPrimaryColor + self.subtitleLabel.textColor = theme.textPrimaryColor + self.informationLabel.textColor = theme.textSecondaryColor + self.cardBackgroundView.backgroundColor = theme.baseColor + self.contentView.backgroundColor = theme.backgroundColor + } + + // MARK: - Actions + + @IBAction private func closeButtonAction(_ sender: Any) { + self.delegate?.betaAnnounceCellDidTapCloseButton(self) + } +} + +// Copy past from NibReusable in order to expose these methods to ObjC +extension BetaAnnounceCell { + @objc static var reuseIdentifier: String { + return String(describing: self) + } + + @objc static var nib: UINib { + return UINib(nibName: String(describing: self), bundle: Bundle(for: self)) + } +} diff --git a/Riot/Modules/Spaces/BetaAnnounceCell.xib b/Riot/Modules/Spaces/BetaAnnounceCell.xib new file mode 100644 index 000000000..5889319fc --- /dev/null +++ b/Riot/Modules/Spaces/BetaAnnounceCell.xib @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +