OnboardingStep.swift 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // LoopFollow
  2. // OnboardingStep.swift
  3. import Foundation
  4. /// The phases of the first-run onboarding wizard.
  5. ///
  6. /// Progress is tracked by phase, not by page: the set of phases is stable, while
  7. /// some phases contain a variable number of internal pages (the Nightscout connect
  8. /// phase can be one or two pages; the alarms phase is one page per offered alarm,
  9. /// which differs between Nightscout and Dexcom). Those phases report their
  10. /// within-phase position through `OnboardingViewModel.phaseProgress`, so the
  11. /// overall progress bar stays smooth no matter how many pages a phase has.
  12. ///
  13. /// `connect` renders the Nightscout, Dexcom, or import view depending on the data
  14. /// source the user picks in `dataSource`.
  15. enum OnboardingStep: CaseIterable, Hashable {
  16. case welcome
  17. case overview
  18. case dataSource
  19. case connect
  20. case units
  21. case generalAlarms
  22. case alarms
  23. case tabOrder
  24. case notifications
  25. case telemetry
  26. case completion
  27. /// Steps that show the progress bar + phase label + Skip at the top. The
  28. /// welcome and completion screens are full-bleed and provide their own CTA.
  29. var showsProgressHeader: Bool {
  30. switch self {
  31. case .welcome, .completion:
  32. return false
  33. default:
  34. return true
  35. }
  36. }
  37. /// Steps that use the shared Back / Continue footer. Phases that contain their
  38. /// own internal pages or custom primary buttons (overview, connect, units,
  39. /// alarms, notifications, telemetry) supply their own footer instead, as do the
  40. /// full-bleed welcome and completion screens.
  41. var usesSharedFooter: Bool {
  42. switch self {
  43. case .dataSource, .generalAlarms, .tabOrder:
  44. return true
  45. default:
  46. return false
  47. }
  48. }
  49. /// Short name shown in the progress header for this phase.
  50. var phaseTitle: String {
  51. switch self {
  52. case .welcome, .completion: return ""
  53. case .overview: return "Overview"
  54. case .dataSource: return "Data source"
  55. case .connect: return "Connect"
  56. case .units: return "Units & metrics"
  57. case .generalAlarms: return "Alarm basics"
  58. case .alarms: return "Alarms"
  59. case .tabOrder: return "Tabs"
  60. case .notifications: return "Notifications"
  61. case .telemetry: return "Privacy"
  62. }
  63. }
  64. }