51 lines
1.3 KiB
Swift
51 lines
1.3 KiB
Swift
//
|
|
// StatePickerView.swift
|
|
// Bunch O' Dice
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct StatePickerView: View {
|
|
@EnvironmentObject var current: Roll
|
|
private let controlSize = 30.0
|
|
|
|
var body: some View {
|
|
HStack {
|
|
Button(action: { current.state = .hit }) {
|
|
ZStack {
|
|
if current.state == .hit { circle() }
|
|
Text(RollState.hit.print())
|
|
}
|
|
}
|
|
.glassEffect()
|
|
Button(action: { current.state = .wound }) {
|
|
ZStack {
|
|
if current.state == .wound { circle() }
|
|
Text(RollState.wound.print())
|
|
}
|
|
}
|
|
.glassEffect()
|
|
Button(action: { current.state = .armour }) {
|
|
ZStack {
|
|
if current.state == .armour { circle() }
|
|
Text(RollState.armour.print())
|
|
}
|
|
}
|
|
.glassEffect()
|
|
}
|
|
.font(.system(size: 60))
|
|
}
|
|
|
|
@ViewBuilder private func circle() -> some View {
|
|
Circle()
|
|
.fill(Color.gray)
|
|
.blur(radius: 2.0)
|
|
.frame(width: controlSize * 2.5, height: controlSize * 2.5, alignment: .center)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
StatePickerView()
|
|
.environmentObject(Roll())
|
|
}
|