ui cleanup

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