Skip to content

Commit

Permalink
Update Demo App @ Catalyst
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakr233 committed Aug 29, 2024
1 parent 7e29531 commit 8792750
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Example/ColorfulApp/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,35 @@ import ColorfulX
import SwiftUI

struct App: SwiftUI.App {
#if targetEnvironment(macCatalyst)
@Environment(\.scenePhase) var scenePhase
#endif

var body: some Scene {
WindowGroup {
ContentView().background(Color.white)
}
#if targetEnvironment(macCatalyst)
.onChange(of: scenePhase) { _ in
removeTitleBarFromWindow()
}
#endif
#if os(macOS)
.windowResizability(.contentSize)
.windowStyle(.hiddenTitleBar)
.windowToolbarStyle(.unifiedCompact)
#endif
}

#if targetEnvironment(macCatalyst)
func removeTitleBarFromWindow() {
let scenes = UIApplication.shared.connectedScenes.map { $0 as? UIWindowScene }
for scene in scenes {
if let titlebar = scene?.titlebar {
titlebar.titleVisibility = .hidden
titlebar.toolbar = nil
}
}
}
#endif
}

0 comments on commit 8792750

Please sign in to comment.