ZStack {
Color.orange.edgesIgnoringSafeArea(.all)
VStack {
Spacer()
NavigationLink(destination: // EASY VIEW
ZStack {
Color.orange.edgesIgnoringSafeArea(.all)
VStack {
// Reset button
Button(action: {
viewModel.num1 = Int.random(in: 0...5)
viewModel.num2 = Int.random(in: 0...5)
viewModel.resetVariables()
}, label: {
Text("Reset?")
.foregroundColor(.red)
.font(.system(size: 30))
.opacity(viewModel.resetButton ? 1:0)
})
Spacer()
Spacer()
HStack {
Text("\(viewModel.num1) \(Image(systemName: operatorSymbol)) \(viewModel.num2) = ")
.font(.system(size: 50)).foregroundColor(.black).opacity(viewModel.numbersVisable ? 1:0)
// Text Imputed by keypad
Text(viewModel.appendNumberPadLine).foregroundColor(.gray).font(.system(size: 50))
}
Spacer()
Spacer()
// Button to pass
Button(action: {
viewModel.num1 = Int.random(in: 0...5)
viewModel.num2 = Int.random(in: 0...5)
viewModel.passing()
viewModel.appendNumberPadLine = ""
if viewModel.totalCounter >= 20 {
viewModel.roundOver()
}
}, label: {
Text("Pass")
.font(.system(size: 20))
.font(.title2)
.padding(15)
.foregroundColor(.white)
.background(Color.black)
.cornerRadius(15)
.opacity(viewModel.numbersVisable ? 1:0)
})
// Button to check
Button(action: {
viewModel.checkNumbers()
viewModel.appendNumberPadLine = ""
viewModel.num1 = Int.random(in: 0...5)
viewModel.num2 = Int.random(in: 0...5)
if viewModel.totalCounter >= 20 {
viewModel.roundOver()
}
viewModel.resetClear()
}, label: {
Text("Check")
.font(.system(size: 30))
.font(.title2)
.padding(15)
.foregroundColor(.white)
.background(Color.green)
.cornerRadius(15)
.opacity(viewModel.numbersVisable ? 1:0)
})
Spacer()
}
Spacer()
}
}.navigationBarTitle(operatorName, displayMode: .inline)
) {
Text("Easy")
.font(.title2)
.padding(35)
.foregroundColor(.white)
.background(Color.green)
.cornerRadius(40)
.onAppear(perform: { viewModel.resetVariables();
})
}