Scene SwiftUI
- WindowGroup
- DocumentGroup (PlainText3, WikiPad) Separate DocumentGroup SwiftUI???
Commands
- .commands scene modifier. Separate commands from app and scene. Use CommandMenu.swift.
Issues
- How do menu commands access document? (Specific to DocumentGroup.)
- How does app access file?
Active Document from Command Menu How do menu commands access document? (Specific to DocumentGroup.)
- FocusedValuesExtension: calculated document binding
- .focusedSceneValue(.document, file.$document) // Scene value equivalent of environment for values? (Found in App.swift, DocumentGroup scene, apply modifier to top level view.)
- @FocusedValue(.document) var focusedDocument // 4. Focused value-focused scene value bug. If in app file, causes debug layout errors and drawing issuses. If in menu commands file ok. (Found in CommandsMenu.swift.)
Document File Name DocumentGroup(newDocument: WikiPadDocument()) { file in
File name available as parameter in DocumentGroup function.
Scene Phases
- active
- background
- inactive
- default (unknown)
Code
- @Environment(.scenePhase) private var scenePhase
Examples
Lifecycle
- Uses AppDelegate and @NSApplicationDelgateAdaptor.
- Uses environment property scenePhase and WindowGroup:Scene onChange(of: scenePhase).
Notes
System Where start-stop code? app delegate proxy? 1x launch Where wake-sleep code? scene phases? Nx, active-inactive (Both app and scene can be active. Where startup code? App property init.
Mac
-
Red (Close): close window (file close and file new window do not affect scene phase, or app phase.)
-
Yellow (Minimize): minimize to dock
-
Green (Maximize): full screen or maximize
-
Dock running apps (dot below) have toolbar, even if no windows. Dock selection causes app active. (But not scene active.)
Scene (Does not affect App)
- Minimize (window minimize or yellow button) cause scene inactive, dock right section.
- Restore (window diamond or dock right section) cause scene active. (Active window gets check. Inactive windows get diamond.)