refactor into smaller units

This commit is contained in:
Rory Hinnen
2026-09-12 11:25:34 -05:00
parent 4eb7494d08
commit 1507f8b8c6
14 changed files with 637 additions and 415 deletions
@@ -0,0 +1,50 @@
//
// 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())
}