Add a UserProfileScreen for profiles of non-members. (#2687)

This commit is contained in:
Doug
2024-04-12 09:54:14 +01:00
committed by GitHub
parent 47912d999b
commit 5c9d0975ce
22 changed files with 520 additions and 56 deletions
@@ -26,6 +26,7 @@ struct RoomMemberDetailsScreenCoordinatorParameters {
}
enum RoomMemberDetailsScreenCoordinatorAction {
case openUserProfile
case openDirectChat(displayName: String?)
}
@@ -52,6 +53,8 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
guard let self else { return }
switch action {
case .openUserProfile:
actionsSubject.send(.openUserProfile)
case .openDirectChat(let displayName):
actionsSubject.send(.openDirectChat(displayName: displayName))
}
@@ -17,6 +17,7 @@
import Foundation
enum RoomMemberDetailsScreenViewModelAction {
case openUserProfile
case openDirectChat(displayName: String?)
}
@@ -59,8 +59,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
state.memberDetails = RoomMemberDetails(withProxy: member)
state.isOwnMemberDetails = member.userID == roomProxy.ownUserID
case .failure(let error):
state.bindings.alertInfo = .init(id: .unknown)
MXLog.error("[RoomFlowCoordinator] Failed to get member: \(error)")
MXLog.warning("Failed to find member: \(error)")
actionsSubject.send(.openUserProfile)
}
}
}
@@ -21,19 +21,6 @@ struct RoomMemberDetailsScreen: View {
@ObservedObject var context: RoomMemberDetailsScreenViewModel.Context
var body: some View {
content
.compoundList()
.navigationTitle(L10n.screenRoomMemberDetailsTitle)
.alert(item: $context.ignoreUserAlert, actions: blockUserAlertActions, message: blockUserAlertMessage)
.alert(item: $context.alertInfo)
.track(screen: .User)
.interactiveQuickLook(item: $context.mediaPreviewItem, shouldHideControls: true)
}
// MARK: - Private
@ViewBuilder
private var content: some View {
Form {
headerSection
@@ -42,8 +29,16 @@ struct RoomMemberDetailsScreen: View {
blockUserSection
}
}
.compoundList()
.navigationTitle(L10n.screenRoomMemberDetailsTitle)
.alert(item: $context.ignoreUserAlert, actions: blockUserAlertActions, message: blockUserAlertMessage)
.alert(item: $context.alertInfo)
.track(screen: .User)
.interactiveQuickLook(item: $context.mediaPreviewItem, shouldHideControls: true)
}
// MARK: - Private
@ViewBuilder
private var headerSection: some View {
if let memberDetails = context.viewState.memberDetails {
@@ -63,7 +58,7 @@ struct RoomMemberDetailsScreen: View {
}
}
} else {
AvatarHeaderView(member: .init(loading: context.viewState.userID),
AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID),
avatarSize: .user(on: .memberDetails),
imageProvider: context.imageProvider,
footer: { })