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