Allow tapping the avatar in the room member bottom sheet to view it fullscreen (#5989)

* Extract a shared helper for loading a media preview

The four screens that show a fullscreen avatar each had their own copy of the same
load-and-wrap logic. Move it to MediaPreviewItem.load, with the mime type as a
parameter defaulting to JPEG, and leave each screen's loading indicator where it is.

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>

* Only dismiss a QuickLook preview that is still presented

UIKit forwards dismiss() up the presentation chain when the receiver has nothing
presented, so dismissing the avatar view was dismissing the profile details sheet
also.

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>

* Allow tapping the avatar in the room member bottom sheet to view it fullscreen

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>

---------

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
This commit is contained in:
Danny
2026-08-07 06:11:40 -06:00
committed by GitHub
parent bbdbbe1081
commit 1a72a4e17b
8 changed files with 56 additions and 17 deletions
@@ -97,4 +97,22 @@ struct ManageRoomMemberSheetViewModelTests {
try await deferredAction.fulfill()
#expect(context.alertInfo == nil)
}
@Test
mutating func displayAvatar() async throws {
let member = RoomMemberDetails(withProxy: RoomMemberProxyMock.mockDan)
viewModel = ManageRoomMemberSheetViewModel(memberDetails: .memberDetails(roomMember: member),
permissions: .init(canKick: true, canBan: true, ownPowerLevel: RoomMemberProxyMock.mockAdmin.powerLevel),
roomProxy: JoinedRoomProxyMock(.init()),
userIndicatorController: UserIndicatorControllerMock(),
analyticsService: AnalyticsServiceMock(.init()),
mediaProvider: MediaProviderMock(.init()))
let avatarURL = try #require(member.avatarURL)
let deferred = deferFulfillment(context.observe(\.viewState.bindings.mediaPreviewItem)) { $0 != nil }
context.send(viewAction: .displayAvatar(avatarURL))
try await deferred.fulfill()
#expect(context.mediaPreviewItem?.previewItemTitle == member.name)
}
}