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
|
static let defaultValue: Bool = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct IsModal: EnvironmentKey {
|
||||||
|
static let defaultValue: Bool = false
|
||||||
|
}
|
||||||
|
|
||||||
private struct IsInCaptureMode: EnvironmentKey {
|
private struct IsInCaptureMode: EnvironmentKey {
|
||||||
static let defaultValue: Bool = false
|
static let defaultValue: Bool = false
|
||||||
}
|
}
|
||||||
|
@ -49,6 +53,11 @@ public extension EnvironmentValues {
|
||||||
set { self[IsCompact.self] = newValue }
|
set { self[IsCompact.self] = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isModal: Bool {
|
||||||
|
get { self[IsModal.self] }
|
||||||
|
set { self[IsModal.self] = newValue }
|
||||||
|
}
|
||||||
|
|
||||||
var isInCaptureMode: Bool {
|
var isInCaptureMode: Bool {
|
||||||
get { self[IsInCaptureMode.self] }
|
get { self[IsInCaptureMode.self] }
|
||||||
set { self[IsInCaptureMode.self] = newValue }
|
set { self[IsInCaptureMode.self] = newValue }
|
||||||
|
|
|
@ -134,6 +134,7 @@ extension StatusEditor {
|
||||||
.environment(RouterPath())
|
.environment(RouterPath())
|
||||||
.allowsHitTesting(false)
|
.allowsHitTesting(false)
|
||||||
.environment(\.isStatusFocused, false)
|
.environment(\.isStatusFocused, false)
|
||||||
|
.environment(\.isModal, true)
|
||||||
.padding(.horizontal, .layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.padding(.vertical, .statusComponentSpacing)
|
.padding(.vertical, .statusComponentSpacing)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import SwiftUI
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
public struct StatusRowMediaPreviewView: View {
|
public struct StatusRowMediaPreviewView: View {
|
||||||
@Environment(\.isPresented) private var isPresented
|
|
||||||
@Environment(\.openWindow) private var openWindow
|
@Environment(\.openWindow) private var openWindow
|
||||||
@Environment(\.extraLeadingInset) private var extraLeadingInset: CGFloat
|
@Environment(\.extraLeadingInset) private var extraLeadingInset: CGFloat
|
||||||
@Environment(\.isCompact) private var isCompact: Bool
|
@Environment(\.isCompact) private var isCompact: Bool
|
||||||
|
@ -32,11 +31,7 @@ public struct StatusRowMediaPreviewView: View {
|
||||||
{
|
{
|
||||||
return sceneDelegate.windowWidth * 0.80
|
return sceneDelegate.windowWidth * 0.80
|
||||||
}
|
}
|
||||||
if isPresented && UIDevice.current.userInterfaceIdiom == .pad {
|
|
||||||
return sceneDelegate.windowWidth * 0.50
|
|
||||||
} else {
|
|
||||||
return sceneDelegate.windowWidth
|
return sceneDelegate.windowWidth
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +184,7 @@ private struct MediaPreview: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
private struct FeaturedImagePreView: View {
|
private struct FeaturedImagePreView: View {
|
||||||
let attachment: MediaAttachment
|
let attachment: MediaAttachment
|
||||||
let imageMaxHeight: CGFloat
|
let imageMaxHeight: CGFloat
|
||||||
|
@ -200,6 +196,7 @@ private struct FeaturedImagePreView: View {
|
||||||
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
||||||
@Environment(Theme.self) private var theme
|
@Environment(Theme.self) private var theme
|
||||||
@Environment(\.isCompact) private var isCompact: Bool
|
@Environment(\.isCompact) private var isCompact: Bool
|
||||||
|
@Environment(\.isModal) private var isModal: Bool
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let size: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
|
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)
|
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
|
let boxHeight = availableHeight * 0.8 // use only 80% of window height to leave room for text
|
||||||
|
|
||||||
if from.width <= boxWidth, from.height <= boxHeight {
|
if from.width <= boxWidth, from.height <= boxHeight {
|
||||||
|
|
Loading…
Reference in a new issue