增加换肤功能

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,48 @@
//
// ConferenceListActions.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/6/12.
//
import Foundation
import RTCRoomEngine
enum ConferenceListActions {
static let key = "action.conferenceList"
static let fetchConferenceList = ActionTemplate(id: key.appending(".fetchConferenceList"),
payloadType: (String, Int).self)
static let scheduleConference = ActionTemplate(id: key.appending(".scheduleConference"),
payloadType: TUIConferenceInfo.self)
static let cancelConference = ActionTemplate(id: key.appending(".cancelConference"),
payloadType: String.self)
static let updateConferenceInfo = ActionTemplate(id: key.appending(".updateConferenceInfo"),
payloadType: (TUIConferenceInfo, TUIConferenceModifyFlag).self)
static let addAttendeesByAdmin = ActionTemplate(id: key.appending(".addAttendeesByAdmin"),
payloadType: (String, [String]).self)
static let removeAttendeesByAdmin = ActionTemplate(id: key.appending(".removeAttendeesByAdmin"),
payloadType: (String, [String]).self)
static let resetConferenceList = ActionTemplate(id: key.appending(".resetConferenceList"))
// MARK: callback
static let updateConferenceList = ActionTemplate(id: key.appending(".updateConferenceList"), payloadType: ([ConferenceInfo], String).self)
static let insertConference = ActionTemplate(id: key.appending(".insertConference"), payloadType: ConferenceInfo.self)
static let removeConference = ActionTemplate(id: key.appending(".removeConference"), payloadType: String.self)
static let onConferenceUpdated = ActionTemplate(id: key.appending(".onConferenceUpdated"), payloadType: ConferenceInfo.self)
static let onScheduleSuccess = ActionTemplate(id: key.appending("onScheduleSuccess"), payloadType: TUIConferenceInfo.self)
static let onCancelSuccess = ActionTemplate(id: key.appending("onCancelSuccess"))
static let onUpdateInfoSuccess = ActionTemplate(id: key.appending("onUpdateInfoSuccess"))
static let onAddAttendeesSuccess = ActionTemplate(id: key.appending("onAddAttendeesSuccess"))
static let onRemoveAttendeesSuccess = ActionTemplate(id: key.appending("onRemoveAttendeesSuccess"))
}
// MARK: - Subject action, only event, no reduce.
enum ScheduleResponseActions {
static let key = "action.schedule.response"
static let onScheduleSuccess = ActionTemplate(id: key.appending("onScheduleSuccess"), payloadType: TUIConferenceInfo.self)
static let onCancelSuccess = ActionTemplate(id: key.appending("onScheduleSuccess"))
static let onUpdateInfoSuccess = ActionTemplate(id: key.appending("onUpdateInfoSuccess"))
}

View File

