ExpirationReminderSetupView.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // ExpirationReminderSetupView.swift
  3. // OmniKit
  4. //
  5. // Created by Pete Schwamb on 5/17/21.
  6. // Copyright © 2021 LoopKit Authors. All rights reserved.
  7. //
  8. import SwiftUI
  9. import LoopKitUI
  10. struct ExpirationReminderSetupView: View {
  11. @State var expirationReminderDefault: Int = 2
  12. public var valueChanged: ((_ value: Int) -> Void)?
  13. public var continueButtonTapped: (() -> Void)?
  14. public var cancelButtonTapped: (() -> Void)?
  15. var body: some View {
  16. GuidePage(content: {
  17. VStack(alignment: .leading, spacing: 15) {
  18. Text(LocalizedString("The App notifies you in advance of Pod expiration.\n\nScroll to set the number of hours advance notice you would like to have.", comment: "Description text on ExpirationReminderSetupView")).fixedSize(horizontal: false, vertical: true)
  19. Divider()
  20. ExpirationReminderPickerView(expirationReminderDefault: $expirationReminderDefault, collapsible: false, showingHourPicker: true)
  21. .onChange(of: expirationReminderDefault) { value in
  22. valueChanged?(value)
  23. }
  24. }
  25. .padding(.vertical, 8)
  26. }) {
  27. VStack {
  28. Button(action: {
  29. continueButtonTapped?()
  30. }) {
  31. Text(LocalizedString("Next", comment: "Text of continue button on ExpirationReminderSetupView"))
  32. .actionButtonStyle(.primary)
  33. }
  34. }
  35. .padding()
  36. }
  37. .navigationBarTitle(LocalizedString("Expiration Reminder", comment: "navigation bar title for expiration reminder"), displayMode: .automatic)
  38. .navigationBarHidden(false)
  39. .toolbar {
  40. ToolbarItem(placement: .navigationBarTrailing) {
  41. Button(LocalizedString("Cancel", comment: "Cancel button title"), action: {
  42. cancelButtonTapped?()
  43. })
  44. }
  45. }
  46. }
  47. }
  48. struct ExpirationReminderSetupView_Previews: PreviewProvider {
  49. static var previews: some View {
  50. ExpirationReminderSetupView()
  51. }
  52. }