Make link preview cards larger
This commit is contained in:
parent
23a4999196
commit
907810d98a
|
@ -102,9 +102,9 @@
|
||||||
</textView>
|
</textView>
|
||||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QqC-GR-TLC" customClass="StatusCardView" customModule="Tusker" customModuleProvider="target">
|
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QqC-GR-TLC" customClass="StatusCardView" customModule="Tusker" customModuleProvider="target">
|
||||||
<rect key="frame" x="0.0" y="131" width="361" height="0.0"/>
|
<rect key="frame" x="0.0" y="131" width="361" height="0.0"/>
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" priority="999" constant="65" id="Tdo-Hv-ITE"/>
|
<constraint firstAttribute="height" priority="999" constant="90" id="Tdo-Hv-ITE"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IF9-9U-Gk0" customClass="AttachmentsContainerView" customModule="Tusker" customModuleProvider="target">
|
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IF9-9U-Gk0" customClass="AttachmentsContainerView" customModule="Tusker" customModuleProvider="target">
|
||||||
|
|
|
@ -25,8 +25,10 @@ class StatusCardView: UIView {
|
||||||
private var imageRequest: ImageCache.Request?
|
private var imageRequest: ImageCache.Request?
|
||||||
private var isGrayscale = false
|
private var isGrayscale = false
|
||||||
|
|
||||||
|
private var hStack: UIStackView!
|
||||||
private var titleLabel: UILabel!
|
private var titleLabel: UILabel!
|
||||||
private var descriptionLabel: UILabel!
|
private var descriptionLabel: UILabel!
|
||||||
|
private var domainLabel: UILabel!
|
||||||
private var imageView: UIImageView!
|
private var imageView: UIImageView!
|
||||||
private var placeholderImageView: UIImageView!
|
private var placeholderImageView: UIImageView!
|
||||||
|
|
||||||
|
@ -41,11 +43,13 @@ class StatusCardView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func commonInit() {
|
private func commonInit() {
|
||||||
self.clipsToBounds = true
|
// self.clipsToBounds = true
|
||||||
self.layer.cornerRadius = 6.5
|
// self.layer.borderWidth = 0.5
|
||||||
self.layer.borderWidth = 1
|
// self.layer.borderColor = UIColor.lightGray.cgColor
|
||||||
self.layer.borderColor = UIColor.lightGray.cgColor
|
self.layer.shadowColor = UIColor.black.cgColor
|
||||||
self.backgroundColor = inactiveBackgroundColor
|
self.layer.shadowRadius = 5
|
||||||
|
self.layer.shadowOpacity = 0.2
|
||||||
|
self.layer.shadowOffset = .zero
|
||||||
|
|
||||||
self.addInteraction(UIContextMenuInteraction(delegate: self))
|
self.addInteraction(UIContextMenuInteraction(delegate: self))
|
||||||
|
|
||||||
|
@ -60,9 +64,16 @@ class StatusCardView: UIView {
|
||||||
descriptionLabel.numberOfLines = 2
|
descriptionLabel.numberOfLines = 2
|
||||||
descriptionLabel.setContentCompressionResistancePriority(.defaultLow, for: .vertical)
|
descriptionLabel.setContentCompressionResistancePriority(.defaultLow, for: .vertical)
|
||||||
|
|
||||||
|
domainLabel = UILabel()
|
||||||
|
domainLabel.font = .preferredFont(forTextStyle: .caption2)
|
||||||
|
domainLabel.adjustsFontForContentSizeCategory = true
|
||||||
|
domainLabel.numberOfLines = 1
|
||||||
|
domainLabel.textColor = .tintColor
|
||||||
|
|
||||||
let vStack = UIStackView(arrangedSubviews: [
|
let vStack = UIStackView(arrangedSubviews: [
|
||||||
titleLabel,
|
titleLabel,
|
||||||
descriptionLabel
|
descriptionLabel,
|
||||||
|
domainLabel,
|
||||||
])
|
])
|
||||||
vStack.axis = .vertical
|
vStack.axis = .vertical
|
||||||
vStack.alignment = .leading
|
vStack.alignment = .leading
|
||||||
|
@ -73,15 +84,23 @@ class StatusCardView: UIView {
|
||||||
imageView.contentMode = .scaleAspectFill
|
imageView.contentMode = .scaleAspectFill
|
||||||
imageView.clipsToBounds = true
|
imageView.clipsToBounds = true
|
||||||
|
|
||||||
let hStack = UIStackView(arrangedSubviews: [
|
let spacer = UIView()
|
||||||
|
spacer.backgroundColor = .clear
|
||||||
|
|
||||||
|
hStack = UIStackView(arrangedSubviews: [
|
||||||
imageView,
|
imageView,
|
||||||
vStack
|
vStack,
|
||||||
|
spacer,
|
||||||
])
|
])
|
||||||
hStack.translatesAutoresizingMaskIntoConstraints = false
|
hStack.translatesAutoresizingMaskIntoConstraints = false
|
||||||
hStack.axis = .horizontal
|
hStack.axis = .horizontal
|
||||||
hStack.alignment = .center
|
hStack.alignment = .center
|
||||||
hStack.distribution = .fill
|
hStack.distribution = .fill
|
||||||
hStack.spacing = 4
|
hStack.spacing = 4
|
||||||
|
hStack.clipsToBounds = true
|
||||||
|
hStack.layer.borderWidth = 0.5
|
||||||
|
hStack.layer.borderColor = UIColor.lightGray.cgColor
|
||||||
|
hStack.backgroundColor = inactiveBackgroundColor
|
||||||
|
|
||||||
addSubview(hStack)
|
addSubview(hStack)
|
||||||
|
|
||||||
|
@ -98,8 +117,10 @@ class StatusCardView: UIView {
|
||||||
|
|
||||||
vStack.heightAnchor.constraint(equalTo: heightAnchor, constant: -8),
|
vStack.heightAnchor.constraint(equalTo: heightAnchor, constant: -8),
|
||||||
|
|
||||||
|
spacer.widthAnchor.constraint(equalToConstant: 4),
|
||||||
|
|
||||||
hStack.leadingAnchor.constraint(equalTo: leadingAnchor),
|
hStack.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||||
hStack.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -4),
|
hStack.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||||
hStack.topAnchor.constraint(equalTo: topAnchor),
|
hStack.topAnchor.constraint(equalTo: topAnchor),
|
||||||
hStack.bottomAnchor.constraint(equalTo: bottomAnchor),
|
hStack.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||||
|
|
||||||
|
@ -112,6 +133,11 @@ class StatusCardView: UIView {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
hStack.layer.cornerRadius = 0.1 * bounds.height
|
||||||
|
}
|
||||||
|
|
||||||
func updateUI(status: StatusMO) {
|
func updateUI(status: StatusMO) {
|
||||||
guard status.id != statusID else {
|
guard status.id != statusID else {
|
||||||
return
|
return
|
||||||
|
@ -135,6 +161,13 @@ class StatusCardView: UIView {
|
||||||
let description = card.description.trimmingCharacters(in: .whitespacesAndNewlines)
|
let description = card.description.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
descriptionLabel.text = description
|
descriptionLabel.text = description
|
||||||
descriptionLabel.isHidden = description.isEmpty
|
descriptionLabel.isHidden = description.isEmpty
|
||||||
|
|
||||||
|
if let host = card.url.host {
|
||||||
|
domainLabel.text = host.serialized
|
||||||
|
domainLabel.isHidden = false
|
||||||
|
} else {
|
||||||
|
domainLabel.isHidden = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func updateUIForPreferences() {
|
@objc private func updateUIForPreferences() {
|
||||||
|
@ -201,7 +234,7 @@ class StatusCardView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
backgroundColor = activeBackgroundColor
|
hStack.backgroundColor = activeBackgroundColor
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +242,7 @@ class StatusCardView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
backgroundColor = inactiveBackgroundColor
|
hStack.backgroundColor = inactiveBackgroundColor
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
|
|
||||||
if let card = card, let delegate = navigationDelegate {
|
if let card = card, let delegate = navigationDelegate {
|
||||||
|
@ -218,7 +251,7 @@ class StatusCardView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
backgroundColor = inactiveBackgroundColor
|
hStack.backgroundColor = inactiveBackgroundColor
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +271,12 @@ extension StatusCardView: UIContextMenuInteractionDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForHighlightingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
||||||
|
let params = UIPreviewParameters()
|
||||||
|
params.visiblePath = UIBezierPath(roundedRect: hStack.bounds, cornerRadius: hStack.layer.cornerRadius)
|
||||||
|
return UITargetedPreview(view: hStack, parameters: params)
|
||||||
|
}
|
||||||
|
|
||||||
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
||||||
if let viewController = animator.previewViewController,
|
if let viewController = animator.previewViewController,
|
||||||
let delegate = navigationDelegate {
|
let delegate = navigationDelegate {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class StatusContentContainer: UIView {
|
||||||
|
|
||||||
let cardView = StatusCardView().configure {
|
let cardView = StatusCardView().configure {
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
$0.heightAnchor.constraint(equalToConstant: 65),
|
$0.heightAnchor.constraint(equalToConstant: 90),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,9 +132,9 @@
|
||||||
</textView>
|
</textView>
|
||||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LKo-VB-XWl" customClass="StatusCardView" customModule="Tusker" customModuleProvider="target">
|
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LKo-VB-XWl" customClass="StatusCardView" customModule="Tusker" customModuleProvider="target">
|
||||||
<rect key="frame" x="0.0" y="200.5" width="295" height="0.0"/>
|
<rect key="frame" x="0.0" y="200.5" width="295" height="0.0"/>
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" priority="999" constant="65" id="khY-jm-CPn"/>
|
<constraint firstAttribute="height" priority="999" constant="90" id="khY-jm-CPn"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
<view hidden="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1" translatesAutoresizingMaskIntoConstraints="NO" id="nbq-yr-2mA" customClass="AttachmentsContainerView" customModule="Tusker" customModuleProvider="target">
|
<view hidden="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1" translatesAutoresizingMaskIntoConstraints="NO" id="nbq-yr-2mA" customClass="AttachmentsContainerView" customModule="Tusker" customModuleProvider="target">
|
||||||
|
|
Loading…
Reference in New Issue