mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
DM Design Tweaks (#3693)
* dm design tweaks * adding equatable conformance * topic will now be shown in DMs * code suggestion * updated details * better check * code improvement
This commit is contained in:
@@ -22,6 +22,7 @@ struct RoomDetailsScreenCoordinatorParameters {
|
||||
enum RoomDetailsScreenCoordinatorAction {
|
||||
case leftRoom
|
||||
case presentRoomMembersList
|
||||
case presentRecipientDetails(userID: String)
|
||||
case presentRoomDetailsEditScreen
|
||||
case presentNotificationSettingsScreen
|
||||
case presentInviteUsersScreen
|
||||
@@ -88,6 +89,8 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.presentKnockingRequestsListScreen)
|
||||
case .displaySecurityAndPrivacy:
|
||||
actionsSubject.send(.presentSecurityAndPrivacyScreen)
|
||||
case .requestRecipientDetailsPresentation(let userID):
|
||||
actionsSubject.send(.presentRecipientDetails(userID: userID))
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -12,9 +12,10 @@ import SwiftUI
|
||||
|
||||
// MARK: View model
|
||||
|
||||
enum RoomDetailsScreenViewModelAction {
|
||||
enum RoomDetailsScreenViewModelAction: Equatable {
|
||||
case requestNotificationSettingsPresentation
|
||||
case requestMemberDetailsPresentation
|
||||
case requestRecipientDetailsPresentation(userID: String)
|
||||
case requestInvitePeoplePresentation
|
||||
case leftRoom
|
||||
case requestEditDetailsPresentation
|
||||
@@ -68,7 +69,7 @@ struct RoomDetailsScreenViewState: BindableState {
|
||||
}
|
||||
|
||||
var hasTopicSection: Bool {
|
||||
topic != nil || (canEdit && canEditRoomTopic)
|
||||
topic != nil || canEditRoomTopic
|
||||
}
|
||||
|
||||
var bindings: RoomDetailsScreenViewStateBindings
|
||||
@@ -198,6 +199,7 @@ enum RoomDetailsScreenViewAction {
|
||||
case ignoreConfirmed
|
||||
case unignoreConfirmed
|
||||
case processTapNotifications
|
||||
case processTapRecipientProfile
|
||||
case processToggleMuteNotifications
|
||||
case displayAvatar(URL)
|
||||
case processTapPolls
|
||||
|
||||
@@ -170,6 +170,11 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
actionsSubject.send(.displayKnockingRequests)
|
||||
case .processTapSecurityAndPrivacy:
|
||||
actionsSubject.send(.displaySecurityAndPrivacy)
|
||||
case .processTapRecipientProfile:
|
||||
guard let userID = dmRecipient?.userID else {
|
||||
return
|
||||
}
|
||||
actionsSubject.send(.requestRecipientDetailsPresentation(userID: userID))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,7 @@ struct RoomDetailsScreen: View {
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
if let recipient = context.viewState.dmRecipient,
|
||||
let accountOwner = context.viewState.accountOwner {
|
||||
dmHeaderSection(accountOwner: accountOwner,
|
||||
recipient: recipient)
|
||||
} else {
|
||||
normalRoomHeaderSection
|
||||
}
|
||||
roomHeaderSection
|
||||
|
||||
topicSection
|
||||
|
||||
@@ -66,7 +60,7 @@ struct RoomDetailsScreen: View {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private var normalRoomHeaderSection: some View {
|
||||
private var roomHeaderSection: some View {
|
||||
AvatarHeaderView(room: context.viewState.details,
|
||||
avatarSize: .room(on: .details),
|
||||
mediaProvider: context.mediaProvider) { url in
|
||||
@@ -79,19 +73,6 @@ struct RoomDetailsScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.avatar)
|
||||
}
|
||||
|
||||
private func dmHeaderSection(accountOwner: RoomMemberDetails, recipient: RoomMemberDetails) -> some View {
|
||||
AvatarHeaderView(accountOwner: accountOwner,
|
||||
dmRecipient: recipient,
|
||||
mediaProvider: context.mediaProvider) { url in
|
||||
context.send(viewAction: .displayAvatar(url))
|
||||
} footer: {
|
||||
if !context.viewState.shortcuts.isEmpty {
|
||||
headerSectionShortcuts
|
||||
}
|
||||
}
|
||||
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.dmAvatar)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var headerSectionShortcuts: some View {
|
||||
HStack(spacing: 8) {
|
||||
@@ -204,6 +185,14 @@ struct RoomDetailsScreen: View {
|
||||
context.send(viewAction: .processTapSecurityAndPrivacy)
|
||||
})
|
||||
}
|
||||
|
||||
if context.viewState.dmRecipient != nil {
|
||||
ListRow(label: .default(title: L10n.screenRoomDetailsProfileRowTitle,
|
||||
icon: \.userProfile),
|
||||
kind: .navigationLink {
|
||||
context.send(viewAction: .processTapRecipientProfile)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,12 +358,12 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
]
|
||||
|
||||
let roomProxy = JoinedRoomProxyMock(.init(id: "dm_room_id",
|
||||
name: "DM Room",
|
||||
name: "Dan",
|
||||
topic: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
||||
isDirect: true,
|
||||
isEncrypted: true,
|
||||
canonicalAlias: "#alias:domain.com",
|
||||
members: members))
|
||||
members: members,
|
||||
heroes: [.mockDan]))
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||
|
||||
return RoomDetailsScreenViewModel(roomProxy: roomProxy,
|
||||
|
||||
Reference in New Issue
Block a user