Extract and refactor card view

This commit is contained in:
Justin Mazzocchi 2020-09-28 18:14:43 -07:00
parent 6c32d51d30
commit a7e6db409a
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
7 changed files with 211 additions and 144 deletions

View File

@ -53,6 +53,8 @@
D0E2C1D124FD97F000854680 /* ViewModels in Frameworks */ = {isa = PBXBuildFile; productRef = D0E2C1D024FD97F000854680 /* ViewModels */; };
D0E5361C24E3EB4D00FB1CE1 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E5361B24E3EB4D00FB1CE1 /* NotificationService.swift */; };
D0E5362024E3EB4D00FB1CE1 /* Notification Service Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = D0E5361924E3EB4D00FB1CE1 /* Notification Service Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
D0EA59402522AC8700804347 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EA593F2522AC8700804347 /* CardView.swift */; };
D0EA59482522B8B600804347 /* ViewConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EA59472522B8B600804347 /* ViewConstants.swift */; };
D0F0B10E251A868200942152 /* AccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F0B10D251A868200942152 /* AccountView.swift */; };
D0F0B113251A86A000942152 /* AccountContentConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F0B112251A86A000942152 /* AccountContentConfiguration.swift */; };
D0F0B126251A90F400942152 /* AccountListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F0B125251A90F400942152 /* AccountListCell.swift */; };
@ -150,6 +152,8 @@
D0E5361B24E3EB4D00FB1CE1 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
D0E5361D24E3EB4D00FB1CE1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D0E5362824E4A06B00FB1CE1 /* Notification Service Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Notification Service Extension.entitlements"; sourceTree = "<group>"; };
D0EA593F2522AC8700804347 /* CardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; };
D0EA59472522B8B600804347 /* ViewConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewConstants.swift; sourceTree = "<group>"; };
D0F0B10D251A868200942152 /* AccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountView.swift; sourceTree = "<group>"; };
D0F0B112251A86A000942152 /* AccountContentConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountContentConfiguration.swift; sourceTree = "<group>"; };
D0F0B125251A90F400942152 /* AccountListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountListCell.swift; sourceTree = "<group>"; };
@ -236,6 +240,7 @@
D0625E55250F086B00502611 /* Status */ = {
isa = PBXGroup;
children = (
D0EA593F2522AC8700804347 /* CardView.swift */,
D0625E5C250F0B5C00502611 /* StatusContentConfiguration.swift */,
D0625E58250F092900502611 /* StatusListCell.swift */,
D0625E5E250F0CFF00502611 /* StatusView.swift */,
@ -277,7 +282,6 @@
D0F0B10D251A868200942152 /* AccountView.swift */,
D0C7D42424F76169001EBDBB /* AddIdentityView.swift */,
D01F41E024F8885900D55A2D /* Attachments */,
D0C7D42524F76169001EBDBB /* TableView.swift */,
D0C7D42324F76169001EBDBB /* CustomEmojiText.swift */,
D0BEB21024FA2A90001B0F04 /* EditFilterView.swift */,
D0BEB20424FA1107001B0F04 /* FiltersView.swift */,
@ -292,8 +296,10 @@
D02E1F94250B13210071AD56 /* SafariView.swift */,
D0C7D42924F76169001EBDBB /* SecondaryNavigationView.swift */,
D0625E55250F086B00502611 /* Status */,
D0C7D42524F76169001EBDBB /* TableView.swift */,
D0C7D42E24F76169001EBDBB /* TabNavigationView.swift */,
D01F41D624F880C400D55A2D /* TouchFallthroughTextView.swift */,
D0EA59472522B8B600804347 /* ViewConstants.swift */,
D0E1F582251F13EC00D45315 /* WebfingerIndicatorView.swift */,
);
path = Views;
@ -545,10 +551,12 @@
D06BC5E625202AD90079541D /* ProfileViewController.swift in Sources */,
D01C6FAC252024BD003D0300 /* Array+Extensions.swift in Sources */,
D0C7D4D924F7616A001EBDBB /* KingfisherOptionsInfo+Extensions.swift in Sources */,
D0EA59402522AC8700804347 /* CardView.swift in Sources */,
D0F0B10E251A868200942152 /* AccountView.swift in Sources */,
D0BEB1FF24F9E5BB001B0F04 /* ListsView.swift in Sources */,
D0C7D49724F7616A001EBDBB /* IdentitiesView.swift in Sources */,
D01EF22425182B1F00650C6B /* AccountHeaderView.swift in Sources */,
D0EA59482522B8B600804347 /* ViewConstants.swift in Sources */,
D0C7D49824F7616A001EBDBB /* CustomEmojiText.swift in Sources */,
D01F41E424F8889700D55A2D /* AttachmentsView.swift in Sources */,
D0BEB21124FA2A91001B0F04 /* EditFilterView.swift in Sources */,

View File

@ -0,0 +1,22 @@
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
import Mastodon
public struct CardViewModel {
private let card: Card
init(card: Card) {
self.card = card
}
}
public extension CardViewModel {
var url: URL { card.url }
var title: String { card.title }
var description: String { card.description }
var imageURL: URL? { card.image }
}

View File

@ -90,13 +90,13 @@ public extension StatusViewModel {
var sharingURL: URL? { statusService.status.displayStatus.url }
var cardURL: URL? { statusService.status.displayStatus.card?.url }
var cardTitle: String? { statusService.status.displayStatus.card?.title }
var cardDescription: String? { statusService.status.displayStatus.card?.description }
var cardImageURL: URL? { statusService.status.displayStatus.card?.image }
var cardViewModel: CardViewModel? {
if let card = statusService.status.displayStatus.card {
return CardViewModel(card: card)
} else {
return nil
}
}
var canBeReblogged: Bool {
switch statusService.status.displayStatus.visibility {

106
Views/Status/CardView.swift Normal file
View File

@ -0,0 +1,106 @@
// Copyright © 2020 Metabolist. All rights reserved.
import Kingfisher
import UIKit
import ViewModels
final class CardView: UIView {
let imageView = UIImageView()
let titleLabel = UILabel()
let descriptionLabel = UILabel()
let urlLabel = UILabel()
let button = UIButton()
var viewModel: CardViewModel? {
didSet {
guard let viewModel = viewModel else { return }
imageView.isHidden = viewModel.imageURL == nil
imageView.kf.setImage(with: viewModel.imageURL)
titleLabel.text = viewModel.title
descriptionLabel.text = viewModel.description
descriptionLabel.isHidden = descriptionLabel.text == "" || descriptionLabel.text == titleLabel.text
if
let host = viewModel.url.host, host.hasPrefix("www."),
let withoutWww = host.components(separatedBy: "www.").last {
urlLabel.text = withoutWww
} else {
urlLabel.text = viewModel.url.host
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
initializationActions()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
initializationActions()
}
}
private extension CardView {
// swiftlint:disable:next function_body_length
func initializationActions() {
backgroundColor = .secondarySystemBackground
layer.cornerRadius = .defaultCornerRadius
clipsToBounds = true
let stackView = UIStackView()
let innerStackView = UIStackView()
addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false
addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.setBackgroundImage(.highlightedButtonBackground, for: .highlighted)
stackView.addArrangedSubview(imageView)
stackView.addArrangedSubview(innerStackView)
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.setContentCompressionResistancePriority(.defaultLow, for: .vertical)
imageView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
innerStackView.axis = .vertical
innerStackView.isLayoutMarginsRelativeArrangement = true
innerStackView.directionalLayoutMargins =
.init(top: .defaultSpacing, leading: .defaultSpacing, bottom: .defaultSpacing, trailing: .defaultSpacing)
innerStackView.spacing = .compactSpacing
innerStackView.addArrangedSubview(titleLabel)
innerStackView.addArrangedSubview(descriptionLabel)
innerStackView.addArrangedSubview(urlLabel)
titleLabel.font = .preferredFont(forTextStyle: .headline)
titleLabel.adjustsFontForContentSizeCategory = true
titleLabel.setContentCompressionResistancePriority(.required, for: .vertical)
descriptionLabel.font = .preferredFont(forTextStyle: .subheadline)
descriptionLabel.adjustsFontForContentSizeCategory = true
descriptionLabel.setContentCompressionResistancePriority(.required, for: .vertical)
urlLabel.font = .preferredFont(forTextStyle: .footnote)
urlLabel.adjustsFontForContentSizeCategory = true
urlLabel.setContentCompressionResistancePriority(.required, for: .vertical)
urlLabel.textColor = .secondaryLabel
NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.topAnchor.constraint(equalTo: topAnchor),
stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
button.leadingAnchor.constraint(equalTo: leadingAnchor),
button.trailingAnchor.constraint(equalTo: trailingAnchor),
button.topAnchor.constraint(equalTo: topAnchor),
button.bottomAnchor.constraint(equalTo: bottomAnchor),
imageView.heightAnchor.constraint(equalTo: innerStackView.heightAnchor),
imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor)
])
}
}

View File

@ -20,12 +20,7 @@ class StatusView: UIView {
@IBOutlet weak var favoriteButton: UIButton!
@IBOutlet weak var shareButton: UIButton!
@IBOutlet weak var attachmentsView: AttachmentsView!
@IBOutlet weak var cardView: UIView!
@IBOutlet weak var cardImageView: UIImageView!
@IBOutlet weak var cardTitleLabel: UILabel!
@IBOutlet weak var cardDescriptionLabel: UILabel!
@IBOutlet weak var cardURLLabel: UILabel!
@IBOutlet weak var cardButton: UIButton!
@IBOutlet weak var cardView: CardView!
@IBOutlet weak var sensitiveContentView: UIStackView!
@IBOutlet weak var hasReplyFollowingView: UIView!
@IBOutlet weak var inReplyToView: UIView!
@ -86,7 +81,6 @@ extension StatusView: UIContentView {
avatarImageView.kf.cancelDownloadTask()
contextParentAvatarImageView.kf.cancelDownloadTask()
cardImageView.kf.cancelDownloadTask()
applyStatusConfiguration()
}
}
@ -135,13 +129,11 @@ private extension StatusView {
avatarImageView.kf.indicatorType = .activity
contextParentAvatarImageView.kf.indicatorType = .activity
cardImageView.kf.indicatorType = .activity
contentTextView.delegate = self
let highlightedButtonBackgroundImage = UIColor(white: 0, alpha: 0.5).image()
cardButton.setBackgroundImage(highlightedButtonBackgroundImage, for: .highlighted)
avatarButton.setBackgroundImage(highlightedButtonBackgroundImage, for: .highlighted)
contextParentAvatarButton.setBackgroundImage(highlightedButtonBackgroundImage, for: .highlighted)
@ -150,6 +142,17 @@ private extension StatusView {
avatarButton.addAction(accountAction, for: .touchUpInside)
contextParentAvatarButton.addAction(accountAction, for: .touchUpInside)
cardView.button.addAction(
UIAction { [weak self] _ in
guard
let viewModel = self?.statusConfiguration.viewModel,
let url = viewModel.cardViewModel?.url
else { return }
viewModel.urlSelected(url)
},
for: .touchUpInside)
let favoriteAction = UIAction { [weak self] _ in self?.statusConfiguration.viewModel.toggleFavorited() }
favoriteButton.addAction(favoriteAction, for: .touchUpInside)
@ -287,29 +290,8 @@ private extension StatusView {
attachmentsView.attachmentViewModels = viewModel.attachmentViewModels
setNeedsLayout()
if let cardURL = viewModel.cardURL {
cardTitleLabel.text = viewModel.cardTitle
cardDescriptionLabel.text = viewModel.cardDescription
cardDescriptionLabel.isHidden = cardDescriptionLabel.text == ""
|| cardDescriptionLabel.text == cardTitleLabel.text
if
let host = cardURL.host, host.hasPrefix("www."),
let withoutWww = cardURL.host?.components(separatedBy: "www.").last {
cardURLLabel.text = withoutWww
} else {
cardURLLabel.text = cardURL.host
}
if let cardImageURL = viewModel.cardImageURL {
cardImageView.isHidden = false
cardImageView.kf.setImage(with: cardImageURL)
} else {
cardImageView.isHidden = true
}
cardView.isHidden = false
} else {
cardView.isHidden = true
}
cardView.viewModel = viewModel.cardViewModel
cardView.isHidden = viewModel.cardViewModel == nil
sensitiveContentView.isHidden = !viewModel.shouldDisplaySensitiveContent

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17124"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -18,11 +18,6 @@
<outlet property="avatarImageView" destination="5nP-eN-kWB" id="uxB-BV-s8N"/>
<outlet property="avatarReplyContextView" destination="H9l-Fc-4W4" id="gqR-14-5D9"/>
<outlet property="baseView" destination="iN0-l3-epB" id="Uv8-kN-29p"/>
<outlet property="cardButton" destination="0dd-dr-kRv" id="1I9-dk-IwM"/>
<outlet property="cardDescriptionLabel" destination="ad9-Cs-OwJ" id="H9s-3b-3ip"/>
<outlet property="cardImageView" destination="kdP-9H-oGY" id="T4H-1P-Dv8"/>
<outlet property="cardTitleLabel" destination="RDi-25-Ez4" id="VMN-AS-4Dy"/>
<outlet property="cardURLLabel" destination="pJj-LK-GQa" id="29l-Da-gSK"/>
<outlet property="cardView" destination="3dp-0a-Tpx" id="HnM-qF-c1Q"/>
<outlet property="contentTextView" destination="hxc-Pn-Vwz" id="VpV-ct-ngH"/>
<outlet property="contextParentAccountLabel" destination="8eU-OP-ovw" id="ovL-ho-3QQ"/>
@ -72,19 +67,19 @@
<rect key="frame" x="0.0" y="0.0" width="50" height="864"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="arrow.2.squarepath" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="aO2-AK-zwO">
<rect key="frame" x="29.5" y="-7.5" width="20.5" height="14.5"/>
<rect key="frame" x="29.5" y="-0.5" width="20.5" height="15"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="small"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gwb-UL-Eqa">
<rect key="frame" x="24" y="0.0" width="2" height="12"/>
<rect key="frame" x="24" y="0.0" width="2" height="26.5"/>
<color key="backgroundColor" systemColor="quaternaryLabelColor"/>
<constraints>
<constraint firstAttribute="width" constant="2" id="CTo-LC-S4B"/>
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5nP-eN-kWB" customClass="AnimatedImageView" customModule="Kingfisher">
<rect key="frame" x="0.0" y="12" width="50" height="50"/>
<rect key="frame" x="0.0" y="26.5" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="MOY-NI-L3C"/>
<constraint firstAttribute="width" constant="50" id="dHx-9Y-qH0"/>
@ -96,7 +91,7 @@
</userDefinedRuntimeAttributes>
</imageView>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xr7-Jl-psM">
<rect key="frame" x="0.0" y="12" width="50" height="50"/>
<rect key="frame" x="0.0" y="26.5" width="50" height="50"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="25"/>
@ -104,7 +99,7 @@
</userDefinedRuntimeAttributes>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EJV-En-WBg">
<rect key="frame" x="24" y="62" width="2" height="802"/>
<rect key="frame" x="24" y="76.5" width="2" height="787.5"/>
<color key="backgroundColor" systemColor="quaternaryLabelColor"/>
<constraints>
<constraint firstAttribute="width" constant="2" id="cPl-wP-HET"/>
@ -130,31 +125,31 @@
<rect key="frame" x="58" y="0.0" width="478" height="864"/>
<subviews>
<stackView opaque="NO" contentMode="top" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="0RV-3u-4W7">
<rect key="frame" x="0.0" y="0.0" width="478" height="82"/>
<rect key="frame" x="0.0" y="0.0" width="478" height="167"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FMa-fP-vr2">
<rect key="frame" x="0.0" y="0.0" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="478" height="14.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="svp-hj-Xn6">
<rect key="frame" x="0.0" y="8" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="22.5" width="478" height="18"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8mm-Xw-oKi">
<rect key="frame" x="0.0" y="0.0" width="43.5" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="43.5" height="18"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NMr-1N-vQB">
<rect key="frame" x="47.5" y="0.0" width="389" height="0.0"/>
<rect key="frame" x="47.5" y="0.0" width="389" height="18"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="752" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FEN-6u-xs5">
<rect key="frame" x="440.5" y="0.0" width="37.5" height="0.0"/>
<rect key="frame" x="440.5" y="0.0" width="37.5" height="18"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
@ -162,7 +157,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="JJo-vZ-2Ei">
<rect key="frame" x="0.0" y="16" width="478" height="50"/>
<rect key="frame" x="0.0" y="48.5" width="478" height="50"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="G9w-4E-gst">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
@ -220,13 +215,13 @@
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Gq-2q-Cvx">
<rect key="frame" x="0.0" y="74" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="106.5" width="478" height="19.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCallout"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XqE-Oj-oxH">
<rect key="frame" x="0.0" y="82" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="134" width="478" height="33"/>
<color key="backgroundColor" systemColor="linkColor"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<state key="normal" title="Show More">
@ -236,7 +231,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="749" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="BXI-3E-NWh">
<rect key="frame" x="0.0" y="90" width="478" height="712.5"/>
<rect key="frame" x="0.0" y="175" width="478" height="549.5"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="751" scrollEnabled="NO" editable="NO" text="Content" textAlignment="natural" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hxc-Pn-Vwz" customClass="TouchFallthroughTextView" customModule="Metatext" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="478" height="37"/>
@ -249,72 +244,16 @@
<constraint firstAttribute="width" secondItem="diz-eN-CAY" secondAttribute="height" multiplier="16:9" priority="999" id="yvF-tL-A5X"/>
</constraints>
</view>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3dp-0a-Tpx">
<rect key="frame" x="0.0" y="322" width="478" height="390.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="InD-Bl-xMp">
<rect key="frame" x="0.0" y="0.0" width="478" height="390.5"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="kdP-9H-oGY">
<rect key="frame" x="0.0" y="0.0" width="478" height="358.5"/>
<constraints>
<constraint firstAttribute="width" secondItem="kdP-9H-oGY" secondAttribute="height" multiplier="4:3" priority="999" id="Pi5-Mu-x9m"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="6GY-Bg-957">
<rect key="frame" x="0.0" y="358.5" width="478" height="32"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RDi-25-Ez4">
<rect key="frame" x="8" y="8" width="462" height="0.0"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ad9-Cs-OwJ">
<rect key="frame" x="8" y="16" width="462" height="0.0"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pJj-LK-GQa">
<rect key="frame" x="8" y="24" width="462" height="0.0"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<directionalEdgeInsets key="directionalLayoutMargins" top="8" leading="8" bottom="8" trailing="8"/>
</stackView>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0dd-dr-kRv">
<rect key="frame" x="0.0" y="0.0" width="478" height="390.5"/>
</button>
</subviews>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="InD-Bl-xMp" secondAttribute="bottom" id="9sj-tg-MDu"/>
<constraint firstAttribute="bottom" secondItem="0dd-dr-kRv" secondAttribute="bottom" id="EJ1-Fe-4Hk"/>
<constraint firstAttribute="trailing" secondItem="0dd-dr-kRv" secondAttribute="trailing" id="F5A-mO-hup"/>
<constraint firstItem="0dd-dr-kRv" firstAttribute="top" secondItem="3dp-0a-Tpx" secondAttribute="top" id="Gif-tV-8yk"/>
<constraint firstItem="InD-Bl-xMp" firstAttribute="leading" secondItem="3dp-0a-Tpx" secondAttribute="leading" id="TkA-DT-C7q"/>
<constraint firstAttribute="trailing" secondItem="InD-Bl-xMp" secondAttribute="trailing" id="bsr-QN-via"/>
<constraint firstItem="InD-Bl-xMp" firstAttribute="top" secondItem="3dp-0a-Tpx" secondAttribute="top" id="pwn-1Y-2kG"/>
<constraint firstItem="0dd-dr-kRv" firstAttribute="leading" secondItem="3dp-0a-Tpx" secondAttribute="leading" id="vJZ-Qe-3zt"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3dp-0a-Tpx" customClass="CardView" customModule="Metatext" customModuleProvider="target">
<rect key="frame" x="0.0" y="322" width="478" height="227.5"/>
</view>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="zJg-bJ-uzd">
<rect key="frame" x="0.0" y="810.5" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="732.5" width="478" height="18.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="251" contentHorizontalAlignment="leading" contentVerticalAlignment="center" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6HD-MP-H72">
<rect key="frame" x="0.0" y="0.0" width="119.5" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="119.5" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<inset key="titleEdgeInsets" minX="4" minY="0.0" maxX="0.0" maxY="0.0"/>
@ -324,7 +263,7 @@
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="251" contentHorizontalAlignment="leading" contentVerticalAlignment="center" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZKl-Hp-Y42">
<rect key="frame" x="119.5" y="0.0" width="119.5" height="0.0"/>
<rect key="frame" x="119.5" y="0.0" width="119.5" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<inset key="titleEdgeInsets" minX="4" minY="0.0" maxX="0.0" maxY="0.0"/>
@ -334,7 +273,7 @@
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="251" contentHorizontalAlignment="leading" contentVerticalAlignment="center" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ewo-qO-lvX">
<rect key="frame" x="239" y="0.0" width="119.5" height="0.0"/>
<rect key="frame" x="239" y="0.0" width="119.5" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<inset key="titleEdgeInsets" minX="4" minY="0.0" maxX="0.0" maxY="0.0"/>
@ -344,7 +283,7 @@
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zAD-2Z-vhu">
<rect key="frame" x="358.5" y="0.0" width="119.5" height="0.0"/>
<rect key="frame" x="358.5" y="0.0" width="119.5" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" image="square.and.arrow.up" catalog="system">
@ -355,25 +294,25 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="dcp-zF-sHI">
<rect key="frame" x="0.0" y="818.5" width="478" height="45.5"/>
<rect key="frame" x="0.0" y="759" width="478" height="105"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="hTG-pM-6Kn">
<rect key="frame" x="0.0" y="0.0" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="478" height="16"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6Fo-vD-qjJ">
<rect key="frame" x="0.0" y="0.0" width="33" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="33" height="16"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="•" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hYj-vy-Net">
<rect key="frame" x="37" y="0.0" width="6.5" height="0.0"/>
<rect key="frame" x="37" y="0.0" width="6.5" height="16"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="leading" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rdt-TR-8S5">
<rect key="frame" x="47.5" y="0.0" width="430.5" height="0.0"/>
<rect key="frame" x="47.5" y="0.0" width="430.5" height="16"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<state key="normal" title="Button"/>
<state key="disabled">
@ -383,17 +322,17 @@
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4eO-Vd-vy5">
<rect key="frame" x="0.0" y="8" width="478" height="1"/>
<rect key="frame" x="0.0" y="24" width="478" height="1"/>
<color key="backgroundColor" systemColor="separatorColor"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="H9G-jZ-cek"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="M1E-qU-AAW">
<rect key="frame" x="0.0" y="17" width="478" height="0.0"/>
<rect key="frame" x="0.0" y="33" width="478" height="33"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="leading" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OaH-fg-fwa">
<rect key="frame" x="0.0" y="0.0" width="239" height="0.0"/>
<rect key="frame" x="0.0" y="0.0" width="239" height="33"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" title="1">
@ -404,7 +343,7 @@
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="leading" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dCB-Ba-lgt">
<rect key="frame" x="239" y="0.0" width="239" height="0.0"/>
<rect key="frame" x="239" y="0.0" width="239" height="33"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<state key="normal" title="1">
<color key="titleColor" systemColor="secondaryLabelColor"/>
@ -416,45 +355,45 @@
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zAt-7g-Zg4">
<rect key="frame" x="0.0" y="25" width="478" height="1"/>
<rect key="frame" x="0.0" y="74" width="478" height="1"/>
<color key="backgroundColor" systemColor="separatorColor"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="VEz-6j-37B"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="3d0-Jf-WT4">
<rect key="frame" x="0.0" y="34" width="478" height="11.5"/>
<rect key="frame" x="0.0" y="83" width="478" height="22"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="v8s-eL-K9J">
<rect key="frame" x="0.0" y="0.0" width="89" height="11.5"/>
<rect key="frame" x="0.0" y="0.0" width="89" height="22"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" image="bubble.right" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="medium"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="c9q-Xj-ZhU">
<rect key="frame" x="97" y="0.0" width="89.5" height="11.5"/>
<rect key="frame" x="97" y="0.0" width="89.5" height="22"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" image="arrow.2.squarepath" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="medium"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vKK-ho-Mc8">
<rect key="frame" x="194.5" y="0.0" width="89" height="11.5"/>
<rect key="frame" x="194.5" y="0.0" width="89" height="22"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" image="star" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="medium"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jXx-KF-3pu">
<rect key="frame" x="291.5" y="0.0" width="89.5" height="11.5"/>
<rect key="frame" x="291.5" y="0.0" width="89.5" height="22"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" image="square.and.arrow.up" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="medium"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fN1-ao-eiV">
<rect key="frame" x="389" y="0.0" width="89" height="11.5"/>
<rect key="frame" x="389" y="0.0" width="89" height="22"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<state key="normal" image="ellipsis" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="medium"/>
@ -502,9 +441,6 @@
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="secondarySystemBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="separatorColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>

13
Views/ViewConstants.swift Normal file
View File

@ -0,0 +1,13 @@
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
extension CGFloat {
static let defaultSpacing: Self = 8
static let compactSpacing: Self = 4
static let defaultCornerRadius: Self = 8
}
extension UIImage {
static let highlightedButtonBackground = UIColor(white: 0, alpha: 0.5).image()
}