Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM Design Tweaks #3693

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"a11y_user_menu" = "User menu";
"a11y_voice_message_record" = "Record voice message.";
"a11y_voice_message_stop_recording" = "Stop recording";
"a11y.view_details" = "View details";
"action_accept" = "Accept";
"action_add_caption" = "Add caption";
"action_add_to_timeline" = "Add to timeline";
Expand Down Expand Up @@ -440,6 +441,7 @@
"screen_room_single_knock_request_title" = "%1$@ wants to join this room";
"screen_room_single_knock_request_view_button_title" = "View";
"screen_room_details_pinned_events_row_title" = "Pinned messages";
"screen_room_details_profile_row_title" = "Profile";
"screen_room_details_requests_to_join_title" = "Requests to join";
"screen_room_details_security_and_privacy_title" = "Security & privacy";
"screen_roomlist_knock_event_sent_description" = "Request to join sent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"a11y_user_menu" = "User menu";
"a11y_voice_message_record" = "Record voice message.";
"a11y_voice_message_stop_recording" = "Stop recording";
"a11y.view_details" = "View details";
"action_accept" = "Accept";
"action_add_caption" = "Add caption";
"action_add_to_timeline" = "Add to timeline";
Expand Down Expand Up @@ -440,6 +441,7 @@
"screen_room_single_knock_request_title" = "%1$@ wants to join this room";
"screen_room_single_knock_request_view_button_title" = "View";
"screen_room_details_pinned_events_row_title" = "Pinned messages";
"screen_room_details_profile_row_title" = "Profile";
"screen_room_details_requests_to_join_title" = "Requests to join";
"screen_room_details_security_and_privacy_title" = "Security & privacy";
"screen_roomlist_knock_event_sent_description" = "Request to join sent";
Expand Down
2 changes: 2 additions & 0 deletions ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.presentMediaEventsTimeline)
case .presentSecurityAndPrivacyScreen:
stateMachine.tryEvent(.presentSecurityAndPrivacyScreen)
case .presentRecipientDetails(let userID):
stateMachine.tryEvent(.presentRoomMemberDetails(userID: userID))
}
}
.store(in: &cancellables)
Expand Down
7 changes: 7 additions & 0 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,8 @@ internal enum L10n {
internal static var screenRoomDetailsNotificationTitle: String { return L10n.tr("Localizable", "screen_room_details_notification_title") }
/// Pinned messages
internal static var screenRoomDetailsPinnedEventsRowTitle: String { return L10n.tr("Localizable", "screen_room_details_pinned_events_row_title") }
/// Profile
internal static var screenRoomDetailsProfileRowTitle: String { return L10n.tr("Localizable", "screen_room_details_profile_row_title") }
/// Requests to join
internal static var screenRoomDetailsRequestsToJoinTitle: String { return L10n.tr("Localizable", "screen_room_details_requests_to_join_title") }
/// Roles and permissions
Expand Down Expand Up @@ -2781,6 +2783,11 @@ internal enum L10n {
/// Check UnifiedPush
internal static var troubleshootNotificationsTestUnifiedPushTitle: String { return L10n.tr("Localizable", "troubleshoot_notifications_test_unified_push_title") }

internal enum A11y {
/// View details
internal static var viewDetails: String { return L10n.tr("Localizable", "a11y.view_details") }
}

internal enum Common {
/// Copied to clipboard
internal static var copiedToClipboard: String { return L10n.tr("Localizable", "common.copied_to_clipboard") }
Expand Down
11 changes: 10 additions & 1 deletion ElementX/Sources/Mocks/JoinedRoomProxyMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct JoinedRoomProxyMockConfiguration {
var timelineStartReached = false

var members: [RoomMemberProxyMock] = .allMembers
var heroes: [RoomMemberProxyMock] = []
var knockRequestsState: KnockRequestsState = .loaded([])
var ownUserID = RoomMemberProxyMock.mockMe.userID
var inviter: RoomMemberProxyProtocol?
Expand Down Expand Up @@ -159,7 +160,7 @@ extension RoomInfo {
isIgnored: $0.isIgnored,
suggestedRoleForPowerLevel: $0.role,
membershipChangeReason: $0.membershipChangeReason) },
heroes: [],
heroes: configuration.heroes.map(RoomHero.init),
activeMembersCount: UInt64(configuration.members.filter { $0.membership == .join || $0.membership == .invite }.count),
invitedMembersCount: UInt64(configuration.members.filter { $0.membership == .invite }.count),
joinedMembersCount: UInt64(configuration.members.filter { $0.membership == .join }.count),
Expand All @@ -178,3 +179,11 @@ extension RoomInfo {
historyVisibility: .shared)
}
}

private extension RoomHero {
init(from memberProxy: RoomMemberProxyMock) {
self.init(userId: memberProxy.userID,
displayName: memberProxy.displayName,
avatarUrl: memberProxy.avatarURL?.absoluteString)
}
}
12 changes: 10 additions & 2 deletions ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ struct AvatarHeaderView<Footer: View>: View {
@ViewBuilder footer: @escaping () -> Footer) {
avatarInfo = .room(room.avatar)
title = room.name ?? room.id
subtitle = room.canonicalAlias

if let roomAlias = room.canonicalAlias {
subtitle = roomAlias
} else if room.isDirect, case let .heroes(heroes) = room.avatar, heroes.count == 1 {
subtitle = heroes[0].userID
} else {
subtitle = nil
}

self.avatarSize = avatarSize
self.mediaProvider = mediaProvider
Expand Down Expand Up @@ -193,7 +200,8 @@ struct AvatarHeaderView_Previews: PreviewProvider, TestablePreview {
avatarURL: .mockMXCAvatar),
canonicalAlias: "#test:matrix.org",
isEncrypted: true,
isPublic: true),
isPublic: true,
isDirect: false),
avatarSize: .room(on: .details),
mediaProvider: MediaProviderMock(configuration: .init())) {
HStack(spacing: 32) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct RoomDetailsScreenCoordinatorParameters {
enum RoomDetailsScreenCoordinatorAction {
case leftRoom
case presentRoomMembersList
case presentRecipientDetails(userID: String)
case presentRoomDetailsEditScreen
case presentNotificationSettingsScreen
case presentInviteUsersScreen
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,7 +69,7 @@ struct RoomDetailsScreenViewState: BindableState {
}

var hasTopicSection: Bool {
topic != nil || (canEdit && canEditRoomTopic)
topic != nil || canEditRoomTopic
}

var bindings: RoomDetailsScreenViewStateBindings
Expand Down Expand Up @@ -198,6 +199,7 @@ enum RoomDetailsScreenViewAction {
case ignoreConfirmed
case unignoreConfirmed
case processTapNotifications
case processTapRecipientProfile
case processToggleMuteNotifications
case displayAvatar(URL)
case processTapPolls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
})
}
}
}

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions ElementX/Sources/Services/Room/RoomDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ struct RoomDetails {
let canonicalAlias: String?
let isEncrypted: Bool
let isPublic: Bool
let isDirect: Bool
}
3 changes: 2 additions & 1 deletion ElementX/Sources/Services/Room/RoomProxyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ extension JoinedRoomProxyProtocol {
avatar: infoPublisher.value.avatar,
canonicalAlias: infoPublisher.value.canonicalAlias,
isEncrypted: isEncrypted,
isPublic: infoPublisher.value.isPublic)
isPublic: infoPublisher.value.isPublic,
isDirect: infoPublisher.value.isDirect)
}

var isDirectOneToOneRoom: Bool {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading