Skip to content

Commit

Permalink
Updated the Example project with create and delete a new channel.
Browse files Browse the repository at this point in the history
  • Loading branch information
buh committed Sep 30, 2019
1 parent 996babb commit a1940fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Example/ChatExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<viewLayoutGuide key="safeArea" id="t9p-1J-lU0"/>
</view>
<navigationItem key="navigationItem" id="tyC-kY-Be8">
<barButtonItem key="leftBarButtonItem" systemItem="add" id="ReZ-CX-KNT">
<connections>
<action selector="addChannel:" destination="cor-4m-0UN" id="RDJ-f0-p0g"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="stop" id="xsm-do-D8r">
<connections>
<segue destination="Jpg-eB-15H" kind="custom" customClass="DismissSegue" customModule="StreamChat" id="a5b-Jp-cN7"/>
Expand Down Expand Up @@ -256,8 +261,8 @@
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="elX-bx-MbU"/>
<segue reference="a5b-Jp-cN7"/>
<segue reference="Z6X-IU-Iab"/>
<segue reference="seW-P6-fEX"/>
<segue reference="6oS-c0-L1x"/>
</inferredMetricsTieBreakers>
</document>
21 changes: 20 additions & 1 deletion Example/ChatExample/DarkChannelsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,30 @@ final class DarkChannelsViewController: ChannelsViewController {

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
style = .dark
setup()
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}

func setup() {
deleteChannelBySwipe = true
style = .dark
}

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

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

0 comments on commit a1940fc

Please sign in to comment.