// // 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()) } }.padding(10) Button(action: { current.state = .wound }) { ZStack { if current.state == .wound { circle() } Text(RollState.wound.print()) } }.padding(10) Button(action: { current.state = .armour }) { ZStack { if current.state == .armour { circle() } Text(RollState.armour.print()) } }.padding(10) } .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()) }