mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-27 01:20:41 +00:00
Mixin portrait and landscape media in the status medias carousel
This commit is contained in:
parent
1fa54afc3a
commit
6f6e352baf
1 changed files with 4 additions and 6 deletions
|
@ -141,12 +141,10 @@ private struct MediaPreview: View {
|
|||
switch displayData.type {
|
||||
case .image:
|
||||
LazyResizableImage(url: displayData.previewUrl) { state, proxy in
|
||||
let width = isCompact ? imageMaxHeight : proxy.frame(in: .local).width
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(maxWidth: width, maxHeight: imageMaxHeight)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.stroke(.gray.opacity(0.35), lineWidth: 1)
|
||||
|
@ -154,7 +152,6 @@ private struct MediaPreview: View {
|
|||
} else if state.isLoading {
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.fill(Color.gray)
|
||||
.frame(maxWidth: width, maxHeight: imageMaxHeight)
|
||||
}
|
||||
}
|
||||
.overlay {
|
||||
|
@ -165,12 +162,11 @@ private struct MediaPreview: View {
|
|||
}
|
||||
case .av:
|
||||
MediaUIAttachmentVideoView(viewModel: .init(url: displayData.url))
|
||||
.frame(width: isCompact ? imageMaxHeight : proxy.frame(in: .local).width)
|
||||
.frame(height: imageMaxHeight)
|
||||
.accessibilityAddTraits(.startsMediaSession)
|
||||
}
|
||||
}
|
||||
.frame(width: imageMaxHeight / 1.5, height: imageMaxHeight)
|
||||
.frame(width: displayData.isLandscape ? imageMaxHeight * 1.2 : imageMaxHeight / 1.5,
|
||||
height: imageMaxHeight)
|
||||
.clipped()
|
||||
.cornerRadius(4)
|
||||
// #965: do not create overlapping tappable areas, when multiple images are shown
|
||||
|
@ -407,6 +403,7 @@ private struct DisplayData: Identifiable, Hashable {
|
|||
let description: String?
|
||||
let type: DisplayType
|
||||
let accessibilityText: String
|
||||
let isLandscape: Bool
|
||||
|
||||
init?(from attachment: MediaAttachment) {
|
||||
guard let url = attachment.url else { return nil }
|
||||
|
@ -418,6 +415,7 @@ private struct DisplayData: Identifiable, Hashable {
|
|||
description = attachment.description
|
||||
self.type = DisplayType(from: type)
|
||||
accessibilityText = Self.getAccessibilityString(from: attachment)
|
||||
isLandscape = (attachment.meta?.original?.width ?? 0) > (attachment.meta?.original?.height ?? 0)
|
||||
}
|
||||
|
||||
private static func getAccessibilityString(from attachment: MediaAttachment) -> String {
|
||||
|
|
Loading…
Reference in a new issue