Skip to content

Commit b92fa16

Browse files
committed
* Added - setLogLevel() for debugging from the console
* Improved - navigationBar UI
1 parent 19ed247 commit b92fa16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+872
-256
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
### v1.0.6 (May 14, 2020)
4+
* Added - `setLogLevel()` for debugging from the console
5+
* Improved - navigationBar UI
6+
37
### v1.0.5 (May 6, 2020)
48
* Fixed - Weird creation channel navigation flow
59
* Modified - Empty messages string in channel

SendBirdUIKit.framework.dSYM/Contents/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<key>CFBundleSignature</key>
1414
<string>????</string>
1515
<key>CFBundleShortVersionString</key>
16-
<string>1.0.5</string>
16+
<string>1.0.6</string>
1717
<key>CFBundleVersion</key>
1818
<string>1</string>
1919
</dict>
591 KB
Binary file not shown.

SendBirdUIKit.framework/Assets.car

0 Bytes
Binary file not shown.

SendBirdUIKit.framework/Headers/SBUChannelListViewController.swift

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
6767
// MARK: - Lifecycle
6868
open override func loadView() {
6969
super.loadView()
70+
SBULog.info("")
7071

7172
// tableview
7273
self.tableView.delegate = self
@@ -106,9 +107,8 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
106107
}
107108

108109
public func setupStyles() {
109-
110-
self.navigationController?.navigationBar.backgroundColor = .clear
111-
self.navigationController?.navigationBar.barTintColor = theme.navigationBarTintColor
110+
111+
self.navigationController?.navigationBar.setBackgroundImage(UIImage.from(color: theme.navigationBarTintColor), for: .default)
112112
self.navigationController?.navigationBar.shadowImage = UIImage.from(color: theme.navigationBarShadowColor)
113113

114114
self.view.backgroundColor = theme.backgroundColor
@@ -155,10 +155,14 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
155155
self.setupStyles()
156156

157157
if self.isLoading { return }
158-
self.loadChannelChangeLogs(hasMore: true, token: self.lastUpdatedToken)
158+
159+
if self.lastUpdatedToken != nil {
160+
self.loadChannelChangeLogs(hasMore: true, token: self.lastUpdatedToken)
161+
}
159162
}
160163

161164
deinit {
165+
SBULog.info("")
162166
SBDMain.removeChannelDelegate(forIdentifier: self.description)
163167
SBDMain.removeConnectionDelegate(forIdentifier: self.description)
164168
}
@@ -190,6 +194,9 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
190194
self.channelList = []
191195
self.lastUpdatedTimestamp = Int64(Date().timeIntervalSince1970*1000)
192196
self.lastUpdatedToken = nil
197+
SBULog.info("[Request] Channel List")
198+
} else {
199+
SBULog.info("[Request] Next channel List")
193200
}
194201

195202
if self.channelListQuery == nil {
@@ -200,19 +207,24 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
200207
}
201208

