AppDiagnosticsRootView.swift 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import SwiftUI
  2. import Swinject
  3. extension AppDiagnostics {
  4. struct RootView: BaseView {
  5. let resolver: Resolver
  6. @State var state = StateModel()
  7. @Environment(\.colorScheme) var colorScheme
  8. @Environment(AppState.self) var appState
  9. @Environment(\.openURL) var openURL
  10. var body: some View {
  11. List {
  12. Section(
  13. header: Text("Anonymized Data Sharing"),
  14. content: {
  15. VStack(alignment: .leading) {
  16. ForEach(DiagnosticsSharingOption.allCases, id: \.self) { option in
  17. Button(action: {
  18. state.diagnosticsSharingOption = option
  19. }) {
  20. HStack {
  21. Image(
  22. systemName: state
  23. .diagnosticsSharingOption == option ? "largecircle.fill.circle" : "circle"
  24. )
  25. .foregroundColor(state.diagnosticsSharingOption == option ? .accentColor : .secondary)
  26. .imageScale(.large)
  27. Text(option.displayName)
  28. .foregroundColor(.primary)
  29. Spacer()
  30. }
  31. .background(Color.chart.opacity(0.65))
  32. .cornerRadius(10)
  33. }
  34. .buttonStyle(.plain)
  35. }
  36. .padding()
  37. }
  38. .onChange(of: state.diagnosticsSharingOption) {
  39. state.applyDiagnostics()
  40. }
  41. }
  42. ).listRowBackground(Color.chart)
  43. Section {
  44. VStack(alignment: .leading, spacing: 8) {
  45. Text("Why does Trio collect this data?").bold()
  46. VStack(alignment: .leading, spacing: 4) {
  47. BulletPoint(
  48. String(
  49. localized: "App diagnostic insights help us enhance app stability, ensure safety for all users, and enable us to quickly identify and resolve critical issues."
  50. )
  51. )
  52. BulletPoint(
  53. String(
  54. localized: "Trio collects the app's state on crash, device, iOS and general system info, and a stack trace."
  55. )
  56. )
  57. BulletPoint(
  58. String(
  59. localized: "Trio does not collect any health related data, e.g. glucose readings, insulin rates or doses, meal data, setting values, or similar."
  60. )
  61. )
  62. BulletPoint(
  63. String(
  64. localized: "Trio does not track any usage metrics or any other personal data about users other than the used iPhone model and iOS version."
  65. )
  66. )
  67. }
  68. Text(
  69. "Diagnostics are sent to a Google Firebase Crashlytics project, which is securely maintained and accessed only by the Trio team."
  70. )
  71. }
  72. .font(.footnote)
  73. .multilineTextAlignment(.leading)
  74. .foregroundStyle(Color.secondary)
  75. }.listRowBackground(Color.clear)
  76. }
  77. .listSectionSpacing(sectionSpacing)
  78. .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
  79. .onAppear(perform: configureView)
  80. .navigationBarTitle("App Diagnostics")
  81. .navigationBarTitleDisplayMode(.automatic)
  82. .toolbar {
  83. ToolbarItem(placement: .topBarTrailing) {
  84. Button("Privacy Policy") {
  85. if let url = URL(string: "https://github.com/nightscout/Trio/blob/dev/PRIVACY_POLICY.md") {
  86. openURL(url)
  87. } else {
  88. debug(.default, "Invalid URL! Could not gracefully unwrap privacy policy link!")
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }