Skip to content

Commit 53e1b9e

Browse files
authored
Merge pull request #27 from easemob/dev
Dev
2 parents 51e35c6 + 91d2048 commit 53e1b9e

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

Sources/ChatroomUIKit/Classes/Service/Client/RoomService.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ import UIKit
159159
self.roomId = roomId
160160
}
161161

162-
func bindChatDriver(_ driver: IMessageListDrive) {
162+
@objc public func bindChatDriver(_ driver: IMessageListDrive) {
163163
self.chatDrive = driver
164164
}
165165

166-
func bindGiftDriver(_ driver: IGiftMessageListDrive) {
166+
@objc public func bindGiftDriver(_ driver: IGiftMessageListDrive) {
167167
self.giftDrive = driver
168168
}
169169

170-
func bindGlobalNotifyDriver(driver: IGlobalBoardcastViewDrive) {
170+
@objc public func bindGlobalNotifyDriver(driver: IGlobalBoardcastViewDrive) {
171171
self.notifyDrive = driver
172172
}
173173

@@ -188,7 +188,7 @@ import UIKit
188188
}
189189
}
190190

191-
private func cleanCache() {
191+
@objc open func cleanCache() {
192192
self.roomId = ""
193193
self.roomService = nil
194194
self.giftDrive = nil
@@ -228,7 +228,7 @@ import UIKit
228228
// })
229229
// }
230230

231-
@objc public func enterRoom(completion: @escaping (ChatError?) -> Void) {
231+
@objc open func enterRoom(completion: @escaping (ChatError?) -> Void) {
232232
if let userId = ChatroomContext.shared?.currentUser?.userId {
233233
self.roomService?.chatroomOperating(roomId: self.roomId, userId: userId, type: .join) { [weak self] success, error in
234234
guard let `self` = self else { return }
@@ -244,7 +244,7 @@ import UIKit
244244
}
245245
}
246246

247-
@objc public func leaveRoom(completion: @escaping (ChatError?) -> Void) {
247+
@objc open func leaveRoom(completion: @escaping (ChatError?) -> Void) {
248248
self.roomService?.chatroomOperating(roomId: self.roomId, userId: ChatClient.shared().currentUsername ?? "", type: .leave, completion: { [weak self] success, error in
249249
if success {
250250
self?.cleanCache()
@@ -253,7 +253,7 @@ import UIKit
253253
})
254254
}
255255

256-
@objc public func destroyed(completion: @escaping (ChatError?) -> Void) {
256+
@objc open func destroyed(completion: @escaping (ChatError?) -> Void) {
257257
self.roomService?.chatroomOperating(roomId: self.roomId, userId: ChatClient.shared().currentUsername ?? "", type: .destroyed, completion: { [weak self] success, error in
258258
if success {
259259
self?.cleanCache()
@@ -264,7 +264,7 @@ import UIKit
264264

265265
//MARK: - Participants operation
266266
@objc(kickUserWithId:completion:)
267-
public func kick(userId: String,completion: @escaping (ChatError?) -> Void) {
267+
open func kick(userId: String,completion: @escaping (ChatError?) -> Void) {
268268
self.roomService?.operatingUser(roomId: self.roomId, userId: userId, type: .kick, completion: { [weak self] success, error in
269269
if error == nil {
270270
NotificationCenter.default.post(name: NSNotification.Name("ChatroomUIKitKickUserSuccess"), object: userId)
@@ -276,7 +276,7 @@ import UIKit
276276
}
277277

278278
@objc(muteUserWithId:completion:)
279-
public func mute(userId: String,completion: @escaping (ChatError?) -> Void) {
279+
open func mute(userId: String,completion: @escaping (ChatError?) -> Void) {
280280
self.roomService?.operatingUser(roomId: self.roomId, userId: userId, type: .mute, completion: { [weak self] success, error in
281281
if error == nil {
282282
ChatroomContext.shared?.muteMap?[userId] = true
@@ -287,7 +287,7 @@ import UIKit
287287
}
288288

289289
@objc(unmuteUserWithId:completion:)
290-
public func unmute(userId: String,completion: @escaping (ChatError?) -> Void) {
290+
open func unmute(userId: String,completion: @escaping (ChatError?) -> Void) {
291291
self.roomService?.operatingUser(roomId: self.roomId, userId: userId, type: .unmute, completion: { [weak self] success, error in
292292
if error == nil {
293293
ChatroomContext.shared?.muteMap?.removeValue(forKey: userId)
@@ -297,7 +297,7 @@ import UIKit
297297
})
298298
}
299299

300-
@objc public func fetchParticipants(pageSize: UInt, completion: @escaping (([UserInfoProtocol]?,ChatError?)->Void)) {
300+
@objc open func fetchParticipants(pageSize: UInt, completion: @escaping (([UserInfoProtocol]?,ChatError?)->Void)) {
301301
self.roomService?.fetchParticipants(roomId: self.roomId, pageSize: pageSize, completion: { [weak self] userIds, error in
302302
guard let `self` = self else { return }
303303
if let ids = userIds {
@@ -357,7 +357,7 @@ import UIKit
357357
}
358358

359359
@objc(fetchMuteUsersWithPageSize:completion:)
360-
public func fetchMuteUsers(pageSize: UInt, completion: @escaping (([UserInfoProtocol]?,ChatError?)->Void)) {
360+
open func fetchMuteUsers(pageSize: UInt, completion: @escaping (([UserInfoProtocol]?,ChatError?)->Void)) {
361361
self.roomService?.fetchMuteUsers(roomId: self.roomId, pageNum: UInt(self.pageNumOfMute), pageSize: pageSize, completion: { [weak self] userIds, error in
362362
guard let `self` = self else { return }
363363
if error == nil {
@@ -410,7 +410,7 @@ import UIKit
410410
/// - unknownUserIds: User ID array without user information
411411
/// - completion: Callback user infos and error.
412412
@objc(fetchThenCacheUserInfosOnEndScrollWithunknownUserIds:completion:)
413-
public func fetchThenCacheUserInfosOnEndScroll(unknownUserIds:[String], completion: @escaping (([UserInfoProtocol]?,ChatError?)->Void)) {
413+
open func fetchThenCacheUserInfosOnEndScroll(unknownUserIds:[String], completion: @escaping (([UserInfoProtocol]?,ChatError?)->Void)) {
414414
ChatroomUIKitClient.shared.userImplement?.userInfos(userIds: unknownUserIds, completion: { infos, error in
415415
if error == nil {
416416
for info in infos {
@@ -448,7 +448,7 @@ import UIKit
448448
// }
449449
//MARK: - Message operation
450450
@objc(translateWithMessage:completion:)
451-
public func translate(message: ChatMessage,completion: @escaping (ChatError?) -> Void) {
451+
open func translate(message: ChatMessage,completion: @escaping (ChatError?) -> Void) {
452452
self.roomService?.translateMessage(message: message, completion: { [weak self] translateResult, error in
453453
if error == nil,let translation = translateResult {
454454
self?.chatDrive?.refreshMessage(message: translation)
@@ -459,7 +459,7 @@ import UIKit
459459
}
460460

461461
@objc(recallWithMessage:completion:)
462-
public func recall(message: ChatMessage,completion: @escaping (ChatError?) -> Void) {
462+
open func recall(message: ChatMessage,completion: @escaping (ChatError?) -> Void) {
463463
self.roomService?.recall(messageId: message.messageId, completion: { [weak self] error in
464464
if error == nil {
465465
self?.chatDrive?.removeMessage(message: message)
@@ -470,7 +470,7 @@ import UIKit
470470
}
471471

472472
@objc(reportWithMessage:tag:reason:completion:)
473-
public func report(message: ChatMessage,tag: String, reason: String,completion: @escaping (ChatError?) -> Void) {
473+
open func report(message: ChatMessage,tag: String, reason: String,completion: @escaping (ChatError?) -> Void) {
474474
self.roomService?.report(messageId: message.messageId, tag: tag, reason: reason, completion: { [weak self] error in
475475
self?.handleError(type: .report, error: error)
476476
completion(error)

Sources/ChatroomUIKit/Classes/UI/Components/Room/Views/ChatroomView.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,50 @@ import UIKit
3636
lazy private var eventHandlers: NSHashTable<ChatroomViewActionEventsDelegate> = NSHashTable<ChatroomViewActionEventsDelegate>.weakObjects()
3737

3838
public private(set) lazy var carouselTextView: GlobalBoardcastView = {
39-
GlobalBoardcastView(originPoint: Appearance.notifyMessageOriginPoint, width: self.frame.width-40, font: UIFont.theme.headlineExtraSmall, textColor: UIColor.theme.neutralColor98).cornerRadius(.large).backgroundColor(Appearance.notifyBackgroundColor)
39+
self.createBoardcast()
4040
}()
41+
42+
@objc open func createBoardcast() -> GlobalBoardcastView {
43+
GlobalBoardcastView(originPoint: Appearance.notifyMessageOriginPoint, width: self.frame.width-40, font: UIFont.theme.headlineExtraSmall, textColor: UIColor.theme.neutralColor98).cornerRadius(.large).backgroundColor(Appearance.notifyBackgroundColor)
44+
}
4145

4246
/// Gift list on receive gift.
4347
public private(set) lazy var giftArea: GiftMessageList = {
44-
GiftMessageList(frame: CGRect(x: 10, y: self.touchFrame.minY, width: self.touchFrame.width/2.0+60, height: Appearance.giftAreaRowHeight*2),source:self)
48+
self.createGiftsArea()
4549
}()
4650

51+
52+
@objc open func createGiftsArea() -> GiftMessageList {
53+
GiftMessageList(frame: CGRect(x: 10, y: self.touchFrame.minY, width: self.touchFrame.width/2.0+60, height: Appearance.giftAreaRowHeight*2),source:self)
54+
}
55+
4756
/// Chat area list.
4857
public private(set) lazy var chatList: MessageList = {
49-
MessageList(frame: CGRect(x: 0, y: ChatroomUIKitClient.shared.option.option_UI.showGiftMessageArea ? self.giftArea.frame.maxY+5:self.touchFrame.minY, width: self.touchFrame.width-50, height: self.touchFrame.height-54-BottomBarHeight-5-(ChatroomUIKitClient.shared.option.option_UI.showGiftMessageArea ? (Appearance.giftAreaRowHeight*2):0))).backgroundColor(.clear)
58+
self.createChatList()
5059
}()
5160

61+
@objc open func createChatList() -> MessageList {
62+
MessageList(frame: CGRect(x: 0, y: ChatroomUIKitClient.shared.option.option_UI.showGiftMessageArea ? self.giftArea.frame.maxY+5:self.touchFrame.minY, width: self.touchFrame.width-50, height: self.touchFrame.height-54-BottomBarHeight-5-(ChatroomUIKitClient.shared.option.option_UI.showGiftMessageArea ? (Appearance.giftAreaRowHeight*2):0))).backgroundColor(.clear)
63+
}
64+
5265
/// Bottom function bar below chat list.
5366
public private(set) lazy var bottomBar: BottomAreaToolBar = {
54-
BottomAreaToolBar(frame: CGRect(x: 0, y: self.frame.height-54-BottomBarHeight, width: self.touchFrame.width, height: 54), datas: ChatroomUIKitClient.shared.option.option_UI.bottomDataSource)
67+
self.createBottomBar()
5568
}()
5669

70+
@objc open func createBottomBar() -> BottomAreaToolBar {
71+
BottomAreaToolBar(frame: CGRect(x: 0, y: self.frame.height-54-BottomBarHeight, width: self.touchFrame.width, height: 54), datas: ChatroomUIKitClient.shared.option.option_UI.bottomDataSource)
72+
}
73+
5774
/// Input text menu bar.
5875
public private(set) lazy var inputBar: MessageInputBar = {
59-
ComponentsRegister.shared.InputBar.init(frame: CGRect(x: 0, y: self.frame.height, width: self.touchFrame.width, height: 52),text: nil,placeHolder: Appearance.inputPlaceHolder)
76+
self.createInputBar()
6077
}()
6178

79+
@objc open func createInputBar() -> MessageInputBar {
80+
ComponentsRegister.shared.InputBar.init(frame: CGRect(x: 0, y: self.frame.height, width: self.touchFrame.width, height: 52),text: nil,placeHolder: Appearance.inputPlaceHolder)
81+
}
82+
6283
private var touchFrame = CGRect.zero
6384

6485
/// Chatroom view init method.

0 commit comments

Comments
 (0)