зеркало из https://github.com/nextcloud/talk-ios.git
Add giphy integration support for references
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Родитель
e33f14a81e
Коммит
a4f3b7ace1
|
@ -255,6 +255,8 @@
|
|||
1FC940BA2A5F21FD00FFFADE /* SwiftMarkdownObjCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0A1D432A5F1FA800A25433 /* SwiftMarkdownObjCBridge.swift */; };
|
||||
1FCE3D532C9B5918009C68A9 /* SwiftyGif in Frameworks */ = {isa = PBXBuildFile; productRef = 1FCE3D522C9B5918009C68A9 /* SwiftyGif */; };
|
||||
1FCE3D552C9C189D009C68A9 /* NCChatFileControllerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FCE3D542C9C189D009C68A9 /* NCChatFileControllerWrapper.swift */; };
|
||||
1FCE3D572C9C4D18009C68A9 /* ReferenceGiphyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FCE3D562C9C4D18009C68A9 /* ReferenceGiphyView.swift */; };
|
||||
1FCE3D592C9C4D21009C68A9 /* ReferenceGiphyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1FCE3D582C9C4D21009C68A9 /* ReferenceGiphyView.xib */; };
|
||||
1FD6F83C2B825069004048AB /* NCRoomsManagerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD6F83B2B825069004048AB /* NCRoomsManagerExtensions.swift */; };
|
||||
1FD6F83E2B87B712004048AB /* NCUserStatusExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD6F83D2B87B712004048AB /* NCUserStatusExtensions.swift */; };
|
||||
1FD8AE6B2A3A216300787C16 /* UIRoomTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8AD8C2A3A162100787C16 /* UIRoomTest.swift */; };
|
||||
|
@ -784,6 +786,8 @@
|
|||
1FBC3BE42B61ACD5003909E0 /* UnitBaseChatViewControllerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnitBaseChatViewControllerTest.swift; sourceTree = "<group>"; };
|
||||
1FBC3BE82B61BD09003909E0 /* TestBaseRealm.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestBaseRealm.swift; sourceTree = "<group>"; };
|
||||
1FCE3D542C9C189D009C68A9 /* NCChatFileControllerWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCChatFileControllerWrapper.swift; sourceTree = "<group>"; };
|
||||
1FCE3D562C9C4D18009C68A9 /* ReferenceGiphyView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReferenceGiphyView.swift; sourceTree = "<group>"; };
|
||||
1FCE3D582C9C4D21009C68A9 /* ReferenceGiphyView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReferenceGiphyView.xib; sourceTree = "<group>"; };
|
||||
1FD6F83B2B825069004048AB /* NCRoomsManagerExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCRoomsManagerExtensions.swift; sourceTree = "<group>"; };
|
||||
1FD6F83D2B87B712004048AB /* NCUserStatusExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCUserStatusExtensions.swift; sourceTree = "<group>"; };
|
||||
1FD8AD8A2A3A162100787C16 /* NextcloudTalkUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudTalkUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -1343,6 +1347,8 @@
|
|||
1FDE7C9B28DE14B000CB718E /* ReferenceView.xib */,
|
||||
1F46CE2828E05B3200E7D88E /* ReferenceDefaultView.swift */,
|
||||
1F46CE2A28E05B3C00E7D88E /* ReferenceDefaultView.xib */,
|
||||
1FCE3D562C9C4D18009C68A9 /* ReferenceGiphyView.swift */,
|
||||
1FCE3D582C9C4D21009C68A9 /* ReferenceGiphyView.xib */,
|
||||
1F24B5A128E0648600654457 /* ReferenceGithubView.swift */,
|
||||
1F24B5A328E0649200654457 /* ReferenceGithubView.xib */,
|
||||
1FFF41612C70937B00162F4D /* ReferenceZammadView.swift */,
|
||||
|
@ -2448,6 +2454,7 @@
|
|||
2C330372255E6EBC00BDB4E4 /* InfoPlist.strings in Resources */,
|
||||
2C78EFA11F828C41008AFA74 /* CallViewController.xib in Resources */,
|
||||
2C3780C5210F4A26003F9AE8 /* HeaderWithButton.xib in Resources */,
|
||||
1FCE3D592C9C4D21009C68A9 /* ReferenceGiphyView.xib in Resources */,
|
||||
2C7F47AA20289B9600081CC7 /* Localizable.strings in Resources */,
|
||||
2CB997C62A052449003C41AC /* EmojiAvatarPickerViewController.xib in Resources */,
|
||||
2C0574A51EDDA2E300D9E7F2 /* LoginViewController.xib in Resources */,
|
||||
|
@ -2989,6 +2996,7 @@
|
|||
2C4446D32658147900DF1DBC /* TalkAccount.m in Sources */,
|
||||
2CA1CCD61F1E664C002FE6A2 /* ContactsTableViewCell.m in Sources */,
|
||||
1F77A6172AB9B161007B6037 /* ScreenCapturer.m in Sources */,
|
||||
1FCE3D572C9C4D18009C68A9 /* ReferenceGiphyView.swift in Sources */,
|
||||
1FFF41622C70937B00162F4D /* ReferenceZammadView.swift in Sources */,
|
||||
1F98DF9C28E7484700E05174 /* ReferenceDeckView.swift in Sources */,
|
||||
DA66582F27B6B19C00B46B11 /* UserProfileTableViewController+Actions.swift in Sources */,
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers class ReferenceGiphyView: UIView {
|
||||
|
||||
@IBOutlet var contentView: UIView!
|
||||
@IBOutlet weak var referenceThumbnailView: UIImageView!
|
||||
@IBOutlet weak var referenceName: UILabel!
|
||||
@IBOutlet weak var referenceDescription: UITextView!
|
||||
@IBOutlet weak var referenceLink: UILabel!
|
||||
|
||||
var url: String?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
func commonInit() {
|
||||
Bundle.main.loadNibNamed("ReferenceDefaultView", owner: self, options: nil)
|
||||
contentView.frame = self.bounds
|
||||
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
|
||||
referenceName.text = ""
|
||||
referenceDescription.text = ""
|
||||
referenceLink.text = ""
|
||||
|
||||
// Remove padding from textView
|
||||
referenceDescription.textContainerInset = .zero
|
||||
referenceDescription.textContainer.lineFragmentPadding = .zero
|
||||
|
||||
referenceThumbnailView.layer.cornerRadius = 8.0
|
||||
referenceThumbnailView.layer.masksToBounds = true
|
||||
|
||||
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap))
|
||||
contentView.addGestureRecognizer(tap)
|
||||
|
||||
self.addSubview(contentView)
|
||||
}
|
||||
|
||||
func handleTap() {
|
||||
if let url = url {
|
||||
NCUtils.openLinkInBrowser(link: url)
|
||||
}
|
||||
}
|
||||
|
||||
func update(for reference: [String: AnyObject], and url: String) {
|
||||
self.url = url
|
||||
|
||||
referenceName.text = reference["title"] as? String ?? ""
|
||||
referenceDescription.text = reference["alt_text"] as? String ?? ""
|
||||
referenceLink.text = url
|
||||
|
||||
if referenceDescription.text.isEmpty {
|
||||
referenceDescription.isHidden = true
|
||||
}
|
||||
|
||||
if let proxiedUrlString = reference["proxied_url"] as? String, let proxiedUrl = URL(string: proxiedUrlString) {
|
||||
referenceThumbnailView.setGifFromURL(proxiedUrl)
|
||||
} else {
|
||||
setPlaceholderThumbnail()
|
||||
}
|
||||
}
|
||||
|
||||
func setPlaceholderThumbnail() {
|
||||
referenceThumbnailView.image = UIImage(systemName: "safari")?.withTintColor(UIColor.secondarySystemFill, renderingMode: .alwaysOriginal)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="dark"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ReferenceGiphyView" customModule="NextcloudTalk" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="contentView" destination="iN0-l3-epB" id="I1C-wk-7lp"/>
|
||||
<outlet property="referenceDescription" destination="PAt-pa-feD" id="623-d2-v8S"/>
|
||||
<outlet property="referenceLink" destination="3ya-yo-pxr" id="P0s-b2-AjA"/>
|
||||
<outlet property="referenceName" destination="Iby-r5-06p" id="s4c-fP-l69"/>
|
||||
<outlet property="referenceThumbnailView" destination="2GP-6u-K9h" id="RFy-wh-Tkw"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="615" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="2GP-6u-K9h">
|
||||
<rect key="frame" x="10" y="10" width="75" height="80"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES"/>
|
||||
</imageView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="TwV-dN-hY4">
|
||||
<rect key="frame" x="95" y="10" width="510" height="80"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ReferenceName" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="Iby-r5-06p">
|
||||
<rect key="frame" x="0.0" y="0.0" width="510" height="20"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" id="JQE-Y4-q6k"/>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20" id="QFE-e0-spe"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" insetsLayoutMarginsFromSafeArea="NO" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" bouncesZoom="NO" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PAt-pa-feD" userLabel="ReferenceDescription">
|
||||
<rect key="frame" x="0.0" y="20" width="510" height="40"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="10" id="8Vh-Jv-aCb"/>
|
||||
</constraints>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
</textView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ReferenceLink" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3ya-yo-pxr">
|
||||
<rect key="frame" x="0.0" y="60" width="510" height="20"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20" id="QNn-28-pgu"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<color key="textColor" systemColor="linkColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="80" id="DKM-g6-3jd"/>
|
||||
<constraint firstItem="PAt-pa-feD" firstAttribute="top" secondItem="Iby-r5-06p" secondAttribute="bottom" id="PcQ-Px-j8e"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="pL6-X3-vgG"/>
|
||||
</constraints>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="TwV-dN-hY4" secondAttribute="trailing" constant="10" id="0Ky-Bd-RkR"/>
|
||||
<constraint firstItem="TwV-dN-hY4" firstAttribute="leading" secondItem="2GP-6u-K9h" secondAttribute="trailing" constant="10" id="0Zh-gE-cVJ"/>
|
||||
<constraint firstAttribute="bottom" secondItem="TwV-dN-hY4" secondAttribute="bottom" constant="10" id="MnZ-ek-N34"/>
|
||||
<constraint firstItem="TwV-dN-hY4" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="cov-z5-MxE"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<point key="canvasLocation" x="-95" y="-30"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<systemColor name="linkColor">
|
||||
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="secondaryLabelColor">
|
||||
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
|
@ -144,6 +144,16 @@ class ReferenceView: UIView {
|
|||
|
||||
referenceView.addSubview(talkView)
|
||||
foundReferenceView = true
|
||||
} else if richObjectType == "integration_giphy_gif",
|
||||
let reference = firstReference["richObject"] as? [String: AnyObject] {
|
||||
|
||||
let giphyView = ReferenceGiphyView(frame: self.frame)
|
||||
giphyView.update(for: reference, and: url)
|
||||
giphyView.frame = self.bounds
|
||||
giphyView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
|
||||
referenceView.addSubview(giphyView)
|
||||
foundReferenceView = true
|
||||
} else if let reference = firstReference["openGraphObject"] as? [String: String?] {
|
||||
let defaultView = ReferenceDefaultView(frame: self.frame)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче