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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
56 changed files with 243 additions and 147 deletions

View File

@ -63,6 +63,7 @@
"action_leave_room" = "Leave room"; "action_leave_room" = "Leave room";
"action_manage_account" = "Manage account"; "action_manage_account" = "Manage account";
"action_manage_devices" = "Manage devices"; "action_manage_devices" = "Manage devices";
"action_message" = "Message";
"action_next" = "Next"; "action_next" = "Next";
"action_no" = "No"; "action_no" = "No";
"action_not_now" = "Not now"; "action_not_now" = "Not now";

View File

@ -176,6 +176,14 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
} }
} }
private func presentCallScreen(roomID: String) async {
guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else {
return
}
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy))
}
private func handleRoomRoute(roomID: String, focussedEventID: String? = nil, animated: Bool) async { private func handleRoomRoute(roomID: String, focussedEventID: String? = nil, animated: Bool) async {
guard roomID == self.roomID else { fatalError("Navigation route doesn't belong to this room flow.") } guard roomID == self.roomID else { fatalError("Navigation route doesn't belong to this room flow.") }
@ -1064,6 +1072,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.presentUserProfile(userID: userID)) stateMachine.tryEvent(.presentUserProfile(userID: userID))
case .openDirectChat(let roomID): case .openDirectChat(let roomID):
stateMachine.tryEvent(.startChildFlow(roomID: roomID, entryPoint: .room)) stateMachine.tryEvent(.startChildFlow(roomID: roomID, entryPoint: .room))
case .startCall(let roomID):
Task { await self.presentCallScreen(roomID: roomID) }
} }
} }
.store(in: &cancellables) .store(in: &cancellables)
@ -1087,6 +1097,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
switch action { switch action {
case .openDirectChat(let roomID): case .openDirectChat(let roomID):
stateMachine.tryEvent(.startChildFlow(roomID: roomID, entryPoint: .room)) stateMachine.tryEvent(.startChildFlow(roomID: roomID, entryPoint: .room))
case .startCall(let roomID):
Task { await self.presentCallScreen(roomID: roomID) }
case .dismiss: case .dismiss:
break // Not supported when pushed. break // Not supported when pushed.
} }
@ -1094,11 +1106,14 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
.store(in: &cancellables) .store(in: &cancellables)
// Replace the RoomMemberDetailsScreen without any animation. // Replace the RoomMemberDetailsScreen without any animation.
navigationStackCoordinator.pop(animated: false) // If this pop and push happens before the previous navigation is completed it might break screen presentation logic
navigationStackCoordinator.push(coordinator, animated: false) { [weak self] in DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
self.navigationStackCoordinator.pop(animated: false)
self.navigationStackCoordinator.push(coordinator, animated: false) { [weak self] in
self?.stateMachine.tryEvent(.dismissUserProfile) self?.stateMachine.tryEvent(.dismissUserProfile)
} }
} }
}
private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) { private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) {
guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else { guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else {

View File

@ -238,10 +238,10 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.processEvent(.showUserProfileScreen(userID: userID), userInfo: .init(animated: animated)) stateMachine.processEvent(.showUserProfileScreen(userID: userID), userInfo: .init(animated: animated))
case .genericCallLink(let url): case .genericCallLink(let url):
navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)), animated: animated) navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)), animated: animated)
case .oidcCallback:
break
case .settings, .chatBackupSettings: case .settings, .chatBackupSettings:
settingsFlowCoordinator.handleAppRoute(appRoute, animated: animated) settingsFlowCoordinator.handleAppRoute(appRoute, animated: animated)
case .oidcCallback:
break
} }
} }
@ -595,6 +595,14 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
navigationSplitCoordinator.setSheetCoordinator(callScreenCoordinator, animated: true) navigationSplitCoordinator.setSheetCoordinator(callScreenCoordinator, animated: true)
} }
private func presentCallScreen(roomID: String) async {
guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else {
return
}
presentCallScreen(roomProxy: roomProxy)
}
// MARK: Secure backup confirmation // MARK: Secure backup confirmation
private func presentSecureBackupLogoutConfirmationScreen() { private func presentSecureBackupLogoutConfirmationScreen() {
@ -706,6 +714,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
case .openDirectChat(let roomID): case .openDirectChat(let roomID):
navigationSplitCoordinator.setSheetCoordinator(nil) navigationSplitCoordinator.setSheetCoordinator(nil)
stateMachine.processEvent(.selectRoom(roomID: roomID, entryPoint: .room)) stateMachine.processEvent(.selectRoom(roomID: roomID, entryPoint: .room))
case .startCall(let roomID):
Task { await self.presentCallScreen(roomID: roomID) }
case .dismiss: case .dismiss:
navigationSplitCoordinator.setSheetCoordinator(nil) navigationSplitCoordinator.setSheetCoordinator(nil)
} }

View File

@ -160,6 +160,8 @@ internal enum L10n {
internal static var actionManageAccount: String { return L10n.tr("Localizable", "action_manage_account") } internal static var actionManageAccount: String { return L10n.tr("Localizable", "action_manage_account") }
/// Manage devices /// Manage devices
internal static var actionManageDevices: String { return L10n.tr("Localizable", "action_manage_devices") } internal static var actionManageDevices: String { return L10n.tr("Localizable", "action_manage_devices") }
/// Message
internal static var actionMessage: String { return L10n.tr("Localizable", "action_message") }
/// Next /// Next
internal static var actionNext: String { return L10n.tr("Localizable", "action_next") } internal static var actionNext: String { return L10n.tr("Localizable", "action_next") }
/// No /// No

View File

@ -22,19 +22,22 @@ struct FormActionButtonStyle: ButtonStyle {
let title: String let title: String
func makeBody(configuration: Configuration) -> some View { func makeBody(configuration: Configuration) -> some View {
VStack(spacing: 8) { VStack(spacing: 4) {
configuration.label configuration.label
.buttonStyle(.plain) .buttonStyle(.plain)
.foregroundColor(.compound.textPrimary) .foregroundColor(.compound.iconSecondary)
.scaledFrame(size: 54) .scaledFrame(size: 24)
.background {
RoundedRectangle(cornerRadius: 16)
.fill(configuration.isPressed ? Color.compound.bgSubtlePrimary : .compound.bgCanvasDefaultLevel1)
}
Text(title) Text(title)
.foregroundColor(.compound.textSecondary) .foregroundColor(.compound.textPrimary)
.font(.compound.bodyMD) .font(.compound.bodyLG)
}
.padding(.horizontal, 4)
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
.background {
RoundedRectangle(cornerRadius: 14)
.fill(configuration.isPressed ? Color.compound.bgSubtlePrimary : .compound.bgCanvasDefaultLevel1)
} }
} }
} }

View File

@ -106,6 +106,10 @@ struct AvatarHeaderView<Footer: View>: View {
} }
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.listRowBackground(Color.clear) .listRowBackground(Color.clear)
.listRowInsets(EdgeInsets(top: 11,
leading: 0,
bottom: 11,
trailing: 0))
} }
} }

View File

@ -97,7 +97,7 @@ struct RoomDetailsScreen: View {
@ViewBuilder @ViewBuilder
private var headerSectionShortcuts: some View { private var headerSectionShortcuts: some View {
HStack(spacing: 32) { HStack(spacing: 8) {
ForEach(context.viewState.shortcuts, id: \.self) { shortcut in ForEach(context.viewState.shortcuts, id: \.self) { shortcut in
switch shortcut { switch shortcut {
case .mute: case .mute:

View File

@ -29,6 +29,7 @@ struct RoomMemberDetailsScreenCoordinatorParameters {
enum RoomMemberDetailsScreenCoordinatorAction { enum RoomMemberDetailsScreenCoordinatorAction {
case openUserProfile case openUserProfile
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String)
} }
final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol { final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
@ -59,6 +60,8 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.openUserProfile) actionsSubject.send(.openUserProfile)
case .openDirectChat(let roomID): case .openDirectChat(let roomID):
actionsSubject.send(.openDirectChat(roomID: roomID)) actionsSubject.send(.openDirectChat(roomID: roomID))
case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID))
} }
} }
.store(in: &cancellables) .store(in: &cancellables)

View File

@ -19,6 +19,7 @@ import Foundation
enum RoomMemberDetailsScreenViewModelAction { enum RoomMemberDetailsScreenViewModelAction {
case openUserProfile case openUserProfile
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String)
} }
struct RoomMemberDetailsScreenViewState: BindableState { struct RoomMemberDetailsScreenViewState: BindableState {
@ -26,6 +27,7 @@ struct RoomMemberDetailsScreenViewState: BindableState {
var memberDetails: RoomMemberDetails? var memberDetails: RoomMemberDetails?
var isOwnMemberDetails = false var isOwnMemberDetails = false
var isProcessingIgnoreRequest = false var isProcessingIgnoreRequest = false
var dmRoomID: String?
var bindings: RoomMemberDetailsScreenViewStateBindings var bindings: RoomMemberDetailsScreenViewStateBindings
} }
@ -83,6 +85,7 @@ enum RoomMemberDetailsScreenViewAction {
case unignoreConfirmed case unignoreConfirmed
case displayAvatar case displayAvatar
case openDirectChat case openDirectChat
case startCall(roomID: String)
} }
enum RoomMemberDetailsScreenError: Hashable { enum RoomMemberDetailsScreenError: Hashable {

View File

@ -61,6 +61,12 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
roomMemberProxy = member roomMemberProxy = member
state.memberDetails = RoomMemberDetails(withProxy: member) state.memberDetails = RoomMemberDetails(withProxy: member)
state.isOwnMemberDetails = member.userID == roomProxy.ownUserID state.isOwnMemberDetails = member.userID == roomProxy.ownUserID
switch await clientProxy.directRoomForUserID(member.userID) {
case .success(let roomID):
state.dmRoomID = roomID
case .failure:
break
}
case .failure(let error): case .failure(let error):
MXLog.warning("Failed to find member: \(error)") MXLog.warning("Failed to find member: \(error)")
actionsSubject.send(.openUserProfile) actionsSubject.send(.openUserProfile)
@ -91,6 +97,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
Task { await displayFullScreenAvatar() } Task { await displayFullScreenAvatar() }
case .openDirectChat: case .openDirectChat:
Task { await openDirectChat() } Task { await openDirectChat() }
case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID))
} }
} }

