-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWatchCalculatorView.swift
49 lines (44 loc) · 1.49 KB
/
WatchCalculatorView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// WatchCalculatorView.swift
// seximalWatch WatchKit Extension
//
// Created by Henrik Storch on 27.06.21.
//
import SwiftUI
struct WatchCalculatorView: View {
@ObservedObject var model: Calculator = Calculator()
let columns: [GridItem] = [
GridItem(spacing: Constraint.calcPadding, alignment: .trailing),
GridItem(spacing: Constraint.calcPadding, alignment: .center),
GridItem(spacing: Constraint.calcPadding, alignment: .center)]
var body: some View {
VStack {
HStack {
Spacer()
Text(model.logic.output)
.font(.system(size: 20))
if model.logic.output != "0" {
Image(systemName: "delete.left.fill")
.imageScale(.large)
.onTapGesture {
model.apply(.mod(.del))
}
.background(Color.black)
}
}
Divider()
LazyVGrid(columns: columns, spacing: Constraint.calcPadding, content: {
ForEach(Calculator.Action.allCases) { op in
CalculatorButton(type: op, font: .body.bold(), model: model)
.cornerRadius(6)
// .padding(.top, 5)
}
})
}
}
}
struct CalculatorView_Previews: PreviewProvider {
static var previews: some View {
WatchCalculatorView()
}
}