SpaceFeatureUnaivableViewController: Use a view data to populate view.

This commit is contained in:
SBiOSoftWhare
2021-05-04 10:02:31 +02:00
parent 8fb3583ac6
commit 9c2b032b99
2 changed files with 28 additions and 19 deletions
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="lF3-B1-QSM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -13,32 +11,32 @@
<objects>
<viewController extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="lF3-B1-QSM" customClass="SpaceFeatureUnaivableViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="xml-pK-Qwj">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1B8-AI-sNF">
<rect key="frame" x="0.0" y="44" width="414" height="728"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="510"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nR7-UU-l9H">
<rect key="frame" x="0.0" y="0.0" width="414" height="398"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="358"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="27X-Of-wNa">
<rect key="frame" x="0.0" y="0.0" width="414" height="398"/>
<rect key="frame" x="30.5" y="0.0" width="539" height="358"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="50" translatesAutoresizingMaskIntoConstraints="NO" id="ylT-1L-OLp">
<rect key="frame" x="25" y="50" width="364" height="328"/>
<rect key="frame" x="25" y="50" width="489" height="288"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="feature_unavaible_artwork" translatesAutoresizingMaskIntoConstraints="NO" id="sGd-vk-QZn">
<rect key="frame" x="0.0" y="0.0" width="364" height="106"/>
<rect key="frame" x="0.0" y="0.0" width="489" height="106"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Youre trying to open a link to a Space. Spaces are currently only available in beta on web, or Android" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0bq-od-FQz">
<rect key="frame" x="0.0" y="156" width="364" height="61"/>
<rect key="frame" x="0.0" y="156" width="489" height="41"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Use your computer to open the link. If you do, well let you know when the feature comes to iOS." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9ZF-ov-Mf3">
<rect key="frame" x="0.0" y="267" width="364" height="61"/>
<rect key="frame" x="0.0" y="247" width="489" height="41"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
@@ -75,7 +73,7 @@
</constraints>
</scrollView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BdP-W0-pdD" customClass="CustomRoundedButton" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="47" y="792" width="320" height="50"/>
<rect key="frame" x="140" y="530" width="320" height="50"/>
<constraints>
<constraint firstAttribute="width" priority="750" constant="320" id="G7t-Z3-ug8"/>
<constraint firstAttribute="height" constant="50" id="xkR-Bc-1Cv"/>
@@ -109,8 +107,8 @@
</view>
<connections>
<outlet property="artworkImageView" destination="sGd-vk-QZn" id="823-PG-zoL"/>
<outlet property="generalInfoLabel" destination="9ZF-ov-Mf3" id="9Oc-Zg-QZE"/>
<outlet property="informationLabel" destination="0bq-od-FQz" id="fLM-1x-mjU"/>
<outlet property="instructionsLabel" destination="9ZF-ov-Mf3" id="9Oc-Zg-QZE"/>
<outlet property="shareButton" destination="BdP-W0-pdD" id="V4x-Wz-spl"/>
</connections>
</viewController>
@@ -16,6 +16,11 @@
import UIKit
struct SpaceFeatureUnavailableViewData {
let informationText: String
let shareLink: URL
}
final class SpaceFeatureUnaivableViewController: UIViewController {
// MARK: - Constants
@@ -30,18 +35,20 @@ final class SpaceFeatureUnaivableViewController: UIViewController {
@IBOutlet private weak var artworkImageView: UIImageView!
@IBOutlet private weak var informationLabel: UILabel!
@IBOutlet private weak var instructionsLabel: UILabel!
@IBOutlet private weak var generalInfoLabel: UILabel!
@IBOutlet private weak var shareButton: CustomRoundedButton!
// MARK: Private
private var theme: Theme!
private var viewData: SpaceFeatureUnavailableViewData!
// MARK: - Setup
@objc class func instantiate() -> SpaceFeatureUnaivableViewController {
class func instantiate(with viewData: SpaceFeatureUnavailableViewData) -> SpaceFeatureUnaivableViewController {
let viewController = StoryboardScene.SpaceFeatureUnaivableViewController.initialScene.instantiate()
viewController.theme = ThemeService.shared().theme
viewController.viewData = viewData
return viewController
}
@@ -72,7 +79,9 @@ final class SpaceFeatureUnaivableViewController: UIViewController {
private func setupViews() {
self.title = VectorL10n.spaceFeatureUnavailableTitle
self.instructionsLabel.text = VectorL10n.spaceFeatureUnavailableInstructions
self.informationLabel.text = self.viewData.informationText
self.generalInfoLabel.text = VectorL10n.spaceFeatureUnavailableGeneralInfo
self.shareButton.titleLabel?.font = UIFont.systemFont(ofSize: 17.0, weight: .medium)
self.shareButton.setTitle(VectorL10n.spaceFeatureUnavailableShareLinkAction, for: .normal)
@@ -90,7 +99,7 @@ final class SpaceFeatureUnaivableViewController: UIViewController {
}
self.informationLabel.textColor = theme.textPrimaryColor
self.instructionsLabel.textColor = theme.textSecondaryColor
self.generalInfoLabel.textColor = theme.textSecondaryColor
// Artwork image view
@@ -109,12 +118,14 @@ final class SpaceFeatureUnaivableViewController: UIViewController {
self.shareButton.setImage(buttonImage, for: .normal)
}
func fill(informationText: String, shareLink: URL) {
self.informationLabel.text = informationText
}
// MARK: - Private
private func shareWebAppURL() {
guard let webAppURL = URL(string: BuildSettings.applicationWebAppUrlString) else {
return
}
let webAppURL = self.viewData.shareLink
// Set up activity view controller
let activityItems: [Any] = [ webAppURL ]