DM Details have been updated (#2836)

This commit is contained in:
Mauro
2024-05-14 18:47:20 +02:00
committed by GitHub
parent d66ff02d12
commit 2c038c5969
68 changed files with 314 additions and 169 deletions
@@ -64,6 +64,7 @@ struct RoomDetailsScreenViewState: BindableState {
var bindings: RoomDetailsScreenViewStateBindings
var dmRecipient: RoomMemberDetails?
var accountOwner: RoomMemberDetails?
var shortcuts: [RoomDetailsScreenViewShortcut] {
var shortcuts: [RoomDetailsScreenViewShortcut] = [.mute]
@@ -174,9 +174,11 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
.receive(on: DispatchQueue.main)
.sink { [weak self, ownUserID = roomProxy.ownUserID] members in
guard let self else { return }
let accountOwner = members.first(where: { $0.userID == ownUserID })
let dmRecipient = members.first(where: { $0.userID != ownUserID })
self.dmRecipient = dmRecipient
self.state.dmRecipient = dmRecipient.map(RoomMemberDetails.init(withProxy:))
self.state.accountOwner = accountOwner.map(RoomMemberDetails.init(withProxy:))
}
.store(in: &cancellables)
@@ -24,8 +24,10 @@ struct RoomDetailsScreen: View {
var body: some View {
Form {
if let recipient = context.viewState.dmRecipient {
dmHeaderSection(recipient: recipient)
if let recipient = context.viewState.dmRecipient,
let accountOwner = context.viewState.accountOwner {
dmHeaderSection(accountOwner: accountOwner,
recipient: recipient)
} else {
normalRoomHeaderSection
}
@@ -82,9 +84,9 @@ struct RoomDetailsScreen: View {
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.avatar)
}
private func dmHeaderSection(recipient: RoomMemberDetails) -> some View {
AvatarHeaderView(member: recipient,
avatarSize: .user(on: .memberDetails),
private func dmHeaderSection(accountOwner: RoomMemberDetails, recipient: RoomMemberDetails) -> some View {
AvatarHeaderView(accountOwner: accountOwner,
dmRecipient: recipient,
imageProvider: context.imageProvider) {
context.send(viewAction: .displayAvatar)
} footer: {