View File

@ -25,7 +25,6 @@ struct RoomMemberDetailsScreen: View {
headerSection headerSection
if context.viewState.memberDetails != nil, !context.viewState.isOwnMemberDetails { if context.viewState.memberDetails != nil, !context.viewState.isOwnMemberDetails {
directChatSection
blockUserSection blockUserSection
} }
} }
@ -39,6 +38,38 @@ struct RoomMemberDetailsScreen: View {
// MARK: - Private // MARK: - Private
@ViewBuilder
private var otherUserFooter: some View {
HStack(spacing: 8) {
if context.viewState.memberDetails != nil, !context.viewState.isOwnMemberDetails {
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.memberDetails?.permalink {
ShareLink(item: permalink) {
CompoundIcon(\.shareIos)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionShare))
}
}
.padding(.top, 32)
}
@ViewBuilder @ViewBuilder
private var headerSection: some View { private var headerSection: some View {
if let memberDetails = context.viewState.memberDetails { if let memberDetails = context.viewState.memberDetails {
@ -47,15 +78,7 @@ struct RoomMemberDetailsScreen: View {
imageProvider: context.imageProvider) { imageProvider: context.imageProvider) {
context.send(viewAction: .displayAvatar) context.send(viewAction: .displayAvatar)
} footer: { } footer: {
if let permalink = memberDetails.permalink { otherUserFooter
HStack(spacing: 32) {
ShareLink(item: permalink) {
CompoundIcon(\.shareIos)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionShare))
}
.padding(.top, 32)
}
} }
} else { } else {
AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID), AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID),
@ -65,17 +88,6 @@ struct RoomMemberDetailsScreen: 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)
}
}
@ViewBuilder @ViewBuilder
private var blockUserSection: some View { private var blockUserSection: some View {
if let memberDetails = context.viewState.memberDetails { if let memberDetails = context.viewState.memberDetails {
@ -134,9 +146,16 @@ struct RoomMemberDetailsScreen_Previews: PreviewProvider, TestablePreview {
let roomProxyMock = RoomProxyMock(with: .init(name: "")) let roomProxyMock = RoomProxyMock(with: .init(name: ""))
roomProxyMock.getMemberUserIDReturnValue = .success(member) roomProxyMock.getMemberUserIDReturnValue = .success(member)
let clientProxyMock = ClientProxyMock(.init())
// to avoid mock the call state for the account owner test case
if member.userID != RoomMemberProxyMock.mockMe.userID {
clientProxyMock.directRoomForUserIDReturnValue = .success("roomID")
}
return RoomMemberDetailsScreenViewModel(userID: member.userID, return RoomMemberDetailsScreenViewModel(userID: member.userID,
roomProxy: roomProxyMock, roomProxy: roomProxyMock,
clientProxy: ClientProxyMock(.init()), clientProxy: clientProxyMock,
mediaProvider: MockMediaProvider(), mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController, userIndicatorController: ServiceLocator.shared.userIndicatorController,
analytics: ServiceLocator.shared.analytics) analytics: ServiceLocator.shared.analytics)

View File

@ -28,6 +28,7 @@ struct UserProfileScreenCoordinatorParameters {
enum UserProfileScreenCoordinatorAction { enum UserProfileScreenCoordinatorAction {
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String)
case dismiss case dismiss
} }
@ -57,6 +58,8 @@ final class UserProfileScreenCoordinator: CoordinatorProtocol {
switch action { switch action {
case .openDirectChat(let roomID): case .openDirectChat(let roomID):
actionsSubject.send(.openDirectChat(roomID: roomID)) actionsSubject.send(.openDirectChat(roomID: roomID))
case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID))
case .dismiss: case .dismiss:
actionsSubject.send(.dismiss) actionsSubject.send(.dismiss)
} }

View File

@ -18,6 +18,7 @@ import Foundation
enum UserProfileScreenViewModelAction { enum UserProfileScreenViewModelAction {
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String)
case dismiss case dismiss
} }
@ -28,6 +29,7 @@ struct UserProfileScreenViewState: BindableState {
var userProfile: UserProfileProxy? var userProfile: UserProfileProxy?
var permalink: URL? var permalink: URL?
var dmRoomID: String?
var bindings: UserProfileScreenViewStateBindings var bindings: UserProfileScreenViewStateBindings
} }
@ -42,6 +44,7 @@ struct UserProfileScreenViewStateBindings {
enum UserProfileScreenViewAction { enum UserProfileScreenViewAction {
case displayAvatar case displayAvatar
case openDirectChat case openDirectChat
case startCall(roomID: String)
case dismiss case dismiss
} }

View File

@ -59,6 +59,12 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
case .success(let userProfile): case .success(let userProfile):
state.userProfile = userProfile state.userProfile = userProfile
state.permalink = (try? matrixToUserPermalink(userId: userID)).flatMap(URL.init(string:)) state.permalink = (try? matrixToUserPermalink(userId: userID)).flatMap(URL.init(string:))
switch await clientProxy.directRoomForUserID(userProfile.userID) {
case .success(let roomID):
state.dmRoomID = roomID
case .failure:
break
}
case .failure(let error): case .failure(let error):
state.bindings.alertInfo = .init(id: .unknown) state.bindings.alertInfo = .init(id: .unknown)
MXLog.error("Failed to find user profile: \(error)") MXLog.error("Failed to find user profile: \(error)")
@ -81,6 +87,8 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
Task { await displayFullScreenAvatar() } Task { await displayFullScreenAvatar() }
case .openDirectChat: case .openDirectChat:
Task { await openDirectChat() } Task { await openDirectChat() }
case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID))
case .dismiss: case .dismiss:
actionsSubject.send(.dismiss) actionsSubject.send(.dismiss)
} }

