@@ -14,6 +14,7 @@ import StreamChat
1414class CustomChatViewController : ChatViewController {
1515
1616 @IBOutlet weak var closeBarButton : UIBarButtonItem !
17+ let membersCountButton = UIBarButtonItem ( title: " 🤷🏻♀️0 " , style: . plain, target: nil , action: nil )
1718
1819 required init ? ( coder aDecoder: NSCoder ) {
1920 super. init ( coder: aDecoder)
@@ -28,19 +29,38 @@ class CustomChatViewController: ChatViewController {
2829 navigationItem. rightBarButtonItems = [ button]
2930 }
3031
32+ touchMembersCount ( )
33+
34+ if ( navigationItem. rightBarButtonItems? . count ?? 0 ) == 1 {
35+ navigationItem. rightBarButtonItems? . append ( membersCountButton)
36+ } else {
37+ navigationItem. leftBarButtonItem = membersCountButton
38+ }
39+
3140 guard let channelPresenter = channelPresenter else {
3241 return
3342 }
3443
35- title = " \( channelPresenter. channel. name) ( \( channelPresenter . channel . members . count ) ) "
44+ title = channelPresenter. channel. name
3645
3746 channelPresenter. channelDidUpdate
3847 . drive ( onNext: { [ weak self] channel in
39- self ? . title = " \( channel. name) ( \( channel. members. count) ) "
48+ self ? . title = channelPresenter. channel. name
49+ self ? . touchMembersCount ( )
4050 } )
4151 . disposed ( by: disposeBag)
4252 }
4353
54+ func touchMembersCount( ) {
55+ guard let channelPresenter = channelPresenter else {
56+ return
57+ }
58+
59+ membersCountButton. title = channelPresenter. channel. members. count > 0
60+ ? " 🙋🏻♀️ \( channelPresenter. channel. members. count) "
61+ : " 🤷🏻♀️0 "
62+ }
63+
4464 @IBAction func showMenu( _ sender: Any ) {
4565 let alert = UIAlertController ( title: nil , message: nil , preferredStyle: . actionSheet)
4666
@@ -124,42 +144,4 @@ class CustomChatViewController: ChatViewController {
124144
125145 return nil
126146 }
127-
128- // override func messageCell(at indexPath: IndexPath, message: Message, readUsers: [User]) -> UITableViewCell {
129- // let cell = tableView.dequeueReusableCell(withIdentifier: "message")
130- // ?? UITableViewCell(style: .value2, reuseIdentifier: "message")
131- //
132- // cell.textLabel?.text = message.user.name
133- // cell.textLabel?.numberOfLines = 2
134- // cell.textLabel?.font = .systemFont(ofSize: 12, weight: .bold)
135- // cell.detailTextLabel?.text = message.text
136- // cell.detailTextLabel?.numberOfLines = 0
137- //
138- // return cell
139- // }
140- //
141- // override func loadingCell(at indexPath: IndexPath) -> UITableViewCell? {
142- // let cell = tableView.dequeueReusableCell(withIdentifier: "loading")
143- // ?? UITableViewCell(style: .default, reuseIdentifier: "loading")
144- //
145- // cell.textLabel?.textColor = .red
146- // cell.textLabel?.text = "LOADING..."
147- // cell.textLabel?.textAlignment = .center
148- //
149- // return cell
150- // }
151- //
152- // override func statusCell(at indexPath: IndexPath,
153- // title: String,
154- // subtitle: String? = nil,
155- // highlighted: Bool) -> UITableViewCell? {
156- // let cell = tableView.dequeueReusableCell(withIdentifier: "status")
157- // ?? UITableViewCell(style: .default, reuseIdentifier: "status")
158- //
159- // cell.textLabel?.textColor = .gray
160- // cell.textLabel?.text = title
161- // cell.textLabel?.textAlignment = .center
162- //
163- // return cell
164- // }
165147}
0 commit comments