UX Update for user profile screen and room member details (#2822)

This commit is contained in:
Mauro
2024-05-09 17:41:09 +02:00
committed by GitHub
parent 1166400312
commit 783eab2a8a
56 changed files with 243 additions and 147 deletions
@@ -23,10 +23,6 @@ struct UserProfileScreen: View {
var body: some View {
Form {
headerSection
if context.viewState.userProfile != nil, !context.viewState.isOwnUser {
directChatSection
}
}
.compoundList()
.navigationTitle(L10n.screenRoomMemberDetailsTitle)
@@ -39,6 +35,38 @@ struct UserProfileScreen: View {
// MARK: - Private
@ViewBuilder
private var otherUserFooter: some View {
HStack(spacing: 8) {
if context.viewState.userProfile != nil, !context.viewState.isOwnUser {
Button {
context.send(viewAction: .openDirectChat)
} label: {
CompoundIcon(\.chat)
}
.buttonStyle(FormActionButtonStyle(title: L10n.commonMessage))
.accessibilityIdentifier(A11yIdentifiers.roomMemberDetailsScreen.directChat)
}
if let roomID = context.viewState.dmRoomID {
Button {
context.send(viewAction: .startCall(roomID: roomID))
} label: {
CompoundIcon(\.videoCall)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionCall))
}
if let permalink = context.viewState.permalink {
ShareLink(item: permalink) {
CompoundIcon(\.shareIos)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionShare))
}
}
.padding(.top, 32)
}
@ViewBuilder
private var headerSection: some View {
if let userProfile = context.viewState.userProfile {
@@ -47,15 +75,7 @@ struct UserProfileScreen: View {
imageProvider: context.imageProvider) {
context.send(viewAction: .displayAvatar)
} footer: {
if let permalink = context.viewState.permalink {
HStack(spacing: 32) {
ShareLink(item: permalink) {
CompoundIcon(\.shareIos)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionShare))
}
.padding(.top, 32)
}
otherUserFooter
}
} else {
AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID),
@@ -65,17 +85,6 @@ struct UserProfileScreen: View {
}
}
private var directChatSection: some View {
Section {
ListRow(label: .default(title: L10n.commonDirectChat,
icon: \.chat),
kind: .button {
context.send(viewAction: .openDirectChat)
})
.accessibilityIdentifier(A11yIdentifiers.roomMemberDetailsScreen.directChat)
}
}
@ToolbarContentBuilder
private var toolbar: some ToolbarContent {
if context.viewState.isPresentedModally {
@@ -104,11 +113,15 @@ struct UserProfileScreen_Previews: PreviewProvider, TestablePreview {
}
static func makeViewModel(userID: String) -> UserProfileScreenViewModel {
UserProfileScreenViewModel(userID: userID,
isPresentedModally: false,
clientProxy: ClientProxyMock(.init()),
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
analytics: ServiceLocator.shared.analytics)
let clientProxyMock = ClientProxyMock(.init())
if userID != RoomMemberProxyMock.mockMe.userID {
clientProxyMock.directRoomForUserIDReturnValue = .success("roomID")
}
return UserProfileScreenViewModel(userID: userID,
isPresentedModally: false,
clientProxy: clientProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
analytics: ServiceLocator.shared.analytics)
}
}