mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 19:10:49 +02:00
Room timeline: Move files in explicit folders.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// 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 Foundation
|
||||
import Reusable
|
||||
|
||||
@objcMembers
|
||||
class FromAThreadView: UIView {
|
||||
|
||||
private enum Constants {
|
||||
static let viewHeight: CGFloat = 18
|
||||
}
|
||||
|
||||
@IBOutlet private weak var iconView: UIImageView!
|
||||
@IBOutlet private weak var titleLabel: UILabel!
|
||||
|
||||
static func contentViewHeight(forEvent event: MXEvent,
|
||||
fitting maxWidth: CGFloat) -> CGFloat {
|
||||
return Constants.viewHeight
|
||||
}
|
||||
|
||||
static func instantiate() -> FromAThreadView {
|
||||
let view = FromAThreadView.loadFromNib()
|
||||
view.update(theme: ThemeService.shared().theme)
|
||||
view.titleLabel.text = VectorL10n.messageFromAThread
|
||||
return view
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension FromAThreadView: NibLoadable {}
|
||||
|
||||
extension FromAThreadView: Themable {
|
||||
|
||||
func update(theme: Theme) {
|
||||
backgroundColor = .clear
|
||||
iconView.tintColor = theme.colors.secondaryContent
|
||||
titleLabel.textColor = theme.colors.secondaryContent
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
|
||||
<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"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="FromAThreadView" customModule="Riot" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="139" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="gZf-Nh-De6">
|
||||
<rect key="frame" x="0.0" y="0.0" width="139" height="18"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="threads_icon" translatesAutoresizingMaskIntoConstraints="NO" id="cdy-fz-kjn">
|
||||
<rect key="frame" x="0.0" y="0.0" width="18" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="3mH-It-De7"/>
|
||||
<constraint firstAttribute="width" constant="18" id="Jzw-cL-zxG"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="From a thread" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fX6-Xz-I4e">
|
||||
<rect key="frame" x="22" y="0.0" width="117" height="18"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="13"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="gZf-Nh-De6" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="0Hy-t1-GHo"/>
|
||||
<constraint firstAttribute="trailing" secondItem="gZf-Nh-De6" secondAttribute="trailing" id="ELX-qi-dTm"/>
|
||||
<constraint firstAttribute="bottom" secondItem="gZf-Nh-De6" secondAttribute="bottom" id="Pye-fH-Zny"/>
|
||||
<constraint firstItem="gZf-Nh-De6" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="dWk-cp-fYS"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="iconView" destination="cdy-fz-kjn" id="Kev-ko-oTu"/>
|
||||
<outlet property="titleLabel" destination="fX6-Xz-I4e" id="65X-PJ-RpF"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-119.56521739130436" y="-257.47767857142856"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="threads_icon" width="27" height="28.5"/>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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 Foundation
|
||||
|
||||
struct ThreadSummaryModel {
|
||||
let numberOfReplies: Int
|
||||
let lastMessageSenderAvatar: AvatarViewDataProtocol?
|
||||
let lastMessageText: NSAttributedString?
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// 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 Foundation
|
||||
import Reusable
|
||||
|
||||
@objc
|
||||
protocol ThreadSummaryViewDelegate: AnyObject {
|
||||
func threadSummaryViewTapped(_ summaryView: ThreadSummaryView)
|
||||
}
|
||||
|
||||
/// A view to display a summary for an `MXThread` generated by the `MXThreadingService`.
|
||||
@objcMembers
|
||||
class ThreadSummaryView: UIView {
|
||||
|
||||
private enum Constants {
|
||||
static let viewDefaultWidth: CGFloat = 320
|
||||
static let cornerRadius: CGFloat = 8
|
||||
static let lastMessageFont: UIFont = .systemFont(ofSize: 13)
|
||||
}
|
||||
|
||||
@IBOutlet private weak var iconView: UIImageView!
|
||||
@IBOutlet private weak var numberOfRepliesLabel: UILabel!
|
||||
@IBOutlet private weak var lastMessageAvatarView: UserAvatarView!
|
||||
@IBOutlet private weak var lastMessageContentLabel: UILabel!
|
||||
|
||||
private var theme: Theme = ThemeService.shared().theme
|
||||
private(set) var thread: MXThread?
|
||||
|
||||
private lazy var tapGestureRecognizer: UITapGestureRecognizer = {
|
||||
return UITapGestureRecognizer(target: self, action: #selector(tapped(_:)))
|
||||
}()
|
||||
|
||||
weak var delegate: ThreadSummaryViewDelegate?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(withThread thread: MXThread) {
|
||||
self.thread = thread
|
||||
super.init(frame: CGRect(origin: .zero,
|
||||
size: CGSize(width: Constants.viewDefaultWidth,
|
||||
height: RoomBubbleCellLayout.threadSummaryViewHeight)))
|
||||
loadNibContent()
|
||||
update(theme: ThemeService.shared().theme)
|
||||
configure()
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
static func contentViewHeight(forThread thread: MXThread?, fitting maxWidth: CGFloat) -> CGFloat {
|
||||
return RoomBubbleCellLayout.threadSummaryViewHeight
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
loadNibContent()
|
||||
}
|
||||
|
||||
@nonobjc func configure(withModel model: ThreadSummaryModel) {
|
||||
numberOfRepliesLabel.text = String(model.numberOfReplies)
|
||||
if let avatar = model.lastMessageSenderAvatar {
|
||||
lastMessageAvatarView.fill(with: avatar)
|
||||
} else {
|
||||
lastMessageAvatarView.avatarImageView.image = nil
|
||||
}
|
||||
if let lastMessage = model.lastMessageText {
|
||||
let mutable = NSMutableAttributedString(attributedString: lastMessage)
|
||||
mutable.setAttributes([
|
||||
.font: Constants.lastMessageFont
|
||||
], range: NSRange(location: 0, length: mutable.length))
|
||||
lastMessageContentLabel.attributedText = mutable
|
||||
} else {
|
||||
lastMessageContentLabel.attributedText = nil
|
||||
}
|
||||
}
|
||||
|
||||
private func configure() {
|
||||
clipsToBounds = true
|
||||
layer.cornerRadius = Constants.cornerRadius
|
||||
addGestureRecognizer(tapGestureRecognizer)
|
||||
|
||||
guard let thread = thread,
|
||||
let lastMessage = thread.lastMessage,
|
||||
let session = thread.session,
|
||||
let eventFormatter = session.roomSummaryUpdateDelegate as? MXKEventFormatter,
|
||||
let room = session.room(withRoomId: lastMessage.roomId) else {
|
||||
lastMessageAvatarView.avatarImageView.image = nil
|
||||
lastMessageContentLabel.text = nil
|
||||
return
|
||||
}
|
||||
let lastMessageSender = session.user(withUserId: lastMessage.sender)
|
||||
|
||||
let fallbackImage = AvatarFallbackImage.matrixItem(lastMessage.sender,
|
||||
lastMessageSender?.displayname)
|
||||
let avatarViewData = AvatarViewData(matrixItemId: lastMessage.sender,
|
||||
displayName: lastMessageSender?.displayname,
|
||||
avatarUrl: lastMessageSender?.avatarUrl,
|
||||
mediaManager: session.mediaManager,
|
||||
fallbackImage: fallbackImage)
|
||||
|
||||
room.state { [weak self] roomState in
|
||||
guard let self = self else { return }
|
||||
let formatterError = UnsafeMutablePointer<MXKEventFormatterError>.allocate(capacity: 1)
|
||||
let lastMessageText = eventFormatter.attributedString(from: lastMessage,
|
||||
with: roomState,
|
||||
error: formatterError)
|
||||
|
||||
let model = ThreadSummaryModel(numberOfReplies: thread.numberOfReplies,
|
||||
lastMessageSenderAvatar: avatarViewData,
|
||||
lastMessageText: lastMessageText)
|
||||
self.configure(withModel: model)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Action
|
||||
|
||||
@objc
|
||||
private func tapped(_ sender: UITapGestureRecognizer) {
|
||||
guard thread != nil else { return }
|
||||
delegate?.threadSummaryViewTapped(self)
|
||||
}
|
||||
}
|
||||
|
||||
extension ThreadSummaryView: NibOwnerLoadable {}
|
||||
|
||||
extension ThreadSummaryView: Themable {
|
||||
|
||||
func update(theme: Theme) {
|
||||
self.theme = theme
|
||||
|
||||
backgroundColor = theme.colors.system
|
||||
iconView.tintColor = theme.colors.secondaryContent
|
||||
numberOfRepliesLabel.textColor = theme.colors.secondaryContent
|
||||
lastMessageContentLabel.textColor = theme.colors.secondaryContent
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.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="ThreadSummaryView" customModule="Riot" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="iconView" destination="vva-PV-3Ya" id="e1B-Zp-pni"/>
|
||||
<outlet property="lastMessageAvatarView" destination="9wW-1f-f69" id="xiI-t8-Q56"/>
|
||||
<outlet property="lastMessageContentLabel" destination="DVT-JI-3kw" id="O6N-ev-FRz"/>
|
||||
<outlet property="numberOfRepliesLabel" destination="GcG-W8-9LR" id="hzP-Ea-C6l"/>
|
||||
</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="414" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TFL-sS-eJc">
|
||||
<rect key="frame" x="8" y="4" width="398" height="32"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="threads_icon" translatesAutoresizingMaskIntoConstraints="NO" id="vva-PV-3Ya">
|
||||
<rect key="frame" x="4" y="7" width="18" height="18"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="1Tz-Xd-AQx"/>
|
||||
<constraint firstAttribute="width" constant="18" id="PY6-xa-ldK"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="1" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GcG-W8-9LR">
|
||||
<rect key="frame" x="26" y="0.0" width="6" height="32"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="6" id="9Nt-Rk-O81"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9wW-1f-f69" customClass="UserAvatarView" customModule="Riot" customModuleProvider="target">
|
||||
<rect key="frame" x="44" y="4" width="24" height="24"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="24" id="Dmj-av-Udn"/>
|
||||
<constraint firstAttribute="height" constant="24" id="GHv-19-Tjh"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DVT-JI-3kw">
|
||||
<rect key="frame" x="76" y="0.0" width="314" height="32"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="DVT-JI-3kw" secondAttribute="bottom" id="ArM-9P-35J"/>
|
||||
<constraint firstAttribute="bottom" secondItem="GcG-W8-9LR" secondAttribute="bottom" id="FI4-bk-goz"/>
|
||||
<constraint firstItem="DVT-JI-3kw" firstAttribute="top" secondItem="TFL-sS-eJc" secondAttribute="top" id="MSs-PD-tov"/>
|
||||
<constraint firstItem="GcG-W8-9LR" firstAttribute="leading" secondItem="vva-PV-3Ya" secondAttribute="trailing" constant="4" id="PhI-J3-Ycb"/>
|
||||
<constraint firstItem="GcG-W8-9LR" firstAttribute="top" secondItem="TFL-sS-eJc" secondAttribute="top" id="Twp-gS-w3u"/>
|
||||
<constraint firstItem="9wW-1f-f69" firstAttribute="centerY" secondItem="TFL-sS-eJc" secondAttribute="centerY" id="UYy-PQ-m7A"/>
|
||||
<constraint firstAttribute="trailing" secondItem="DVT-JI-3kw" secondAttribute="trailing" constant="8" id="bX2-Ha-8bf"/>
|
||||
<constraint firstItem="vva-PV-3Ya" firstAttribute="centerY" secondItem="TFL-sS-eJc" secondAttribute="centerY" id="mkf-Hx-FLe"/>
|
||||
<constraint firstItem="DVT-JI-3kw" firstAttribute="leading" secondItem="9wW-1f-f69" secondAttribute="trailing" constant="8" id="qGg-0A-C6M"/>
|
||||
<constraint firstItem="9wW-1f-f69" firstAttribute="leading" secondItem="GcG-W8-9LR" secondAttribute="trailing" constant="12" id="s2V-X9-cyI"/>
|
||||
<constraint firstItem="vva-PV-3Ya" firstAttribute="leading" secondItem="TFL-sS-eJc" secondAttribute="leading" constant="4" id="vyh-e4-Vy3"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="TFL-sS-eJc" secondAttribute="bottom" constant="4" id="GJq-Pw-T0A"/>
|
||||
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="TFL-sS-eJc" secondAttribute="trailing" constant="8" id="RR6-Uu-dD9"/>
|
||||
<constraint firstItem="TFL-sS-eJc" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="8" id="lbH-ay-p0c"/>
|
||||
<constraint firstItem="TFL-sS-eJc" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="4" id="yqe-iO-Cz5"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<point key="canvasLocation" x="-23.188405797101453" y="-179.46428571428569"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="threads_icon" width="27" height="28.5"/>
|
||||
</resources>
|
||||
</document>
|
||||
Reference in New Issue
Block a user