ui cleanup

This commit is contained in:
Rory Hinnen
2026-09-07 11:15:18 -05:00
parent 025b006194
commit 2c10c7c093
+51 -28
View File
@@ -76,6 +76,7 @@ struct MainView: View {
//MARK: State Views
@ViewBuilder func armourCalculator(controlSize: Double) -> some View {
VStack {
HStack(alignment: .top) {
Spacer()
VStack {
@@ -98,13 +99,14 @@ struct MainView: View {
Text("Penetration")
}
Spacer()
VStack{
VStack {
Text("Invulnerable")
Toggle("", isOn: $current.invulnerable).labelsHidden()
.padding()
}
Spacer()
VStack {
}
HStack {
Text("Reroll")
Picker("", selection: $current.saveRerollMode) {
ForEach(RerollMode.allCases, id: \.self) { mode in
@@ -112,20 +114,19 @@ struct MainView: View {
}
}
.pickerStyle(.segmented)
.frame(width: 180)
Button("🎲") {
current.applyReroll()
}
.disabled(current.saveRerollMode == .none || current.saveHasRerolled)
.padding()
.font(.system(size: controlSize))
}
Spacer()
.padding(.horizontal)
}
.padding()
}
@ViewBuilder func woundCalculator(controlSize: Double) -> some View {
VStack {
HStack(alignment: .top) {
Spacer()
VStack {
@@ -143,7 +144,6 @@ struct MainView: View {
}.font(.system(size: controlSize))
Text("Strength")
}
Spacer()
VStack {
Text("Toughness")
@@ -181,7 +181,8 @@ struct MainView: View {
Text("Modifier")
}
Spacer()
VStack {
}
HStack {
Text("Reroll")
Picker("", selection: $current.woundRerollMode) {
ForEach(RerollMode.allCases, id: \.self) { mode in
@@ -189,21 +190,21 @@ struct MainView: View {
}
}
.pickerStyle(.segmented)
.frame(width: 180)
Button("🎲") {
current.applyReroll()
}
.disabled(current.woundRerollMode == .none || current.woundHasRerolled)
.padding()
.font(.system(size: controlSize))
}
Spacer()
}.padding()
.padding(.horizontal)
}
.padding()
}
@ViewBuilder func hitCalculator(controlSize: Double) -> some View {
VStack {
HStack(alignment: .top) {
Group {
Spacer()
VStack {
Text("Hit")
.multilineTextAlignment(.center)
@@ -212,8 +213,7 @@ struct MainView: View {
.gesture(TapGesture() .onEnded {
current.modifier = current.modifier.add()
})
Text( (current.modifier.rawValue > 0 ?
"+" : "") +
Text((current.modifier.rawValue > 0 ? "+" : "") +
String(current.modifier.rawValue))
Text("▼")
.gesture(TapGesture() .onEnded {
@@ -223,6 +223,7 @@ struct MainView: View {
.font(.system(size: controlSize))
Text("Modifier")
}
Spacer()
VStack {
Text("Blow Up")
VStack {
@@ -239,9 +240,10 @@ struct MainView: View {
}
.padding()
.font(.system(size: controlSize))
}
VStack {
Spacer()
}
HStack {
Text("Reroll")
Picker("", selection: $current.hitRerollMode) {
ForEach(RerollMode.allCases, id: \.self) { mode in
@@ -249,16 +251,15 @@ struct MainView: View {
}
}
.pickerStyle(.segmented)
.frame(width: 180)
Button("🎲") {
current.applyReroll()
}
.disabled(current.hitRerollMode == .none || current.hitHasRerolled)
.padding()
.font(.system(size: controlSize))
}
.padding(.horizontal)
}
}.padding()
.padding()
}
//MARK: die views
@@ -272,6 +273,7 @@ struct MainView: View {
Text(String(current.dice.value(which: whichDie)))
.foregroundColor(current.state == .armour ?
displayColorArmorText : displayColorHit)
.frame(minWidth: 44, alignment: .trailing)
Image(systemName: "die.face." + String(whichDie.rawValue) + ".fill")
.foregroundColor(current.state == .armour ?
displayColorArmor : displayColorHit)
@@ -326,8 +328,18 @@ struct MainView: View {
VStack{
HStack {
VStack {
Button(action: {showFillView.toggle()}) {
buttons(color: blue, label: "Pool", value: current.total)
Button(action: { showFillView.toggle() }) {
VStack(spacing: 2) {
Text("Dice Pool")
.font(.caption)
Text(String(current.total))
.font(.system(size: 28, weight: .black))
}
.padding(.horizontal, 20)
.padding(.vertical, 8)
.background(Color(blue).opacity(0.35))
.clipShape(RoundedRectangle(cornerRadius: 10))
.foregroundColor(.primary)
}
.sheet(isPresented: $showFillView,
onDismiss: { current.resetPool() }) {
@@ -337,11 +349,9 @@ struct MainView: View {
.padding(20)
}
}
Spacer()
Button(action: current.incrementState) {
buttons(color: red, label: current.state.text(), value: current.result)
}
}.padding(.leading, padSize)
Spacer()
diePool().padding(.trailing, padSize)
@@ -366,9 +376,22 @@ struct MainView: View {
.sheet(isPresented: $sheet.isShowing, content: sheetContent)}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
MainView()
.environmentObject(Roll())
}
#Preview("Hit") {
MainView().environmentObject(Roll())
}
#Preview("Wound") {
MainView().environmentObject({
let r = Roll()
r.state = .wound
return r
}())
}
#Preview("Armour") {
MainView().environmentObject({
let r = Roll()
r.state = .armour
return r
}())
}