63 lines
1.8 KiB
Swift
63 lines
1.8 KiB
Swift
import Portico
|
|
|
|
private struct Item: Identifiable { let id: Int; let title: String }
|
|
|
|
struct ListDemo: View {
|
|
@State private var items = [Item(id: 1, title: "One"),
|
|
Item(id: 2, title: "Two"),
|
|
Item(id: 3, title: "Three")]
|
|
@State private var next = 4
|
|
|
|
var body: some View {
|
|
VStack(spacing: 12) {
|
|
HStack(spacing: 12) {
|
|
Button("Add") { items.append(Item(id: next, title: "Item \(next)")); next += 1 }
|
|
Button("Remove first") { if !items.isEmpty { items.removeFirst() } }
|
|
Button("Reverse") { items.reverse() }
|
|
}
|
|
ForEach($items, id: \.id) { item in
|
|
Label(item.title)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - Adw widget demo
|
|
|
|
struct AdwDemo: View {
|
|
@State private var title = "Welcome to Portico!"
|
|
@State private var description = "Making GTK apps is as simple as 1, 2, 3!"
|
|
|
|
var body: some View {
|
|
VStack {
|
|
HeaderBar()
|
|
Clamp {
|
|
StatusPage {
|
|
PreferencesGroup {
|
|
EntryRow()
|
|
.title("Title")
|
|
.text($title)
|
|
EntryRow()
|
|
.title("Description")
|
|
.text($description)
|
|
}
|
|
.title("Welcome Options")
|
|
}
|
|
.title($title)
|
|
.description($description)
|
|
.iconName("person-symbolic")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct ExampleApp: App {
|
|
var applicationId: String? { "dev.bscubed.PorticoExample" }
|
|
|
|
var body: some Scene {
|
|
Window { _ in AdwDemo() }
|
|
.title("Portico Example")
|
|
.defaultSize(width: 1280, height: 800)
|
|
}
|
|
}
|