diff --git a/Packages/Env/Sources/Env/CustomEnvValues.swift b/Packages/Env/Sources/Env/CustomEnvValues.swift index d1d978ca..ec6ac161 100644 --- a/Packages/Env/Sources/Env/CustomEnvValues.swift +++ b/Packages/Env/Sources/Env/CustomEnvValues.swift @@ -13,6 +13,10 @@ private struct IsCompact: EnvironmentKey { static let defaultValue: Bool = false } +private struct IsModal: EnvironmentKey { + static let defaultValue: Bool = false +} + private struct IsInCaptureMode: EnvironmentKey { static let defaultValue: Bool = false } @@ -48,6 +52,11 @@ public extension EnvironmentValues { get { self[IsCompact.self] } set { self[IsCompact.self] = newValue } } + + var isModal: Bool { + get { self[IsModal.self] } + set { self[IsModal.self] = newValue } + } var isInCaptureMode: Bool { get { self[IsInCaptureMode.self] } diff --git a/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift b/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift index b0046279..912462ad 100644 --- a/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift @@ -134,6 +134,7 @@ extension StatusEditor { .environment(RouterPath()) .allowsHitTesting(false) .environment(\.isStatusFocused, false) + .environment(\.isModal, true) .padding(.horizontal, .layoutPadding) .padding(.vertical, .statusComponentSpacing) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift index d4eea8cd..20a248c4 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift @@ -8,7 +8,6 @@ import SwiftUI @MainActor public struct StatusRowMediaPreviewView: View { - @Environment(\.isPresented) private var isPresented @Environment(\.openWindow) private var openWindow @Environment(\.extraLeadingInset) private var extraLeadingInset: CGFloat @Environment(\.isCompact) private var isCompact: Bool @@ -32,11 +31,7 @@ public struct StatusRowMediaPreviewView: View { { return sceneDelegate.windowWidth * 0.80 } - if isPresented && UIDevice.current.userInterfaceIdiom == .pad { - return sceneDelegate.windowWidth * 0.50 - } else { - return sceneDelegate.windowWidth - } + return sceneDelegate.windowWidth #endif } @@ -189,6 +184,7 @@ private struct MediaPreview: View { } } +@MainActor private struct FeaturedImagePreView: View { let attachment: MediaAttachment let imageMaxHeight: CGFloat @@ -200,6 +196,7 @@ private struct FeaturedImagePreView: View { @Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool @Environment(Theme.self) private var theme @Environment(\.isCompact) private var isCompact: Bool + @Environment(\.isModal) private var isModal: Bool var body: some View { let size: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight) @@ -260,7 +257,11 @@ private struct FeaturedImagePreView: View { return .init(width: imageMaxHeight, height: imageMaxHeight) } - let boxWidth = availableWidth - appLayoutWidth + var boxWidth = availableWidth - appLayoutWidth + if isModal && + (UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac) { + boxWidth = availableWidth * 0.50 + } let boxHeight = availableHeight * 0.8 // use only 80% of window height to leave room for text if from.width <= boxWidth, from.height <= boxHeight {