@@ -0,0 +1,120 @@
//
// ConferenceListEffects.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/6/12.
//
import Foundation
import RTCRoomEngine
import Combine
class ConferenceListEffects: Effects {
typealias Environment = ServiceCenter
let scheduleConference = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: ConferenceListActions.scheduleConference)
.flatMap { action in
environment.conferenceListService.scheduleConference(conferenceInfo: action.payload)
.map { conferenceInfo in
ConferenceListActions.onScheduleSuccess(payload: conferenceInfo)
}
.catch { error -> Just<Action> in
Just(ErrorActions.throwError(payload: error))
}
}
.eraseToAnyPublisher()
}
let cancelConference = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: ConferenceListActions.cancelConference)
.flatMap { action in
environment.conferenceListService.cancelConference(conferenceId: action.payload)
.map { _ in
ConferenceListActions.onCancelSuccess()
}
.catch { error -> Just<Action> in
Just(ErrorActions.throwError(payload: error))
}
}
.eraseToAnyPublisher()
}
let updateConferenceInfo = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: ConferenceListActions.updateConferenceInfo)
.flatMap { action in
environment.conferenceListService.updateConferenceInfo(conferenceInfo: action.payload.0,
modifyFlag: action.payload.1)
.map { _ in
ConferenceListActions.onUpdateInfoSuccess()
}
.catch { error -> Just<Action> in
Just(ErrorActions.throwError(payload: error))
}
}
.eraseToAnyPublisher()
}
let fetchConferenceList = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: ConferenceListActions.fetchConferenceList)
.flatMap { action in
environment.conferenceListService.fetchConferenceList(status: [.notStarted, .running],
cursor: action.payload.0,
count: action.payload.1)
.map { (conferenceList, cursor) in
ConferenceListActions.updateConferenceList(payload: (conferenceList, cursor))
}
.catch { error -> Just<Action> in
Just(ErrorActions.throwError(payload: error))
}
}
.eraseToAnyPublisher()
}
let addAttendeesByAdmin = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: ConferenceListActions.addAttendeesByAdmin)
.flatMap { action in
environment.conferenceListService.addAttendeesByAdmin(conferenceId: action.payload.0, userIdList: action.payload.1)
.map { _ in
ConferenceListActions.onAddAttendeesSuccess()
}
.catch { error -> Just<Action> in
Just(ErrorActions.throwError(payload: error))
}
}
.eraseToAnyPublisher()
}
let removeAttendeesByAdmin = Effect<Environment>.dispatchingOne { actions, environment in
actions.wasCreated(from: ConferenceListActions.removeAttendeesByAdmin)
.flatMap { action in
environment.conferenceListService.removeAttendeesByAdmin(conferenceId: action.payload.0, userIdList: action.payload.1)
.map { _ in
ConferenceListActions.onRemoveAttendeesSuccess()
}
.catch { error -> Just<Action> in
Just(ErrorActions.throwError(payload: error))
}
}
.eraseToAnyPublisher()
}
let onScheduleSuccess = Effect<Environment>.nonDispatching { actions, environment in
actions
.wasCreated(from: ConferenceListActions.onScheduleSuccess)
.sink { action in
let conferenceInfo = action.payload
environment.store?.dispatch(action: ScheduleResponseActions.onScheduleSuccess(payload: conferenceInfo))
}
}
let onCancelSuccess = Effect<Environment>.nonDispatching { actions, environment in
actions
.wasCreated(from: ConferenceListActions.onCancelSuccess)
.sink { action in
environment.store?.dispatch(action: ScheduleResponseActions.onCancelSuccess())
}
}
}

View File

@@ -0,0 +1,39 @@
//
// Conference.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/6/12.
//
import Foundation
let ConferenceListReducer = Reducer<ConferenceListState>(
ReduceOn(ConferenceListActions.updateConferenceList, reduce: { state, action in
let incomingConferences = action.payload.0
let previousConferences = state.scheduledConferences
let combinedSet = Set(incomingConferences + previousConferences)
state.scheduledConferences = Array(combinedSet)
state.fetchScheduledConferencesCursor = action.payload.1
}),
ReduceOn(ConferenceListActions.insertConference, reduce: { state, action in
if !state.scheduledConferences.contains(action.payload) {
state.scheduledConferences.append(action.payload)
}
}),
ReduceOn(ConferenceListActions.removeConference, reduce: { state, action in
let conferenceToRemove = action.payload
let conferences = state.scheduledConferences.map { $0.basicInfo.roomId }
if let index = conferences.firstIndex(of: conferenceToRemove) {
state.scheduledConferences.remove(at: index)
}
}),
ReduceOn(ConferenceListActions.onConferenceUpdated, reduce: { state, action in
let conference = action.payload
if let index = state.scheduledConferences.firstIndex(where: { $0.basicInfo.roomId == conference.basicInfo.roomId }) {
state.scheduledConferences[index] = conference
}
}),
ReduceOn(ConferenceListActions.resetConferenceList, reduce: { state, action in
state.scheduledConferences.removeAll()
})
)

View File

@@ -0,0 +1,15 @@
//
// ConferenceListSelectors.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/6/12.
//
import Foundation
enum ConferenceListSelectors {
static let getConferenceListState = Selector(keyPath: \OperationState.conferenceListState)
static let getConferenceList = Selector.with(getConferenceListState, keyPath:\ConferenceListState.scheduledConferences)
static let getConferenceListCursor = Selector.with(getConferenceListState, keyPath:\ConferenceListState.fetchScheduledConferencesCursor)
}