202209
guard self.channelListQuery?.hasNext == true else {
210+
SBULog.info("All channels have been loaded.")
203211
self.setLoading(false, false)
204212
return
205213
}
206-
214+
207215
self.channelListQuery?.loadNextPage(completionHandler: { [weak self] channels, error in
208216
defer { self?.setLoading(false, false) }
209217

210-
guard error == nil else {
211-
self?.didReceiveError(error?.localizedDescription)
218+
if let error = error {
219+
SBULog.error("[Failed] Channel list request : \(String(describing: error.localizedDescription))")
220+
self?.didReceiveError(error.localizedDescription)
212221
self?.showNetworkError()
213222
return
214223
}
215224
guard let channels = channels else { return }
225+
226+
SBULog.info("[Response] \(channels.count) channels")
227+
216228

217229
self?.channelList += channels
218230
self?.sortChannelList(needReload: true)
@@ -222,28 +234,41 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
222234

223235
func loadChannelChangeLogs(hasMore: Bool, token: String?) {
224236
guard hasMore == true else {
237+
SBULog.info("All channel changes have been loaded.")
225238
self.sortChannelList(needReload: true)
226239
return
227240
}
228241

229242
if let token = token {
243+
SBULog.info("[Request] Channel change logs with token")
230244
SBDMain.getMyGroupChannelChangeLogs(byToken: token, customTypes: nil) { [weak self] updatedChannels, deletedChannelUrls, hasMore, token, error in
231-
if let error = error { self?.didReceiveError(error.localizedDescription) }
245+
if let error = error {
246+
SBULog.error("[Failed] Channel change logs request : \(error.localizedDescription)")
247+
self?.didReceiveError(error.localizedDescription)
248+
}
232249

233250
self?.lastUpdatedToken = token
234251

252+
SBULog.info("[Response] \(String(format: "%d updated channels", updatedChannels?.count ?? 0)), \(String(format: "%d deleted channels", deletedChannelUrls?.count ?? 0))")
253+
235254
self?.upsertChannels(channels: updatedChannels, needReload: false)
236255
self?.deleteChannels(channelUrls: deletedChannelUrls, needReload: false)
237256

238257
self?.loadChannelChangeLogs(hasMore: hasMore, token: token)
239258
}
240259
}
241260
else {
261+
SBULog.info("[Request] Channel change logs with last updated timestamp")
242262
SBDMain.getMyGroupChannelChangeLogs(byTimestamp: self.lastUpdatedTimestamp, customTypes: nil) { [weak self] updatedChannels, deletedChannelUrls, hasMore, token, error in
243-
if let error = error { self?.didReceiveError(error.localizedDescription) }
263+
if let error = error {
264+
SBULog.error("[Failed] Channel change logs request : \(error.localizedDescription)")
265+
self?.didReceiveError(error.localizedDescription)
266+
}
244267

245268
self?.lastUpdatedToken = token
246269

270+
SBULog.info("[Response] \(String(format: "%d updated channels", updatedChannels?.count ?? 0)), \(String(format: "%d deleted channels", deletedChannelUrls?.count ?? 0))")
271+
247272
self?.upsertChannels(channels: updatedChannels, needReload: false)
248273
self?.deleteChannels(channelUrls: deletedChannelUrls, needReload: false)
249274

@@ -450,10 +475,16 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
450475
let iconSize: CGFloat = 40.0
451476

452477
let leaveAction = UIContextualAction(style: .normal, title: "") { action, view, success in
478+
SBULog.info("[Request] Leave channel, ChannelUrl:\(channel.channelUrl)")
453479
channel.leave { [weak self] error in
454-
if let error = error { self?.didReceiveError(error.localizedDescription) }
480+
if let error = error {
481+
SBULog.error("[Failed] Leave channel request: \(String(error.localizedDescription))")
482+
self?.didReceiveError(error.localizedDescription)
483+
}
484+
485+
SBULog.info("[Succeed] Leave channel request, ChannelUrl:\(channel.channelUrl)")
486+
success(true)
455487
}
456-
success(true)
457488
}
458489

459490
let leaveTypeView = UIImageView(frame: CGRect(x: (size-iconSize)/2, y: (size-iconSize)/2, width: iconSize, height: iconSize))
@@ -468,13 +499,20 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
468499
let pushOption = channel.myPushTriggerOption
469500

470501
let alarmAction = UIContextualAction(style: .normal, title: "") { action, view, success in
502+
SBULog.info("[Request] Channel push status : \(pushOption == .off ? "on" : "off"), ChannelUrl:\(channel.channelUrl)")
471503
channel.setMyPushTriggerOption(pushOption == .off ? .all : .off) { [weak self] error in
472-
if let error = error { self?.didReceiveError(error.localizedDescription) }
504+
if let error = error {
505+
SBULog.error("[Failed] Channel push status request: \(String(error.localizedDescription))")
506+
self?.didReceiveError(error.localizedDescription)
507+
}
508+
509+
SBULog.info("[Succeed] Channel push status, ChannelUrl:\(channel.channelUrl)")
510+
success(true)
511+
473512
DispatchQueue.main.async {
474513
tableView.reloadRows(at: [indexPath], with: .automatic)
475514
}
476515
}
477-
success(true)
478516
}
479517

480518
let alarmTypeView = UIImageView(frame: CGRect(x: (size-iconSize)/2, y: (size-iconSize)/2, width: iconSize, height: iconSize))
@@ -503,8 +541,14 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
503541
let iconSize: CGFloat = 40.0
504542

505543
let leave = UITableViewRowAction(style: .normal, title: "") { action, indexPath in
544+
SBULog.info("[Request] Leave channel, ChannelUrl:\(channel.channelUrl)")
506545
channel.leave { [weak self] error in
507-
if let error = error { self?.didReceiveError(error.localizedDescription) }
546+
if let error = error {
547+
SBULog.error("[Failed] Leave channel request: \(String(error.localizedDescription))")
548+
self?.didReceiveError(error.localizedDescription)
549+
}
550+
551+
SBULog.info("[Succeed] Leave channel request, ChannelUrl:\(channel.channelUrl)")
508552
}
509553
}
510554

@@ -520,8 +564,14 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
520564

521565
let pushOption = channel.myPushTriggerOption
522566
let alarm = UITableViewRowAction(style: .normal, title: "") { action, indexPath in
567+
SBULog.info("[Request] Channel push status : \(pushOption == .off ? "on" : "off"), ChannelUrl:\(channel.channelUrl)")
523568
channel.setMyPushTriggerOption(pushOption == .off ? .all : .off) { [weak self] error in
524-
if let error = error { self?.didReceiveError(error.localizedDescription) }
569+
if let error = error {
570+
SBULog.error("[Failed] Channel push status request: \(String(error.localizedDescription))")
571+
self?.didReceiveError(error.localizedDescription)
572+
}
573+
574+
SBULog.info("[Succeed] Channel push status, ChannelUrl:\(channel.channelUrl)")
525575

526576
DispatchQueue.main.async {
527577
tableView.reloadRows(at: [indexPath], with: .automatic)
@@ -550,6 +600,8 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
550600

551601
// MARK: - SBDChannelDelegate
552602
open func channel(_ sender: SBDGroupChannel, userDidJoin user: SBDUser) {
603+
SBULog.info("User did join the channel, Nickname:\(String(user.nickname ?? "")) - ChannelUrl:\(sender.channelUrl)")
604+
553605
if self.channelListQuery?.includeEmptyChannel == false {
554606
self.updateChannels(channels: [sender], needReload: true)
555607
} else {
@@ -559,17 +611,22 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
559611

560612
open func channel(_ sender: SBDGroupChannel, userDidLeave user: SBDUser) {
561613
guard user.userId == SBUGlobals.CurrentUser?.userId else { return }
562-
614+
SBULog.info("User did leave the channel, Nickname:\(String(user.nickname ?? "")) - ChannelUrl:\(sender.channelUrl)")
615+
563616
self.deleteChannels(channelUrls: [sender.channelUrl], needReload: true)
564617
}
565618

566619
open func channelWasChanged(_ sender: SBDBaseChannel) {
567620
guard let channel = sender as? SBDGroupChannel else { return }
621+
SBULog.info("Channel was changed, ChannelUrl:\(sender.channelUrl)") // markAsRead, didReceiveMsg
622+
568623
self.upsertChannels(channels: [channel], needReload: true)
569624
}
570625

571626
open func channel(_ sender: SBDBaseChannel, messageWasDeleted messageId: Int64) {
572627
guard let channel = sender as? SBDGroupChannel else { return }
628+
SBULog.info("Message was deleted in the channel, MessageID:\(String(messageId)) - channelUrl:\(channel.channelUrl)")
629+
573630
self.upsertChannels(channels: [channel], needReload: false)
574631
}
575632

@@ -579,12 +636,13 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
579636
/// If necessary, override to handle errors.
580637
/// - Parameter message: error message
581638
open func didReceiveError(_ message: String?) {
582-
639+
SBULog.error("Did receive error: \(message ?? "")")
583640
}
584641

585642

586643
// MARK: - SBDConnectionDelegate
587644
open func didSucceedReconnection() {
645+
SBULog.info("Did succeed reconnection")
588646
self.loadChannelChangeLogs(hasMore: true, token: self.lastUpdatedToken)
589647
}
590648

@@ -593,10 +651,14 @@ open class SBUChannelListViewController: UIViewController, UITableViewDelegate,
593651
func didSelectRetry() {
594652
self.emptyView.updateType(.noChannels)
595653

654+
SBULog.info("[Request] Retry load channel list")
596655
SBUMain.connectionCheck { [weak self] user, error in
597656
guard let self = self else { return }
598657

599-
if let error = error { self.didReceiveError(error.localizedDescription) }
658+
if let error = error {
659+
SBULog.error("[Failed] Retry request: \(String(error.localizedDescription))")
660+
self.didReceiveError(error.localizedDescription)
661+
}
600662

601663
SBDMain.removeChannelDelegate(forIdentifier: self.description)
602664
SBDMain.removeConnectionDelegate(forIdentifier: self.description)

SendBirdUIKit.framework/Headers/SBUChannelSettingsViewController.swift

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
6262
@available(*, unavailable, renamed: "SBUChannelSettingsViewController.init(channelUrl:)")
6363
required public init?(coder: NSCoder) {
6464
super.init(coder: coder)
65+
SBULog.info("")
6566
}
6667

6768
/// If you have channel object, use this initialize function.
6869
/// - Parameter channel: Channel object
6970
public init(channel: SBDGroupChannel?) {
7071
super.init(nibName: nil, bundle: nil)
72+
SBULog.info("")
7173

7274
self.channel = channel
7375

@@ -78,6 +80,7 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
7880
/// - Parameter channelUrl: Channel url string
7981
public init(channelUrl: String?) {
8082
super.init(nibName: nil, bundle: nil)
83+
SBULog.info("")
8184

8285
self.channelUrl = channelUrl
8386

@@ -86,7 +89,8 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
8689

8790
open override func loadView() {
8891
super.loadView()
89-
92+
SBULog.info("")
93+
9094
// navigation bar
9195
self.navigationItem.leftBarButtonItem = self.leftBarButton
9296
self.navigationItem.rightBarButtonItem = self.rightBarButton
@@ -132,9 +136,8 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
132136

133137
/// This function handles the initialization of styles.
134138
open func setupStyles() {
135-
self.navigationController?.navigationBar.backgroundColor = .clear
136-
self.navigationController?.navigationBar.barTintColor = theme.navigationBarTintColor
137-
self.navigationController?.navigationBar.shadowImage = .from(color: theme.navigationShadowColor)
139+
self.navigationController?.navigationBar.setBackgroundImage(UIImage.from(color: theme.navigationBarTintColor), for: .default)
140+
self.navigationController?.navigationBar.shadowImage = UIImage.from(color: theme.navigationShadowColor)
138141

139142
self.leftBarButton?.tintColor = theme.leftBarButtonTintColor
140143
self.rightBarButton?.tintColor = theme.rightBarButtonTintColor
@@ -185,10 +188,17 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
185188
params.coverUrl = self.channel?.coverUrl
186189
}
187190

191+
SBULog.info("[Request] Channel update")
188192
channel.update(with: params) { [weak self] channel, error in
193+
if let error = error {
194+
SBULog.error("[Failed] Channel update request: \(String(error.localizedDescription))")
195+
}
196+
189197
if let userInfoView = self?.userInfoView as? UserInfoView {
190198
userInfoView.configure(channel: self?.channel)
191199
}
200+
201+
SBULog.info("[Succeed] Channel update")
192202
}
193203
}
194204

@@ -199,10 +209,15 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
199209

200210
SBUMain.connectionCheck { [weak self] user, error in
201211

212+
SBULog.info("[Request] Load channel: \(String(channelUrl))")
202213
SBDGroupChannel.getWithUrl(channelUrl) { [weak self] channel, error in
203-
guard error == nil else { return }
214+
if let error = error {
215+
SBULog.error("[Failed] Load channel request: \(error.localizedDescription)")
216+
return
217+
}
204218

205219
self?.channel = channel
220+
SBULog.info("[Succeed] Load channel request: \(String(format: "%@", self?.channel ?? ""))")
206221

207222
if let userInfoView = self?.userInfoView as? UserInfoView {
208223
userInfoView.configure(channel: self?.channel)
@@ -263,13 +278,30 @@ open class SBUChannelSettingsViewController: UIViewController, UITableViewDelega
263278
// MARK: - Actions
264279
public func changeNotification(isOn: Bool) {
265280
let triggerOption: SBDGroupChannelPushTriggerOption = isOn ? .all : .off
266-
self.channel?.setMyPushTriggerOption(triggerOption, completionHandler: { error in
281+
282+
SBULog.info("[Request] Channel push status : \(triggerOption == .off ? "on" : "off"), ChannelUrl:\(self.channel?.channelUrl ?? "")")
283+
self.channel?.setMyPushTriggerOption(triggerOption, completionHandler: { [weak self] error in
284+
guard let self = self else { return }
285+
286+
if let error = error {
287+
SBULog.error("[Failed] Channel push status request: \(String(error.localizedDescription))")
288+
}
289+
290+
SBULog.info("[Succeed] Channel push status, ChannelUrl:\(self.channel?.channelUrl ?? "")")
267291
})
268292
}
269293

270294
public func leaveChannel() {
295+
SBULog.info("[Request] Leave channel, ChannelUrl:\(self.channel?.channelUrl ?? "")")
271296
self.channel?.leave(completionHandler: { [weak self] error in
272297
guard let self = self else { return }
298+
299+
if let error = error {
300+
SBULog.error("[Failed] Leave channel request: \(String(error.localizedDescription))")
301+
}
302+
303+
SBULog.info("[Succeed] Leave channel request, ChannelUrl:\(self.channel?.channelUrl ?? "")")
304+
273305
guard let navigationController = self.navigationController, navigationController.viewControllers.count > 1 else {
274306
self.dismiss(animated: true, completion: nil)
275307
return

0 commit comments

Comments
 (0)