AppDiagnosticsRootView.swift 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. var body: some View {
  10. List {
  11. Section(
  12. header: Text("Anonymized Data Sharing"),
  13. content: {
  14. VStack {
  15. ForEach(DiagnosticsSharingOption.allCases, id: \.self) { option in
  16. Button(action: {
  17. state.diagnosticsSharingOption = option
  18. }) {
  19. HStack {
  20. Image(
  21. systemName: state
  22. .diagnosticsSharingOption == option ? "largecircle.fill.circle" : "circle"
  23. )
  24. .foregroundColor(state.diagnosticsSharingOption == option ? .accentColor : .secondary)
  25. .imageScale(.large)
  26. Text(option.displayName)
  27. .foregroundColor(.primary)
  28. Spacer()
  29. }
  30. .background(Color.chart.opacity(0.65))
  31. .cornerRadius(10)
  32. }
  33. .buttonStyle(.plain)
  34. }
  35. .padding()
  36. }
  37. .onChange(of: state.diagnosticsSharingOption) {
  38. state.applyDiagnostics()
  39. }
  40. }
  41. ).listRowBackground(Color.chart)
  42. Section {
  43. VStack(alignment: .leading, spacing: 8) {
  44. Text("Why does Trio collect this data?").bold()
  45. VStack(alignment: .leading, spacing: 4) {
  46. Text(
  47. "• App diagnostic insights help us enhance app stability, ensure safety for all users, and enable us to quickly identify and resolve critical issues."
  48. )
  49. Text(
  50. "• Trio collects the app's state on crash, device, iOS and general system info, and a stack trace."
  51. )
  52. Text(
  53. "• Trio does not collect any health related data, e.g. glucose readings, insulin rates or doses, meal data, setting values, or similar."
  54. )
  55. Text(
  56. "• Trio does not track any usage metrics or any other personal data about users other than the used iPhone model and iOS version."
  57. )
  58. }
  59. Text(
  60. "Diagnostics are sent to a Google Firebase Crashlytics project, which is securely maintained and accessed only by the Trio team."
  61. )
  62. }
  63. .font(.footnote)
  64. .multilineTextAlignment(.leading)
  65. .foregroundStyle(Color.secondary)
  66. }.listRowBackground(Color.clear)
  67. }
  68. .listSectionSpacing(sectionSpacing)
  69. .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
  70. .onAppear(perform: configureView)
  71. .navigationBarTitle("App Diagnostics")
  72. .navigationBarTitleDisplayMode(.automatic)
  73. }
  74. }
  75. }