Adapt medias view to secondary column

This commit is contained in:
Thomas Ricouard 2023-01-29 17:37:15 +01:00
parent 979ba61b07
commit e0d6340a9d
3 changed files with 16 additions and 1 deletions

View File

@ -119,6 +119,7 @@ struct IceCubesApp: App {
currentAccount.account?.id != nil {
Divider().edgesIgnoringSafeArea(.all)
NotificationsTab(popToRootTab: $popToRootTab, lockedType: nil, isSecondaryColumn: true)
.environment(\.isSecondaryColumn, true)
.frame(maxWidth: 360)
}
}

View File

@ -0,0 +1,13 @@
import Foundation
import SwiftUI
private struct SecondaryColumnKey: EnvironmentKey {
static let defaultValue = false
}
extension EnvironmentValues {
public var isSecondaryColumn: Bool {
get { self[SecondaryColumnKey.self] }
set { self[SecondaryColumnKey.self] = newValue }
}
}

View File

@ -7,6 +7,7 @@ import SwiftUI
public struct StatusMediaPreviewView: View {
@Environment(\.openURL) private var openURL
@Environment(\.isSecondaryColumn) private var isSecondaryColumn
@EnvironmentObject var sceneDelegate: SceneDelegate
@EnvironmentObject private var preferences: UserPreferences
@ -65,7 +66,7 @@ public struct StatusMediaPreviewView: View {
}
private func imageSize(from: CGSize, newWidth: CGFloat) -> CGSize {
if isNotifications || theme.statusDisplayStyle == .compact {
if isNotifications || theme.statusDisplayStyle == .compact || isSecondaryColumn {
return .init(width: imageMaxHeight, height: imageMaxHeight)
}
let ratio = newWidth / from.width