Skip to content

Commit 51e35c6

Browse files
authored
Merge pull request #26 from easemob/dev
rooms Register
2 parents f39f17a + f9fced0 commit 51e35c6

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ import UIKit
116116
self.option.option_UI.bottomDataSource = options.bottomDataSource
117117
self.option.option_UI.showGiftMessageArea = options.showGiftMessageArea
118118
self.option.option_UI.chatAreaShowGift = options.chatAreaShowGift
119-
let room = ChatroomView(respondTouch: frame)
120-
let service = RoomService(roomId: roomId)
119+
let room = ComponentsRegister.shared.RoomView.init(respondTouch: frame)
120+
let service = ComponentsRegister.shared.RoomViewService.init(roomId: roomId)
121121
self.roomService = service
122122
room.connectService(service)
123123
return room

Sources/ChatroomUIKit/Classes/UI/Components/Room/Controllers/ParticipantsController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010
/// Chatroom participants list
1111
open class ParticipantsController: UITableViewController {
1212

13-
public private(set) var roomService = RoomService(roomId: ChatroomContext.shared?.roomId ?? "")
13+
public private(set) var roomService = ComponentsRegister.shared.RoomViewService.init(roomId: ChatroomContext.shared?.roomId ?? "")
1414

1515
public private(set) var users = [UserInfoProtocol]() {
1616
didSet {

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import UIKit
9595
fatalError("init(coder:) has not been implemented")
9696
}
9797

98-
private func sendTextMessage(text: String) {
98+
@objc open func sendTextMessage(text: String) {
9999
self.service?.roomService?.sendMessage(text: text, roomId: ChatroomContext.shared?.roomId ?? "", completion: { [weak self] message, error in
100100
if error == nil {
101101
self?.chatList.showNewMessage(message: message, gift: nil)
@@ -114,7 +114,7 @@ import UIKit
114114
/// This method binds your view to the model it serves. A ChatroomView can only call it once. There is judgment in this method. Calling it multiple times is invalid.
115115
/// - Parameter service: ``RoomService``
116116
@objc(connectWithService:)
117-
public func connectService(_ service: RoomService) {
117+
open func connectService(_ service: RoomService) {
118118
if self.service != nil {
119119
return
120120
}
@@ -137,7 +137,7 @@ import UIKit
137137
/// Disconnect room service
138138
/// - Parameter service: ``RoomService``
139139
@objc(disconnectWithService:)
140-
public func disconnectService(_ service: RoomService) {
140+
open func disconnectService(_ service: RoomService) {
141141
self.service?.leaveRoom(completion: { [weak self] error in
142142
if error == nil {
143143
self?.service = nil
@@ -199,8 +199,16 @@ extension ChatroomView: GiftMessageListTransformAnimationDataSource {
199199
extension ChatroomView: MessageListActionEventsHandler {
200200

201201
public func onMessageLongPressed(message: ChatMessage) {
202+
203+
self.showLongPressDialog(message: message, messageActions: self.filterMessageActions(message: message))
204+
for delegate in self.eventHandlers.allObjects {
205+
delegate.onMessageLongPressed(message: message)
206+
}
207+
}
208+
209+
@objc open func filterMessageActions(message: ChatMessage) -> [ActionSheetItemProtocol] {
202210
if message.body.type == .custom {
203-
return
211+
return []
204212
}
205213
let currentUser = ChatroomContext.shared?.currentUser?.userId ?? ""
206214
var messageActions = [ActionSheetItemProtocol]()
@@ -255,10 +263,7 @@ extension ChatroomView: MessageListActionEventsHandler {
255263
if message.from.lowercased() != currentUser.lowercased() {
256264
messageActions.removeAll { $0.tag == "Recall" }
257265
}
258-
self.showLongPressDialog(message: message, messageActions: messageActions)
259-
for delegate in self.eventHandlers.allObjects {
260-
delegate.onMessageLongPressed(message: message)
261-
}
266+
return messageActions
262267
}
263268

264269
private func showLongPressDialog(message: ChatMessage,messageActions: [ActionSheetItemProtocol]) {

Sources/ChatroomUIKit/Classes/UI/Core/UIKit/Utils/ComponentsRegister.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ fileprivate let component = ComponentsRegister()
3838

3939
public var MessageEntity: ChatEntity.Type = ChatEntity.self
4040

41+
public var RoomView: ChatroomView.Type = ChatroomView.self
42+
43+
public var RoomViewService: RoomService.Type = RoomService.self
44+
4145
}

0 commit comments

Comments
 (0)