51 lines
1.4 KiB
Swift
51 lines
1.4 KiB
Swift
//
|
|
// IncrementDie.swift
|
|
// Bunch O' Dice
|
|
//
|
|
// Created by Rory Martin Hinnen on 6/7/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct AddToPool: View {
|
|
@EnvironmentObject var current: Roll
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Spacer()
|
|
Text(String(current.total) + " 🎲")
|
|
.font(.system(size: 40))
|
|
.padding(15)
|
|
HStack {
|
|
ForEach(Array(stride(from: 2, through: 0, by: -1)), id: \.self) { place in
|
|
VStack{
|
|
Text("▲")
|
|
.gesture(TapGesture().onEnded({
|
|
current.incrementDigits(place: place)
|
|
}))
|
|
Text(String(current.totalDigits[place]))
|
|
.padding(4)
|
|
.border(.black, width: 1.0)
|
|
Text("▼")
|
|
.gesture(TapGesture().onEnded({
|
|
current.decrementDigits(place: place)
|
|
}))
|
|
}
|
|
}
|
|
}
|
|
.font(.system(size: 45))
|
|
.padding(10)
|
|
Button("Clear", action: {current.total = 0})
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
|
|
struct IncrementDie_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
AddToPool()
|
|
.environmentObject(Roll())
|
|
|
|
}
|
|
}
|