mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Allow focusing the different avatars making up a DM details cluster separately. (#3341)
This commit is contained in:
@@ -33,7 +33,7 @@ struct UserProfileScreenViewStateBindings {
|
||||
}
|
||||
|
||||
enum UserProfileScreenViewAction {
|
||||
case displayAvatar
|
||||
case displayAvatar(URL)
|
||||
case openDirectChat
|
||||
case startCall(roomID: String)
|
||||
case dismiss
|
||||
|
||||
@@ -74,8 +74,8 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
|
||||
override func process(viewAction: UserProfileScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .displayAvatar:
|
||||
Task { await displayFullScreenAvatar() }
|
||||
case .displayAvatar(let url):
|
||||
Task { await displayFullScreenAvatar(url) }
|
||||
case .openDirectChat:
|
||||
Task { await openDirectChat() }
|
||||
case .startCall(let roomID):
|
||||
@@ -87,15 +87,14 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func displayFullScreenAvatar() async {
|
||||
private func displayFullScreenAvatar(_ url: URL) async {
|
||||
guard let userProfile = state.userProfile else { fatalError() }
|
||||
guard let avatarURL = userProfile.avatarURL else { return }
|
||||
|
||||
showLoadingIndicator(allowsInteraction: false)
|
||||
defer { hideLoadingIndicator() }
|
||||
|
||||
// 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: userProfile.displayName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ struct UserProfileScreen: View {
|
||||
if let userProfile = context.viewState.userProfile {
|
||||
AvatarHeaderView(user: userProfile,
|
||||
avatarSize: .user(on: .memberDetails),
|
||||
mediaProvider: context.mediaProvider) {
|
||||
context.send(viewAction: .displayAvatar)
|
||||
mediaProvider: context.mediaProvider) { url in
|
||||
context.send(viewAction: .displayAvatar(url))
|
||||
} footer: {
|
||||
otherUserFooter
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user