fix: enforce start size through SwiftUI window constraints
This commit is contained in:
@@ -33,6 +33,7 @@ final class PlayerModel: ObservableObject {
|
||||
@Published private(set) var commandError: String?
|
||||
@Published private(set) var queue = PlaybackQueue()
|
||||
@Published private(set) var recentMedia: [PlaybackProgress.RecentMedia] = []
|
||||
@Published private(set) var startContentHeight: CGFloat = 400
|
||||
@Published var showsQueue = false {
|
||||
didSet {
|
||||
if showsQueue != oldValue { transitionQueue() }
|
||||
@@ -827,6 +828,7 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
func attachWindow(_ window: NSWindow) {
|
||||
guard self.window !== window else { return }
|
||||
startContentHeight = 400 - (window.frame.height - window.contentLayoutRect.height)
|
||||
finishQueueTransition()
|
||||
self.window = window
|
||||
window.title = fileName ?? "Terebi"
|
||||
@@ -2756,6 +2758,7 @@ private struct PlayerContent: View {
|
||||
|
||||
var body: some View {
|
||||
let titleControlsVisible = model.showsQueue || model.isQueueTransitioning || model.controlsVisible
|
||||
let startScreen = model.fileName == nil && !model.isCompact && !model.compactWindow.isTransitioning
|
||||
HStack(spacing: 0) {
|
||||
videoContent
|
||||
if !model.isCompact && !model.compactWindow.isTransitioning && model.queueWidth > 0 {
|
||||
@@ -2766,8 +2769,10 @@ private struct PlayerContent: View {
|
||||
.accessibilityHidden(!model.showsQueue)
|
||||
}
|
||||
}
|
||||
.frame(minWidth: model.isCompact || model.compactWindow.isTransitioning ? 160 : 400 + model.queueWidth,
|
||||
minHeight: model.isCompact || model.compactWindow.isTransitioning ? model.compactContentMinimumHeight : 240)
|
||||
.frame(minWidth: startScreen ? 640 : (model.isCompact || model.compactWindow.isTransitioning ? 160 : 400 + model.queueWidth),
|
||||
maxWidth: startScreen ? 640 : .infinity,
|
||||
minHeight: startScreen ? model.startContentHeight : (model.isCompact || model.compactWindow.isTransitioning ? model.compactContentMinimumHeight : 240),
|
||||
maxHeight: startScreen ? model.startContentHeight : .infinity)
|
||||
.overlay(alignment: .topTrailing) {
|
||||
if !model.isCompact && !model.compactWindow.isTransitioning {
|
||||
titleControls
|
||||
@@ -3143,7 +3148,8 @@ struct TerebiApp: App {
|
||||
PlayerContent(model: model)
|
||||
.focusedSceneObject(model)
|
||||
}
|
||||
.defaultSize(width: 900, height: 560)
|
||||
.defaultSize(width: 640, height: 400)
|
||||
.windowResizability(.contentSize)
|
||||
.windowStyle(.hiddenTitleBar)
|
||||
.commands { PlayerCommands() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user