Allow focusing the different avatars making up a DM details cluster separately. (#3341)

This commit is contained in:
Stefan Ceriu
2024-09-27 15:23:20 +03:00
committed by GitHub
parent 9d23dec2e9
commit 8a3994016d
12 changed files with 65 additions and 51 deletions
@@ -183,7 +183,7 @@ enum RoomDetailsScreenViewAction {
case unignoreConfirmed
case processTapNotifications
case processToggleMuteNotifications
case displayAvatar
case displayAvatar(URL)
case processTapPolls
case toggleFavourite(isFavourite: Bool)
case processTapRolesAndPermissions
@@ -150,8 +150,8 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
}
case .processToggleMuteNotifications:
Task { await toggleMuteNotifications() }
case .displayAvatar:
displayFullScreenAvatar()
case .displayAvatar(let url):
displayFullScreenAvatar(url)
case .processTapPolls:
actionsSubject.send(.requestPollsHistoryPresentation)
case .toggleFavourite(let isFavourite):
@@ -346,11 +346,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
}
}
private func displayFullScreenAvatar() {
guard let avatarURL = roomProxy.avatarURL else {
return
}
private func displayFullScreenAvatar(_ url: URL) {
let loadingIndicatorIdentifier = "roomAvatarLoadingIndicator"
userIndicatorController.submitIndicator(UserIndicator(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
@@ -360,7 +356,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
}
// We don't actually know the mime type here, assume it's an image.
if case let .success(file) = await mediaProvider.loadFileFromSource(.init(url: avatarURL, mimeType: "image/jpeg")) {
if case let .success(file) = await mediaProvider.loadFileFromSource(.init(url: url, mimeType: "image/jpeg")) {
state.bindings.mediaPreviewItem = MediaPreviewItem(file: file, title: roomProxy.roomTitle)
}
}
@@ -65,8 +65,8 @@ struct RoomDetailsScreen: View {
private var normalRoomHeaderSection: some View {
AvatarHeaderView(room: context.viewState.details,
avatarSize: .room(on: .details),
mediaProvider: context.mediaProvider) {
context.send(viewAction: .displayAvatar)
mediaProvider: context.mediaProvider) { url in
context.send(viewAction: .displayAvatar(url))
} footer: {
if !context.viewState.shortcuts.isEmpty {
headerSectionShortcuts
@@ -78,8 +78,8 @@ struct RoomDetailsScreen: View {
private func dmHeaderSection(accountOwner: RoomMemberDetails, recipient: RoomMemberDetails) -> some View {
AvatarHeaderView(accountOwner: accountOwner,
dmRecipient: recipient,
mediaProvider: context.mediaProvider) {
context.send(viewAction: .displayAvatar)
mediaProvider: context.mediaProvider) { url in
context.send(viewAction: .displayAvatar(url))
} footer: {
if !context.viewState.shortcuts.isEmpty {
headerSectionShortcuts