refactor into smaller units
This commit is contained in:
@@ -37,3 +37,42 @@ extension View {
|
||||
self.disabled(condition).opacity(condition ? 0.4 : 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
struct ToggleChip: View {
|
||||
let label: String
|
||||
@Binding var isOn: Bool
|
||||
|
||||
var body: some View {
|
||||
Button(action: { isOn.toggle() }) {
|
||||
Text(label)
|
||||
.fontWeight(isOn ? .semibold : .regular)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.foregroundColor(isOn ? Color(UIColor.systemBackground) : .primary)
|
||||
.background(isOn ? Color.primary : Color.clear)
|
||||
.clipShape(Capsule())
|
||||
.overlay(Capsule().stroke(Color.primary, lineWidth: 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct StatStepper: View {
|
||||
let top: String
|
||||
let value: String
|
||||
let bottom: String
|
||||
let increment: () -> Void
|
||||
let decrement: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(top)
|
||||
Group {
|
||||
Text("▲").gesture(TapGesture().onEnded { increment() })
|
||||
Text(value)
|
||||
Text("▼").gesture(TapGesture().onEnded { decrement() })
|
||||
}
|
||||
.font(.system(size: 30))
|
||||
Text(bottom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user