Merge branch 'ismail/5117_thread_message_actions' into ismail/5092_thread_list

This commit is contained in:
ismailgulek
2021-11-22 14:59:07 +03:00
6 changed files with 79 additions and 62 deletions
@@ -23,26 +23,25 @@ enum ThreadRoomTitleViewMode {
case specificThread(threadId: String)
}
@objc
protocol ThreadRoomTitleViewDelegate: AnyObject {
func threadRoomTitleViewDidTapOptions(_ view: ThreadRoomTitleView)
}
@objcMembers
class ThreadRoomTitleView: RoomTitleView {
private enum Constants {
static let titleLeadingConstraintOnPortrait: CGFloat = 6
static let titleLeadingConstraintOnLandscape: CGFloat = 18
}
var mode: ThreadRoomTitleViewMode = .allThreads {
didSet {
update()
}
}
weak var viewDelegate: ThreadRoomTitleViewDelegate?
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var titleLabelLeadingConstraint: NSLayoutConstraint!
@IBOutlet private weak var roomAvatarView: RoomAvatarView!
@IBOutlet private weak var roomEncryptionBadgeView: UIImageView!
@IBOutlet private weak var roomNameLabel: UILabel!
@IBOutlet private weak var optionsButton: UIButton!
// MARK: - Methods
@@ -102,18 +101,18 @@ class ThreadRoomTitleView: RoomTitleView {
registerThemeServiceDidChangeThemeNotification()
}
override func didMoveToSuperview() {
super.didMoveToSuperview()
// TODO: Find a way to handle this properly
if let superview = superview?.superview {
NSLayoutConstraint.activate([
self.leadingAnchor.constraint(equalTo: superview.leadingAnchor),
self.trailingAnchor.constraint(equalTo: superview.trailingAnchor)
])
override func updateLayout(for orientation: UIInterfaceOrientation) {
super.updateLayout(for: orientation)
if orientation.isPortrait {
titleLabelLeadingConstraint.constant = Constants.titleLeadingConstraintOnPortrait
} else {
titleLabelLeadingConstraint.constant = Constants.titleLeadingConstraintOnLandscape
}
}
// MARK: - Private
private func registerThemeServiceDidChangeThemeNotification() {
NotificationCenter.default.addObserver(self,
selector: #selector(themeDidChange),
@@ -125,10 +124,8 @@ class ThreadRoomTitleView: RoomTitleView {
switch mode {
case .allThreads:
titleLabel.text = VectorL10n.threadsTitle
optionsButton.setImage(Asset.Images.threadsFilter.image, for: .normal)
case .specificThread:
titleLabel.text = VectorL10n.roomThreadTitle
optionsButton.setImage(Asset.Images.roomContextMenuMore.image, for: .normal)
}
}
@@ -137,11 +134,7 @@ class ThreadRoomTitleView: RoomTitleView {
@objc private func themeDidChange() {
self.update(theme: ThemeService.shared().theme)
}
@IBAction private func optionsButtonTapped(_ sender: UIButton) {
viewDelegate?.threadRoomTitleViewDidTapOptions(self)
}
}
extension ThreadRoomTitleView: NibLoadable {}
@@ -152,7 +145,6 @@ extension ThreadRoomTitleView: Themable {
roomAvatarView.backgroundColor = .clear
titleLabel.textColor = theme.colors.primaryContent
roomNameLabel.textColor = theme.colors.secondaryContent
optionsButton.tintColor = theme.colors.accent
}
}
@@ -18,14 +18,14 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ami-Cg-fcA">
<rect key="frame" x="0.0" y="0.0" width="243" height="64"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Threads" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BnG-NU-7Mg">
<rect key="frame" x="48" y="22" width="65.5" height="20.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Thread" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BnG-NU-7Mg">
<rect key="frame" x="18" y="22" width="56.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FJB-2F-rrQ" customClass="RoomAvatarView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="121.5" y="24" width="16" height="16"/>
<rect key="frame" x="82.5" y="24" width="16" height="16"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="Fg7-y5-fEC"/>
@@ -33,7 +33,7 @@
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Mli-PC-WUh">
<rect key="frame" x="131.5" y="28" width="12" height="12"/>
<rect key="frame" x="92.5" y="28" width="12" height="12"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="Mli-PC-WUh" secondAttribute="height" multiplier="1:1" id="Ohw-dy-qg0"/>
@@ -41,28 +41,18 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Room name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8lk-sN-3IP">
<rect key="frame" x="148.5" y="24.5" width="67" height="15"/>
<rect key="frame" x="109.5" y="24.5" width="67" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Unx-UY-EgO">
<rect key="frame" x="195" y="12" width="32" height="40"/>
<inset key="contentEdgeInsets" minX="4" minY="8" maxX="4" maxY="8"/>
<state key="normal" image="threads_filter"/>
<connections>
<action selector="optionsButtonTapped:" destination="iN0-l3-epB" eventType="touchUpInside" id="wOn-cR-mS5"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Unx-UY-EgO" firstAttribute="centerY" secondItem="Ami-Cg-fcA" secondAttribute="centerY" id="30B-oO-Ka5"/>
<constraint firstItem="Mli-PC-WUh" firstAttribute="centerX" secondItem="FJB-2F-rrQ" secondAttribute="trailing" id="BU4-yl-DrP"/>
<constraint firstItem="BnG-NU-7Mg" firstAttribute="leading" secondItem="Ami-Cg-fcA" secondAttribute="leading" constant="48" id="ES6-mL-Y9F"/>
<constraint firstItem="BnG-NU-7Mg" firstAttribute="leading" secondItem="Ami-Cg-fcA" secondAttribute="leading" constant="18" id="ES6-mL-Y9F"/>
<constraint firstItem="8lk-sN-3IP" firstAttribute="centerY" secondItem="Ami-Cg-fcA" secondAttribute="centerY" id="S0S-6y-Vkn"/>
<constraint firstItem="FJB-2F-rrQ" firstAttribute="leading" secondItem="BnG-NU-7Mg" secondAttribute="trailing" constant="8" id="SQk-zN-CO6"/>
<constraint firstAttribute="trailing" secondItem="Unx-UY-EgO" secondAttribute="trailing" constant="16" id="dpB-Nz-PQ9"/>
<constraint firstItem="FJB-2F-rrQ" firstAttribute="centerY" secondItem="Ami-Cg-fcA" secondAttribute="centerY" id="nY0-2s-Wgo"/>
<constraint firstItem="8lk-sN-3IP" firstAttribute="leading" secondItem="FJB-2F-rrQ" secondAttribute="trailing" constant="11" id="ql2-B3-82Y"/>
<constraint firstItem="BnG-NU-7Mg" firstAttribute="centerY" secondItem="Ami-Cg-fcA" secondAttribute="centerY" id="rwC-ak-Ydb"/>
@@ -80,17 +70,16 @@
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="optionsButton" destination="Unx-UY-EgO" id="iOV-Of-m2N"/>
<outlet property="roomAvatarView" destination="FJB-2F-rrQ" id="VKY-tN-0eg"/>
<outlet property="roomEncryptionBadgeView" destination="Mli-PC-WUh" id="9jZ-bS-JCQ"/>
<outlet property="roomNameLabel" destination="8lk-sN-3IP" id="njT-pb-QqT"/>
<outlet property="titleLabel" destination="BnG-NU-7Mg" id="4Fn-m2-HoC"/>
<outlet property="roomAvatarView" destination="FJB-2F-rrQ" id="SUd-p8-VCH"/>
<outlet property="roomEncryptionBadgeView" destination="Mli-PC-WUh" id="MuX-Qw-DfQ"/>
<outlet property="roomNameLabel" destination="8lk-sN-3IP" id="wFm-R4-fBo"/>
<outlet property="titleLabel" destination="BnG-NU-7Mg" id="gDw-Pr-oR8"/>
<outlet property="titleLabelLeadingConstraint" destination="ES6-mL-Y9F" id="MpE-vt-KKC"/>
</connections>
<point key="canvasLocation" x="0.7246376811594204" y="-152.00892857142856"/>
</view>
</objects>
<resources>
<image name="threads_filter" width="24" height="24"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>