Skip to content

Project Structure and Core Concepts

Vinícius Costa edited this page Apr 12, 2026 · 2 revisions

This page explains how an Aparoksha app is put together.

Mental model

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:

  1. define an app type with @main
  2. create an Aparoksha(...) instance for app metadata
  3. declare one or more scenes
  4. add windows
  5. build the content with view types such as WindowView
  6. update the UI through reactive state

Core building blocks

@main struct ...: App

This is the entry point of the application.

@main
struct MyApp: App {
    var scene: Scene {
        Window("My App", icon: .headphones, id: "main") {
            ContentView()
        }
    }
}

let app = Aparoksha(...)

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"
)

scene

The scene property defines the app's windows and menu bar content.

var scene: Scene {
    Window("Main Window", icon: .headphones, id: "main") {
        ContentView()
    }
}

Window

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.

WindowView

A WindowView is the main content of a window.

struct ContentView: WindowView {
    var view: Body {
        VStack {
            Text("Hello")
        }
        .padding(20)
    }
}

State

Reactive state is typically modeled with @State.

@State private var count = 0

Updating the state updates the UI.

Layout and controls

Common declarative pieces include:

  • VStack
  • HStack
  • Text
  • Button

Example:

VStack {
    Text("Counter: \(count)")
    HStack {
        Button("-1") { count -= 1 }
        Button("+1") { count += 1 }
    }
}

Multi-window support

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)
    }
}

Menu bar support

Aparoksha also exposes menu bar primitives.

MenuBar {
    Submenu("File") {
        MenuButton("About") {
            print("About clicked")
        }
    }
}

Window customization

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)
    }
}

Navigation

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.

Practical advice

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.