54 lines
1.6 KiB
Swift
54 lines
1.6 KiB
Swift
//
|
|
// 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())
|
|
}
|
|
}
|