mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add hooks for the RoomDetails, RoomMemberDetails and UserProfile screens. (#5980)
Also adds an @AppHook macro.
This commit is contained in:
@@ -13,8 +13,9 @@ struct UserProfileScreenCoordinatorParameters {
|
||||
let userID: String
|
||||
let isPresentedModally: Bool
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appHooks: AppHooks
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
enum UserProfileScreenCoordinatorAction {
|
||||
@@ -37,8 +38,9 @@ final class UserProfileScreenCoordinator: CoordinatorProtocol {
|
||||
viewModel = UserProfileScreenViewModel(userID: parameters.userID,
|
||||
isPresentedModally: parameters.isPresentedModally,
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
analytics: parameters.analytics)
|
||||
appHooks: parameters.appHooks,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -24,6 +24,7 @@ struct UserProfileScreenViewState: BindableState {
|
||||
var isVerified: Bool?
|
||||
var permalink: URL?
|
||||
var dmRoomID: String?
|
||||
var isCallingEnabled = true
|
||||
|
||||
var bindings: UserProfileScreenViewStateBindings
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ typealias UserProfileScreenViewModelType = StateStoreViewModelV2<UserProfileScre
|
||||
|
||||
class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScreenViewModelProtocol {
|
||||
private let userSession: UserSessionProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let analytics: AnalyticsServiceProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private var actionsSubject: PassthroughSubject<UserProfileScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<UserProfileScreenViewModelAction, Never> {
|
||||
@@ -25,18 +25,20 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
init(userID: String,
|
||||
isPresentedModally: Bool,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
analytics: AnalyticsServiceProtocol) {
|
||||
appHooks: AppHooks,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userSession = userSession
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
let initialViewState = UserProfileScreenViewState(userID: userID,
|
||||
isOwnUser: userID == userSession.clientProxy.userID,
|
||||
isPresentedModally: isPresentedModally,
|
||||
bindings: .init())
|
||||
|
||||
super.init(initialViewState: initialViewState, mediaProvider: userSession.mediaProvider)
|
||||
super.init(initialViewState: appHooks.userProfileScreenHook.update(initialViewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
showLoadingIndicator(allowsInteraction: true)
|
||||
Task {
|
||||
|
||||
@@ -65,7 +65,7 @@ struct UserProfileScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.roomMemberDetailsScreen.directChat)
|
||||
}
|
||||
|
||||
if let roomID = context.viewState.dmRoomID {
|
||||
if let roomID = context.viewState.dmRoomID, context.viewState.isCallingEnabled {
|
||||
Button {
|
||||
context.send(viewAction: .startCall(roomID: roomID, isVoiceCall: true))
|
||||
} label: {
|
||||
@@ -147,7 +147,8 @@ struct UserProfileScreen_Previews: PreviewProvider, TestablePreview {
|
||||
return UserProfileScreenViewModel(userID: userID,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: AnalyticsServiceMock(.init()))
|
||||
appHooks: AppHooks(),
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user