-
Notifications
You must be signed in to change notification settings - Fork 0
Project Structure and Core Concepts
This page explains how an Aparoksha app is put together.
Aparoksha follows a declarative UI model. You describe the app in terms of app metadata, scenes, windows, state, and views.
The common flow looks like this:
- define an app type with
@main - create an
Aparoksha(...)instance for app metadata - declare one or more scenes
- add windows
- build the content with view types such as
WindowView - update the UI through reactive state
This is the entry point of the application.
@main
struct MyApp: App {
var scene: Scene {
Window("My App", icon: .headphones, id: "main") {
ContentView()
}
}
}This defines application-level metadata such as:
- bundle-like app identifier
- display name
- settings and about labels
- developer name
- version
- website and issue tracker URLs
Example:
let app = Aparoksha(
id: "com.example.myapp",
name: "My App",
settings: "Settings",
about: "About My App",
developer: "Your Name",
version: "0.1.0",
quit: "Quit My App",
website: .init(string: "https://example.com")!,
websiteLabel: "Website",
issues: .init(string: "https://example.com/issues")!,
issuesLabel: "Issues",
services: "Services"
)The scene property defines the app's windows and menu bar content.
var scene: Scene {
Window("Main Window", icon: .headphones, id: "main") {
ContentView()
}
}A Window defines a top-level app window.
Window("Main Window", icon: .headphones, id: "main") {
ContentView()
}You can declare multiple windows in the same app.
A WindowView is the main content of a window.
struct ContentView: WindowView {
var view: Body {
VStack {
Text("Hello")
}
.padding(20)
}
}Reactive state is typically modeled with @State.
@State private var count = 0Updating the state updates the UI.
Common declarative pieces include:
VStackHStackTextButton
Example:
VStack {
Text("Counter: \(count)")
HStack {
Button("-1") { count -= 1 }
Button("+1") { count += 1 }
}
}You can place multiple Window(...) declarations inside scene.
var scene: Scene {
Window("Main", icon: .headphones, id: "main") {
MainView()
}
Window("Secondary", icon: .headphones, id: "secondary") {
Text("Secondary window")
.padding(10)
}
}Aparoksha also exposes menu bar primitives.
MenuBar {
Submenu("File") {
MenuButton("About") {
print("About clicked")
}
}
}A WindowView can customize its window.
struct MainView: WindowView {
@State(blockUpdates: true) private var width = 700
@State(blockUpdates: true) private var height = 450
var view: Body {
VStack {
Text("Resizable window")
}
.padding(20)
}
func window(_ window: Window) -> Window {
window.frame(width: $width, height: $height)
}
}FlatNavigation is one of the central navigation abstractions demonstrated by the upstream demo.
FlatNavigation(SidebarItem.allCases, selection: $selectedItem) {
switch selectedItem {
case .home:
Text("Home")
case .settings:
Text("Settings")
}
}The item type typically conforms to FlatNavigationItem.
If you are unsure about a method signature or a UI pattern, the most reliable source today is still the upstream demo app and current package source. Use this wiki as the practical map, but use the demo as the living API reference.