adwaita-swift/Tests/CounterDemo.swift
david-swift 921f025e39 Update demo and fix bugs
- Fix build optional in ViewBuilder
- Fix maximum size frame modifier
- Improve inspector wrapper
- Improve header bar
- Improve status page
- Improve the naming of some elements
2023-10-12 22:15:15 +02:00

49 lines
980 B
Swift

//
// CounterDemo.swift
// Adwaita
//
// Created by david-swift on 25.09.23.
//
// swiftlint:disable missing_docs
import Adwaita
import GTUI
struct CounterDemo: View {
@State private var count = 0
var view: Body {
VStack {
HStack {
CountButton(count: $count, icon: .goPrevious) { $0 -= 1 }
Text("\(count)")
.style("title-1")
.frame(minWidth: 100)
CountButton(count: $count, icon: .goNext) { $0 += 1 }
}
.halign(.center)
}
.valign(.center)
.padding()
}
private struct CountButton: View {
@Binding var count: Int
var icon: Icon.DefaultIcon
var action: (inout Int) -> Void
var view: Body {
Button(icon: .default(icon: icon)) {
action(&count)
}
.style("circular")
}
}
}
// swiftlint:enable missing_docs