mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Allow focusing the different avatars making up a DM details cluster separately. (#3341)
This commit is contained in:
@@ -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
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ enum RoomMemberDetailsScreenViewAction {
|
||||
case showIgnoreAlert
|
||||
case ignoreConfirmed
|
||||
case unignoreConfirmed
|
||||
case displayAvatar
|
||||
case displayAvatar(URL)
|
||||
case openDirectChat
|
||||
case startCall(roomID: String)
|
||||
}
|
||||
|
||||
+4
-8
@@ -84,8 +84,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
Task { await ignoreUser() }
|
||||
case .unignoreConfirmed:
|
||||
Task { await unignoreUser() }
|
||||
case .displayAvatar:
|
||||
Task { await displayFullScreenAvatar() }
|
||||
case .displayAvatar(let url):
|
||||
Task { await displayFullScreenAvatar(url) }
|
||||
case .openDirectChat:
|
||||
Task { await openDirectChat() }
|
||||
case .startCall(let roomID):
|
||||
@@ -143,21 +143,17 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
}
|
||||
}
|
||||
|
||||
private func displayFullScreenAvatar() async {
|
||||
private func displayFullScreenAvatar(_ url: URL) async {
|
||||
guard let roomMemberProxy else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
guard let avatarURL = roomMemberProxy.avatarURL else {
|
||||
return
|
||||
}
|
||||
|
||||
let loadingIndicatorIdentifier = "roomMemberAvatarLoadingIndicator"
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
|
||||
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")) {
|
||||
if case let .success(file) = await mediaProvider.loadFileFromSource(.init(url: url, mimeType: "image/jpeg")) {
|
||||
state.bindings.mediaPreviewItem = MediaPreviewItem(file: file, title: roomMemberProxy.displayName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ struct RoomMemberDetailsScreen: View {
|
||||
if let memberDetails = context.viewState.memberDetails {
|
||||
AvatarHeaderView(member: memberDetails,
|
||||
avatarSize: .user(on: .memberDetails),
|
||||
mediaProvider: context.mediaProvider) {
|
||||
context.send(viewAction: .displayAvatar)
|
||||
mediaProvider: context.mediaProvider) { url in
|
||||
context.send(viewAction: .displayAvatar(url))
|
||||
} footer: {
|
||||
otherUserFooter
|
||||
}
|
||||
|
||||
@@ -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