CheckInsertedCannulaView.swift 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // CheckInsertedCannulaView.swift
  3. // OmniKit
  4. //
  5. // Created by Pete Schwamb on 4/3/20.
  6. // Copyright © 2021 LoopKit Authors. All rights reserved.
  7. //
  8. import SwiftUI
  9. import LoopKitUI
  10. struct CheckInsertedCannulaView: View {
  11. @State private var cancelModalIsPresented: Bool = false
  12. private var didRequestDeactivation: () -> Void
  13. private var wasInsertedProperly: () -> Void
  14. init(didRequestDeactivation: @escaping () -> Void, wasInsertedProperly: @escaping () -> Void) {
  15. self.didRequestDeactivation = didRequestDeactivation
  16. self.wasInsertedProperly = wasInsertedProperly
  17. }
  18. var body: some View {
  19. GuidePage(content: {
  20. VStack {
  21. LeadingImage("Cannula Inserted")
  22. HStack {
  23. FrameworkLocalText("Is the cannula inserted properly?", comment: "Question to confirm the cannula is inserted properly").bold()
  24. Spacer()
  25. }
  26. HStack {
  27. FrameworkLocalText("The window on the top of the Pod should be colored pink when the cannula is properly inserted into the skin.", comment: "Description of proper cannula insertion").fixedSize(horizontal: false, vertical: true)
  28. Spacer()
  29. }.padding(.vertical)
  30. }
  31. }) {
  32. VStack(spacing: 10) {
  33. Button(action: {
  34. self.wasInsertedProperly()
  35. }) {
  36. Text(LocalizedString("Yes", comment: "Button label for user to answer cannula was properly inserted"))
  37. .actionButtonStyle(.primary)
  38. }
  39. Button(action: {
  40. self.didRequestDeactivation()
  41. }) {
  42. Text(LocalizedString("No", comment: "Button label for user to answer cannula was not properly inserted"))
  43. .actionButtonStyle(.destructive)
  44. }
  45. }.padding()
  46. }
  47. .animation(.default)
  48. .alert(isPresented: $cancelModalIsPresented) { cancelPairingModal }
  49. .navigationBarTitle(LocalizedString("Check Cannula", comment: "navigation bar title for check cannula"), displayMode: .automatic)
  50. .navigationBarItems(trailing: cancelButton)
  51. .navigationBarBackButtonHidden(true)
  52. }
  53. var cancelButton: some View {
  54. Button(LocalizedString("Cancel", comment: "Cancel button text in navigation bar on insert cannula screen")) {
  55. cancelModalIsPresented = true
  56. }
  57. .accessibility(identifier: "button_cancel")
  58. }
  59. var cancelPairingModal: Alert {
  60. return Alert(
  61. title: FrameworkLocalText("Are you sure you want to cancel Pod setup?", comment: "Alert title for cancel pairing modal"),
  62. message: FrameworkLocalText("If you cancel Pod setup, the current Pod will be deactivated and will be unusable.", comment: "Alert message body for confirm pod attachment"),
  63. primaryButton: .destructive(FrameworkLocalText("Yes, Deactivate Pod", comment: "Button title for confirm deactivation option"), action: { didRequestDeactivation() } ),
  64. secondaryButton: .default(FrameworkLocalText("No, Continue With Pod", comment: "Continue pairing button title of in pairing cancel modal"))
  65. )
  66. }
  67. }
  68. struct CheckInsertedCannulaView_Previews: PreviewProvider {
  69. static var previews: some View {
  70. CheckInsertedCannulaView(didRequestDeactivation: {}, wasInsertedProperly: {} )
  71. }
  72. }