Move more button out of the title view & remove weird constraints

This commit is contained in:
ismailgulek
2021-11-22 12:22:53 +03:00
parent c312ea13c2
commit 1490f3e118
5 changed files with 49 additions and 32 deletions
@@ -26,6 +26,11 @@ enum ThreadRoomTitleViewMode: Int {
@objcMembers
class ThreadRoomTitleView: RoomTitleView {
private enum Constants {
static let titleLeadingMarginOnPortrait: CGFloat = 6
static let titleLeadingMarginOnLandscape: CGFloat = 18
}
var mode: ThreadRoomTitleViewMode = .full {
didSet {
update()
@@ -47,7 +52,7 @@ class ThreadRoomTitleView: RoomTitleView {
@IBOutlet private weak var fullRoomAvatarView: RoomAvatarView!
@IBOutlet private weak var fullRoomEncryptionBadgeView: UIImageView!
@IBOutlet private weak var fullRoomNameLabel: UILabel!
@IBOutlet private weak var fullOptionsButton: UIButton!
@IBOutlet private weak var titleLabelLeadingConstraint: NSLayoutConstraint!
override var mxRoom: MXRoom! {
didSet {
@@ -97,15 +102,13 @@ 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.titleLeadingMarginOnPortrait
} else {
titleLabelLeadingConstraint.constant = Constants.titleLeadingMarginOnLandscape
}
}
@@ -152,10 +155,6 @@ class ThreadRoomTitleView: RoomTitleView {
self.update(theme: ThemeService.shared().theme)
}
@IBAction private func optionsButtonTapped(_ sender: UIButton) {
}
}
extension ThreadRoomTitleView: Themable {
@@ -165,7 +164,6 @@ extension ThreadRoomTitleView: Themable {
fullRoomAvatarView.backgroundColor = .clear
fullTitleLabel.textColor = theme.colors.primaryContent
fullRoomNameLabel.textColor = theme.colors.secondaryContent
fullOptionsButton.tintColor = theme.colors.accent
}
}
@@ -35,13 +35,13 @@
<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="Thread" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BnG-NU-7Mg">
<rect key="frame" x="48" y="22" width="56.5" height="20.5"/>
<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="112.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"/>
@@ -49,7 +49,7 @@
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Mli-PC-WUh">
<rect key="frame" x="122.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"/>
@@ -57,28 +57,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="139.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="spaces_more"/>
<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"/>
@@ -101,19 +91,18 @@
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="fullContainerView" destination="Ami-Cg-fcA" id="Fo9-bp-DMP"/>
<outlet property="fullOptionsButton" destination="Unx-UY-EgO" id="657-Eq-QhA"/>
<outlet property="fullRoomAvatarView" destination="FJB-2F-rrQ" id="iok-M1-un0"/>
<outlet property="fullRoomEncryptionBadgeView" destination="Mli-PC-WUh" id="Ipu-zu-qBB"/>
<outlet property="fullRoomNameLabel" destination="8lk-sN-3IP" id="bDF-fD-KmE"/>
<outlet property="fullTitleLabel" destination="BnG-NU-7Mg" id="zhJ-om-6HM"/>
<outlet property="partialContainerView" destination="p54-De-nkd" id="huG-Db-CIU"/>
<outlet property="partialTitleLabel" destination="mO3-2G-Gl3" id="X0E-ry-7zp"/>
<outlet property="titleLabelLeadingConstraint" destination="ES6-mL-Y9F" id="YCu-B7-fQD"/>
</connections>
<point key="canvasLocation" x="0.7246376811594204" y="-152.00892857142856"/>
</view>
</objects>
<resources>
<image name="spaces_more" width="24" height="24"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>