Skip to content

Commit

Permalink
Example project updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
buh committed Oct 4, 2019
1 parent 0b0ba4c commit 8161fe8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions Example/ChatExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {

private func setupNotifications() {
Notifications.shared.logsEnabled = true
Notifications.shared.clearApplicationIconBadgeNumberOnAppActive = true

Notifications.shared.showNewMessage = { [weak self] messageReference in
if let tabBarController = self?.window?.rootViewController as? UITabBarController,
Expand Down
27 changes: 22 additions & 5 deletions Example/ChatExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
<state key="normal" title="Show #general chat"/>
<connections>
<segue destination="Z71-Wp-boH" kind="presentation" modalPresentationStyle="fullScreen" id="Z6X-IU-Iab"/>
<segue destination="rzG-dX-Wof" kind="presentation" modalPresentationStyle="fullScreen" id="Z6X-IU-Iab"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qr4-mI-Aca">
Expand Down Expand Up @@ -294,14 +294,14 @@ badge</string>
<navigationItem key="navigationItem" id="M29-wa-tVT">
<barButtonItem key="rightBarButtonItem" systemItem="stop" id="2ar-d7-vJl">
<connections>
<segue destination="Z71-Wp-boH" kind="custom" customClass="DismissSegue" customModule="StreamChat" id="qnB-bf-sHX"/>
<segue destination="rzG-dX-Wof" kind="custom" customClass="DismissSegue" customModule="StreamChat" id="qnB-bf-sHX"/>
</connections>
</barButtonItem>
</navigationItem>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="oEb-lB-XXV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1134" y="681"/>
<point key="canvasLocation" x="2072.8000000000002" y="680.5097451274363"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="FFK-m4-8Eg">
Expand All @@ -320,7 +320,7 @@ badge</string>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="PRt-da-fZL" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="381.60000000000002" y="680.5097451274363"/>
<point key="canvasLocation" x="1320.8" y="680.5097451274363"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="OsV-rf-E6A">
Expand Down Expand Up @@ -359,10 +359,27 @@ badge</string>
</objects>
<point key="canvasLocation" x="-1281" y="-63"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="2hy-ym-0fX">
<objects>
<tabBarController automaticallyAdjustsScrollViewInsets="NO" id="rzG-dX-Wof" sceneMemberID="viewController">
<toolbarItems/>
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="k8B-25-9Jc">
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="Z71-Wp-boH" kind="relationship" relationship="viewControllers" id="x4V-vX-mKE"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yWn-do-Ou1" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="381.60000000000002" y="680.5097451274363"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="qnB-bf-sHX"/>
<segue reference="elX-bx-MbU"/>
<segue reference="Z6X-IU-Iab"/>
<segue reference="seW-P6-fEX"/>
</inferredMetricsTieBreakers>
</document>
18 changes: 16 additions & 2 deletions Example/ChatExample/DarkChannelsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,32 @@ final class DarkChannelsViewController: ChannelsViewController {

@IBAction func addChannel(_ sender: Any) {
let number = Int.random(in: 100...999)
let channel = Channel(type: .messaging, id: "new_channel_\(number)", name: "Channel \(number)")

let channel = Channel(type: .messaging,
id: "new_channel_\(number)",
name: "Channel \(number)",
members: [User.user1.asMember, User.user2.asMember])

channel.create()
.flatMapLatest({ channelResponse in
channelResponse.channel.send(message: Message(text: "A new channel created"))
channelResponse.channel.send(message: Message(text: "A new channel #\(number) created"))
})
.subscribe(onNext: {
print($0)
})
.disposed(by: disposeBag)
}

override func channelCell(at indexPath: IndexPath, channelPresenter: ChannelPresenter) -> UITableViewCell {
let cell = super.channelCell(at: indexPath, channelPresenter: channelPresenter)

if let cell = cell as? ChannelTableViewCell {
cell.nameLabel.text = "\(cell.nameLabel.text ?? "") (\(channelPresenter.channel.members.count))"
}

return cell
}

@IBAction func logout(_ sender: Any) {
if logoutButton.title == "Logout" {
Client.shared.disconnect()
Expand Down

0 comments on commit 8161fe8

Please sign in to comment.