mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Display avatars full screen when tapping on them from the room or member detail screens
This commit is contained in:
committed by
Stefan Ceriu
parent
68f8bfed53
commit
3515494a10
@@ -137,6 +137,9 @@ struct RoomDetailsScreenViewStateBindings {
|
||||
var alertInfo: AlertInfo<RoomDetailsScreenErrorType>?
|
||||
var leaveRoomAlertItem: LeaveRoomAlertItem?
|
||||
var ignoreUserRoomAlertItem: IgnoreUserAlertItem?
|
||||
|
||||
/// A media item that will be previewed with QuickLook.
|
||||
var mediaPreviewItem: MediaPreviewItem?
|
||||
}
|
||||
|
||||
struct LeaveRoomAlertItem: AlertProtocol {
|
||||
@@ -174,6 +177,7 @@ enum RoomDetailsScreenViewAction {
|
||||
case unignoreConfirmed
|
||||
case processTapNotifications
|
||||
case processToogleMuteNotifications
|
||||
case displayAvatar
|
||||
}
|
||||
|
||||
enum RoomDetailsScreenViewShortcut {
|
||||
|
||||
@@ -22,6 +22,7 @@ typealias RoomDetailsScreenViewModelType = StateStoreViewModel<RoomDetailsScreen
|
||||
class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScreenViewModelProtocol {
|
||||
private let accountUserID: String
|
||||
private let roomProxy: RoomProxyProtocol
|
||||
private let mediaProvider: MediaProviderProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let notificationSettingsProxy: NotificationSettingsProxyProtocol
|
||||
|
||||
@@ -41,6 +42,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
appSettings: AppSettings) {
|
||||
self.accountUserID = accountUserID
|
||||
self.roomProxy = roomProxy
|
||||
self.mediaProvider = mediaProvider
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.notificationSettingsProxy = notificationSettingsProxy
|
||||
|
||||
@@ -104,6 +106,8 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
}
|
||||
case .processToogleMuteNotifications:
|
||||
Task { await toggleMuteNotifications() }
|
||||
case .displayAvatar:
|
||||
displayFullScreenAvatar()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,4 +264,24 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
state.bindings.alertInfo = .init(id: .unknown)
|
||||
}
|
||||
}
|
||||
|
||||
private func displayFullScreenAvatar() {
|
||||
guard let avatarURL = roomProxy.avatarURL else {
|
||||
return
|
||||
}
|
||||
|
||||
let loadingIndicatorIdentifier = "roomAvatarLoadingIndicator"
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
|
||||
|
||||
Task {
|
||||
defer {
|
||||
userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier)
|
||||
}
|
||||
|
||||
// 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")) {
|
||||
state.bindings.mediaPreviewItem = MediaPreviewItem(file: file, title: roomProxy.roomTitle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ struct RoomDetailsScreen: View {
|
||||
}
|
||||
}
|
||||
.track(screen: .roomDetails)
|
||||
.interactiveQuickLook(item: $context.mediaPreviewItem)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -76,6 +77,8 @@ struct RoomDetailsScreen: View {
|
||||
avatarSize: .room(on: .details),
|
||||
imageProvider: context.imageProvider,
|
||||
subtitle: context.viewState.canonicalAlias) {
|
||||
context.send(viewAction: .displayAvatar)
|
||||
} footer: {
|
||||
if !context.viewState.shortcuts.isEmpty {
|
||||
headerSectionShortcuts
|
||||
}
|
||||
@@ -90,6 +93,8 @@ struct RoomDetailsScreen: View {
|
||||
avatarSize: .user(on: .memberDetails),
|
||||
imageProvider: context.imageProvider,
|
||||
subtitle: recipient.id) {
|
||||
context.send(viewAction: .displayAvatar)
|
||||
} footer: {
|
||||
if !context.viewState.shortcuts.isEmpty {
|
||||
headerSectionShortcuts
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user