增加换肤功能

This commit is contained in:
启星
2025-08-14 10:07:49 +08:00
parent f6964c1e89
commit 4f9318d98e
8789 changed files with 978530 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
//
// FloatChatAction.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/10.
// Copyright © 2024 Tencent. All rights reserved.
//
import Foundation
enum FloatChatActions {
static let key = "FloatChat.chat"
static let sendMessage = ActionTemplate(id: key.appending(".sendMessage"), payloadType: String.self)
static let onMessageSended = ActionTemplate(id: key.appending(".messageSended"), payloadType: String.self)
static let onMessageReceived = ActionTemplate(id: key.appending(".messageReceived"), payloadType: FloatChatMessage.self)
static let setRoomId = ActionTemplate(id: key.appending(".setRoomId"), payloadType: String.self)
}
enum FloatViewActions {
static let key = "FloatChat.view"
static let showFloatInputView = ActionTemplate(id: key.appending(".show"), payloadType: Bool.self)
}

View File

@@ -0,0 +1,21 @@
//
// FloatChatEffect.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/14.
//
import Foundation
class FloatChatEffect: Effects {
typealias Environment = FloatChatService
let sendMessage = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: FloatChatActions.sendMessage)
.flatMap { action in
environment.sendGroupMessage(action.payload)
.map { FloatChatActions.onMessageSended(payload: $0) }
}
.eraseToAnyPublisher()
}
}

View File

@@ -0,0 +1,28 @@
//
// FloatChatReducer.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/10.
// Copyright © 2024 Tencent. All rights reserved.
//
import Foundation
import RTCRoomEngine
let floatChatReducer = Reducer<FloatChatState>(
ReduceOn(FloatChatActions.onMessageSended) { state, action in
let selfInfo = TUIRoomEngine.getSelfInfo()
let user = FloatChatUser(loginInfo: selfInfo)
let floatMessage = FloatChatMessage(user: user, content: action.payload)
state.latestMessage = floatMessage
},
ReduceOn(FloatChatActions.onMessageReceived) { state, action in
state.latestMessage = action.payload
},
ReduceOn(FloatViewActions.showFloatInputView) { state, action in
state.isFloatInputViewShow = action.payload
},
ReduceOn(FloatChatActions.setRoomId) { state, action in
state.roomId = action.payload
}
)

View File

@@ -0,0 +1,15 @@
//
// FloatChatSelectors.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/10.
// Copyright © 2024 Tencent. All rights reserved.
//
import Foundation
enum FloatChatSelectors {
static let getLatestMessage = Selector(keyPath: \FloatChatState.latestMessage)
static let getShowFloatInputView = Selector(keyPath: \FloatChatState.isFloatInputViewShow)
static let getRoomId = Selector(keyPath: \FloatChatState.roomId)
}

View File

@@ -0,0 +1,23 @@
//
// FloatChatState.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/10.
// Copyright © 2024 Tencent. All rights reserved.
//
import Foundation
import RTCRoomEngine
#if USE_OPENCOMBINE
import OpenCombine
#else
import Combine
#endif
protocol FloatChatStoreProvider {
func dispatch(action: Action)
func select<Value: Equatable>(_ selector: Selector<FloatChatState, Value>) -> AnyPublisher<Value, Never>
func selectCurrent<Value>(_ selector: Selector<FloatChatState, Value>) -> Value
}

View File

@@ -0,0 +1,53 @@
//
// ConferenceRoomStore.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/10.
//
import Foundation
#if USE_OPENCOMBINE
import OpenCombine
#else
import Combine
#endif
class FloatChatStore {
private(set) lazy var store: Store<FloatChatState, FloatChatService> = Store(initialState: FloatChatState(), environment: FloatChatService())
init() {
initStore()
}
deinit {
store.unregister(reducer: floatChatReducer)
store.unregisterEffects(withId: FloatChatEffect.id)
}
private func initStore() {
store.register(reducer: floatChatReducer)
store.register(effects: FloatChatEffect())
}
}
extension FloatChatStore: FloatChatStoreProvider {
func dispatch(action: Action) {
store.dispatch(action: action)
}
func select<Value>(_ selector: Selector<FloatChatState, Value>) -> AnyPublisher<Value, Never> where Value : Equatable {
return store.select(selector)
.removeDuplicates()
.eraseToAnyPublisher()
}
func selectCurrent<Value>(_ selector: Selector<FloatChatState, Value>) -> Value {
return store.selectCurrent(selector)
}
}