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,62 @@
//
// RollSummaryView.swift
// Bunch O' Dice
//
import SwiftUI
struct RollSummaryView: View {
@EnvironmentObject var current: Roll
@State private var showFillView = false
var body: some View {
HStack(spacing: 12) {
Button(action: { showFillView.toggle() }) {
VStack(spacing: 4) {
Text("Dice Pool")
.font(.caption)
Text(String(current.total))
.font(.system(size: 28, weight: .black))
}
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: 10))
.foregroundColor(.black)
}
.sheet(isPresented: $showFillView,
onDismiss: { current.resetPool() }) {
VStack {
AddToPool()
Button("Accept", action: { showFillView.toggle() })
.padding(20)
}
}
Button(action: current.incrementState) {
VStack(spacing: 4) {
Text(current.state.text())
.font(.caption)
Text(String(current.result))
.font(.system(size: 28, weight: .black))
if current.state == .armour && current.mortalWoundsTotal > 0 {
Text("mortal: \(current.mortalWoundsTotal)")
.font(.caption)
}
}
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: 10))
.foregroundColor(.black)
}
}
.padding()
.background(Color.black)
.clipShape(RoundedRectangle(cornerRadius: 14))
}
}
#Preview {
RollSummaryView()
.environmentObject(Roll())
}