103 lines
3.1 KiB
Swift
103 lines
3.1 KiB
Swift
import Portico
|
|
|
|
@main
|
|
struct ExampleApp: App {
|
|
var applicationId: String? { "dev.bscubed.PorticoExample" }
|
|
|
|
@State private var count = 0
|
|
@State private var name = "Portico"
|
|
@State private var darkMode = false
|
|
@State private var volume = 75.0
|
|
@State private var currentPage: UInt32 = 0
|
|
|
|
var body: some Scene {
|
|
ApplicationWindow { _ in
|
|
VStack {
|
|
HeaderBar()
|
|
|
|
Carousel {
|
|
introPage
|
|
counterPage
|
|
settingsPage
|
|
}
|
|
.onPageChanged { page in currentPage = page }
|
|
|
|
Label("Page \(currentPage + 1) of 3")
|
|
.dimmed()
|
|
.halign(.center)
|
|
.margin(8)
|
|
}
|
|
}
|
|
.title("Portico Demo")
|
|
.defaultSize(width: 1080, height: 720)
|
|
}
|
|
|
|
var introPage: some View {
|
|
Clamp {
|
|
StatusPage {
|
|
VStack(spacing: 6) {
|
|
Label("Declarative GTK apps in Swift")
|
|
.title3()
|
|
.marginTop(16)
|
|
Label("A familiar SwiftUI-like API, zero GObject boilerplate")
|
|
.marginBottom(16)
|
|
}
|
|
.card()
|
|
}
|
|
.title("Welcome to Portico")
|
|
.description("Swipe to explore")
|
|
.iconName("face-smile-symbolic")
|
|
}
|
|
.hexpand(true)
|
|
.vexpand(true)
|
|
}
|
|
|
|
var counterPage: some View {
|
|
Clamp {
|
|
StatusPage {
|
|
HStack(spacing: 12) {
|
|
Button("-") { count -= 1 }
|
|
.circular()
|
|
Label("Count: \(count)")
|
|
.title1()
|
|
Button("+") { count += 1 }
|
|
.circular()
|
|
}
|
|
.halign(.center)
|
|
}
|
|
.title("Reactive Counter")
|
|
.description("@State + Binding drive targeted widget updates")
|
|
.iconName("applications-engineering-symbolic")
|
|
}
|
|
.hexpand(true)
|
|
.vexpand(true)
|
|
}
|
|
|
|
var settingsPage: some View {
|
|
Clamp {
|
|
StatusPage {
|
|
VStack(spacing: 12) {
|
|
Label("Name: \(name), Dark mode: \(darkMode), Volume: \(volume)")
|
|
.title2()
|
|
ListBox {
|
|
EntryRow()
|
|
.title("Your Name")
|
|
.text($name)
|
|
SwitchRow()
|
|
.title("Dark Mode")
|
|
.active($darkMode)
|
|
SpinRow(min: 0, max: 100, step: 5)
|
|
.title("Volume")
|
|
.value($volume)
|
|
}
|
|
.boxedList()
|
|
}
|
|
}
|
|
.title("Quick Settings")
|
|
.description("Live GObject property bindings")
|
|
.iconName("application-x-firmware-symbolic")
|
|
}
|
|
.hexpand(true)
|
|
.vexpand(true)
|
|
}
|
|
}
|