CarbsInputView.swift 776 B

12345678910111213141516171819202122232425262728293031
  1. import Foundation
  2. import SwiftUI
  3. // MARK: - Carbs Input View
  4. struct CarbsInputView: View {
  5. @Environment(\.dismiss) var dismiss
  6. @State private var carbsAmount = 0
  7. let state: WatchState
  8. var body: some View {
  9. NavigationView {
  10. VStack {
  11. Picker("Carbs", selection: $carbsAmount) {
  12. ForEach(0 ... 100, id: \.self) { amount in
  13. Text("\(amount)g").tag(amount)
  14. }
  15. }
  16. Button("Add Carbs") {
  17. state.sendCarbsRequest(carbsAmount)
  18. dismiss()
  19. }
  20. .buttonStyle(.bordered)
  21. .tint(.orange)
  22. }
  23. .navigationTitle("Add Carbs")
  24. }
  25. }
  26. }