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