DiagnosticsStepView.swift 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import SwiftUI
  2. struct DiagnosticsStepView: View {
  3. @Bindable var state: Onboarding.StateModel
  4. @Environment(\.openURL) var openURL
  5. var body: some View {
  6. VStack(alignment: .leading, spacing: 20) {
  7. Text("If you prefer not to share this anonymized data, you can opt-out of data sharing.")
  8. .font(.headline)
  9. .padding(.horizontal)
  10. .multilineTextAlignment(.leading)
  11. ForEach(DiagnosticsSharingOption.allCases, id: \.self) { option in
  12. Button(action: {
  13. state.updateDiagnosticsOption(to: option)
  14. }) {
  15. HStack {
  16. Image(systemName: state.diagnosticsSharingOption == option ? "largecircle.fill.circle" : "circle")
  17. .foregroundColor(state.diagnosticsSharingOption == option ? .accentColor : .secondary)
  18. .imageScale(.large)
  19. Text(option.displayName)
  20. .foregroundColor(.primary)
  21. Spacer()
  22. }
  23. .padding()
  24. .background(Color.chart.opacity(0.65))
  25. .cornerRadius(10)
  26. }
  27. .buttonStyle(.plain)
  28. }
  29. Toggle(isOn: $state.hasAcceptedPrivacyPolicy) {
  30. HStack {
  31. Text("I have read and accept the")
  32. Button("Privacy Policy") {
  33. openURL(URL(string: "https://github.com/nightscout/Trio/blob/dev/PRIVACY_POLICY.md")!)
  34. }
  35. .foregroundColor(.accentColor)
  36. .underline()
  37. }
  38. .font(.footnote)
  39. .bold()
  40. }
  41. .toggleStyle(CheckboxToggleStyle(tint: Color.accentColor))
  42. .padding(.horizontal)
  43. .disabled(state.diagnosticsSharingOption == .disabled)
  44. .opacity(state.diagnosticsSharingOption == .disabled ? 0.35 : 1)
  45. VStack(alignment: .leading, spacing: 8) {
  46. Text("Why does Trio collect this data?").bold()
  47. VStack(alignment: .leading, spacing: 4) {
  48. BulletPoint(
  49. String(
  50. localized: "App diagnostic insights help us enhance app stability, ensure safety for all users, and enable us to quickly identify and resolve critical issues."
  51. )
  52. )
  53. BulletPoint(
  54. String(
  55. localized: "Trio collects the app's state on crash, device, iOS and general system info, and a stack trace."
  56. )
  57. )
  58. BulletPoint(
  59. String(
  60. localized: "Trio does not collect any health related data, e.g. glucose readings, insulin rates or doses, meal data, setting values, or similar."
  61. )
  62. )
  63. BulletPoint(
  64. String(
  65. localized: "Trio does not track any usage metrics or any other personal data about users other than the used iPhone model and iOS version."
  66. )
  67. )
  68. }
  69. Text(
  70. "Diagnostics are sent to a Google Firebase Crashlytics project, which is securely maintained and accessed only by the Trio team."
  71. )
  72. }
  73. .multilineTextAlignment(.leading)
  74. .padding(.horizontal)
  75. .font(.footnote)
  76. .foregroundStyle(Color.secondary)
  77. }
  78. .onAppear {
  79. state.syncDiagnosticsOptionFromStorage()
  80. }
  81. }
  82. }