View File

@ -23,10 +23,6 @@ struct UserProfileScreen: View {
var body: some View { var body: some View {
Form { Form {
headerSection headerSection
if context.viewState.userProfile != nil, !context.viewState.isOwnUser {
directChatSection
}
} }
.compoundList() .compoundList()
.navigationTitle(L10n.screenRoomMemberDetailsTitle) .navigationTitle(L10n.screenRoomMemberDetailsTitle)
@ -39,6 +35,38 @@ struct UserProfileScreen: View {
// MARK: - Private // 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 @ViewBuilder
private var headerSection: some View { private var headerSection: some View {
if let userProfile = context.viewState.userProfile { if let userProfile = context.viewState.userProfile {
@ -47,15 +75,7 @@ struct UserProfileScreen: View {
imageProvider: context.imageProvider) { imageProvider: context.imageProvider) {
context.send(viewAction: .displayAvatar) context.send(viewAction: .displayAvatar)
} footer: { } footer: {
if let permalink = context.viewState.permalink { otherUserFooter
HStack(spacing: 32) {
ShareLink(item: permalink) {
CompoundIcon(\.shareIos)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionShare))
}
.padding(.top, 32)
}
} }
} else { } else {
AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID), 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 @ToolbarContentBuilder
private var toolbar: some ToolbarContent { private var toolbar: some ToolbarContent {
if context.viewState.isPresentedModally { if context.viewState.isPresentedModally {
@ -104,9 +113,13 @@ struct UserProfileScreen_Previews: PreviewProvider, TestablePreview {
} }
static func makeViewModel(userID: String) -> UserProfileScreenViewModel { static func makeViewModel(userID: String) -> UserProfileScreenViewModel {
UserProfileScreenViewModel(userID: userID, let clientProxyMock = ClientProxyMock(.init())
if userID != RoomMemberProxyMock.mockMe.userID {
clientProxyMock.directRoomForUserIDReturnValue = .success("roomID")
}
return UserProfileScreenViewModel(userID: userID,
isPresentedModally: false, isPresentedModally: false,
clientProxy: ClientProxyMock(.init()), clientProxy: clientProxyMock,
mediaProvider: MockMediaProvider(), mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController, userIndicatorController: ServiceLocator.shared.userIndicatorController,
analytics: ServiceLocator.shared.analytics) analytics: ServiceLocator.shared.analytics)

1
changelog.d/2816.change Normal file
View File

@ -0,0 +1 @@
The UX of the profile of other users has been updated.