Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit 9acc83d

Browse files
committed
Replace DM icon by bubble on titleView
1 parent 8be2c6f commit 9acc83d

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

Rocket.Chat/Views/Chat/ChatTitleView.swift

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ final class ChatTitleView: UIView {
1616

1717
weak var delegate: ChatTitleViewProtocol?
1818

19+
@IBOutlet weak var viewStatus: UIView! {
20+
didSet {
21+
viewStatus.backgroundColor = .clear
22+
viewStatus.layer.cornerRadius = 4.5
23+
}
24+
}
25+
1926
@IBOutlet weak var titleLabel: UILabel!
2027
@IBOutlet weak var titleImage: UIImageView!
2128
@IBOutlet weak var showInfoImage: UIImageView!
@@ -31,6 +38,7 @@ final class ChatTitleView: UIView {
3138
}
3239

3340
set {
41+
viewStatus.isHidden = newValue
3442
titleLabel.isHidden = newValue
3543
titleImage.isHidden = newValue
3644
showInfoImage.isHidden = newValue
@@ -39,6 +47,7 @@ final class ChatTitleView: UIView {
3947

4048
var state: SocketConnectionState = SocketManager.sharedInstance.state {
4149
didSet {
50+
updateTitleState()
4251
updateConnectionState()
4352
}
4453
}
@@ -56,12 +65,28 @@ final class ChatTitleView: UIView {
5665
didSet {
5766
guard let subscription = subscription else { return }
5867
viewModel.subscription = subscription
59-
titleLabel.text = viewModel.title
6068

69+
DispatchQueue.main.async {
70+
self.updateTitleState()
71+
self.updateConnectionState()
72+
}
73+
}
74+
}
75+
76+
internal func updateTitleState() {
77+
guard let subscription = viewModel.subscription else { return }
78+
79+
titleLabel.text = viewModel.title
80+
81+
if subscription.type == .directMessage {
82+
titleImage.isHidden = true
83+
viewStatus.backgroundColor = viewModel.iconColor
84+
viewStatus.isHidden = false
85+
} else {
86+
titleImage.isHidden = false
6187
let image = UIImage(named: viewModel.imageName)?.imageWithTint(viewModel.iconColor)
6288
titleImage.image = image
63-
64-
updateConnectionState()
89+
viewStatus.isHidden = true
6590
}
6691
}
6792

Rocket.Chat/Views/Chat/ChatTitleView.xib

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,24 @@
7777
<nil key="textColor"/>
7878
<nil key="highlightedColor"/>
7979
</label>
80+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4Ah-8t-4MZ" customClass="NotThemeableView" customModule="Rocket_Chat" customModuleProvider="target">
81+
<rect key="frame" x="11" y="5.5" width="9" height="9"/>
82+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
83+
<constraints>
84+
<constraint firstAttribute="height" constant="9" id="Fq8-xb-rdo"/>
85+
<constraint firstAttribute="width" constant="9" id="Pj3-2B-aw1"/>
86+
</constraints>
87+
</view>
8088
</subviews>
8189
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
8290
<constraints>
91+
<constraint firstItem="4Ah-8t-4MZ" firstAttribute="centerX" secondItem="r2R-yy-EGi" secondAttribute="centerX" id="3Am-Zf-cEY"/>
8392
<constraint firstItem="r2R-yy-EGi" firstAttribute="centerY" secondItem="d1M-6e-vj0" secondAttribute="centerY" id="4gI-vW-2zi"/>
8493
<constraint firstItem="qdc-h6-oM3" firstAttribute="centerY" secondItem="d1M-6e-vj0" secondAttribute="centerY" id="5OS-tR-6Yv"/>
8594
<constraint firstItem="d1M-6e-vj0" firstAttribute="top" secondItem="F2i-rU-dxW" secondAttribute="top" id="7Oa-HK-RhK"/>
8695
<constraint firstAttribute="bottom" secondItem="bLg-FB-vXv" secondAttribute="bottom" id="A60-HQ-QRT"/>
8796
<constraint firstItem="r2R-yy-EGi" firstAttribute="leading" secondItem="F2i-rU-dxW" secondAttribute="leadingMargin" id="COl-CQ-in6"/>
97+
<constraint firstItem="4Ah-8t-4MZ" firstAttribute="centerY" secondItem="r2R-yy-EGi" secondAttribute="centerY" id="NWV-sz-cVT"/>
8898
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="qdc-h6-oM3" secondAttribute="trailing" id="P3U-aA-vZn"/>
8999
<constraint firstItem="qdc-h6-oM3" firstAttribute="leading" secondItem="d1M-6e-vj0" secondAttribute="trailing" constant="8" id="SU1-gG-cyt"/>
90100
<constraint firstItem="d1M-6e-vj0" firstAttribute="leading" secondItem="r2R-yy-EGi" secondAttribute="trailing" constant="4" id="iVT-QY-FmK"/>
@@ -114,6 +124,7 @@
114124
<outlet property="titleLabel" destination="d1M-6e-vj0" id="N3K-Oi-icf"/>
115125
<outlet property="typingLabel" destination="bLg-FB-vXv" id="bcb-ji-CuS"/>
116126
<outlet property="viewLoading" destination="oSA-hf-f6V" id="Sah-7o-vW8"/>
127+
<outlet property="viewStatus" destination="4Ah-8t-4MZ" id="xZe-MG-kNI"/>
117128
<outletCollection property="gestureRecognizers" destination="HlR-jW-RHu" appends="YES" id="vTE-rM-sOD"/>
118129
</connections>
119130
<point key="canvasLocation" x="-100" y="104.34782608695653"/>

0 commit comments

Comments
 (0)