mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Fix image sizing
This commit is contained in:
parent
0da8228e61
commit
af2a69fdb1
3 changed files with 18 additions and 7 deletions
|
@ -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] }
|
||||
|
|
|
@ -134,6 +134,7 @@ extension StatusEditor {
|
|||
.environment(RouterPath())
|
||||
.allowsHitTesting(false)
|
||||
.environment(\.isStatusFocused, false)
|
||||
.environment(\.isModal, true)
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.padding(.vertical, .statusComponentSpacing)
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue