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,53 @@
//
// RerollPickerView.swift
// Bunch O' Dice
//
import SwiftUI
@available(iOS 26.0, *)
struct RerollPickerView: View {
@EnvironmentObject var current: Roll
@Binding var mode: RerollMode
var body: some View {
let actionBinding = Binding<RerollMode>(
get: { mode },
set: { newValue in
mode = newValue
if newValue != .none {
current.applyReroll()
} else {
current.undoReroll()
}
}
)
HStack(spacing: 8) {
Text("Reroll")
HStack(spacing: 6) {
ForEach(RerollMode.allCases, id: \.self) { m in
let isSelected = mode == m
Button(action: { actionBinding.wrappedValue = m }) {
Text(m.label)
.fontWeight(isSelected ? .semibold : .regular)
.padding(.horizontal, 12)
.padding(.vertical, 6)
.foregroundColor(isSelected ? Color(UIColor.systemBackground) : .primary)
.background(isSelected ? Color.green : Color.gray)
.clipShape(Capsule())
.overlay(Capsule().stroke(Color.primary, lineWidth: 1))
.glassEffect()
}
}
}
}
.padding(.horizontal)
}
}
#Preview {
if #available(iOS 26.0, *) {
RerollPickerView(mode: .constant(.none))
.environmentObject(Roll())
}
}