OnboardingStepViews.swift 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import SwiftUI
  2. /// Welcome step view shown at the beginning of onboarding.
  3. struct WelcomeStepView: View {
  4. var body: some View {
  5. VStack(alignment: .center, spacing: 20) {
  6. Image("trioCircledNoBackground")
  7. .resizable()
  8. .scaledToFit()
  9. .frame(height: 100)
  10. .padding()
  11. Text("Hi there!")
  12. .font(.title2)
  13. .fontWeight(.bold)
  14. .multilineTextAlignment(.center)
  15. Text(
  16. "Welcome to Trio - an automated insulin delivery system for iOS based on the OpenAPS algorithm with adaptations."
  17. )
  18. .multilineTextAlignment(.center)
  19. .foregroundColor(.secondary)
  20. Text(
  21. "Trio is designed to help manage your diabetes efficiently. To get the most out of the app, we'll guide you through setting up some essential parameters."
  22. )
  23. .multilineTextAlignment(.center)
  24. .foregroundColor(.secondary)
  25. Text("Let's go through a few quick steps to ensure Trio works optimally for you.")
  26. .multilineTextAlignment(.center)
  27. .foregroundColor(.primary)
  28. .bold()
  29. }
  30. .padding()
  31. .frame(maxWidth: .infinity)
  32. }
  33. }
  34. /// Completed step view shown at the end of onboarding.
  35. struct CompletedStepView: View {
  36. var body: some View {
  37. VStack(alignment: .center, spacing: 20) {
  38. Image(systemName: "checkmark.circle.fill")
  39. .font(.system(size: 80))
  40. .foregroundColor(.green)
  41. .padding()
  42. Text("You're All Set!")
  43. .font(.title)
  44. .fontWeight(.bold)
  45. .multilineTextAlignment(.center)
  46. Text(
  47. "You've successfully completed the initial setup of Trio. Your settings have been saved and you're ready to start using the app."
  48. )
  49. .multilineTextAlignment(.center)
  50. .foregroundColor(.secondary)
  51. VStack(alignment: .leading, spacing: 12) {
  52. ForEach(OnboardingStep.allCases.filter { $0 != .welcome && $0 != .completed }, id: \.self) { step in
  53. SettingItemView(step: step, icon: step.iconName, title: step.title)
  54. }
  55. }
  56. .padding()
  57. .background(Color.green.opacity(0.1))
  58. .cornerRadius(12)
  59. Text("Remember, you can adjust these settings at any time in the app settings if needed.")
  60. .font(.caption)
  61. .foregroundColor(.secondary)
  62. .multilineTextAlignment(.center)
  63. .padding(.top)
  64. }
  65. .padding()
  66. .frame(maxWidth: .infinity)
  67. }
  68. }
  69. /// A reusable view for displaying setting items in the completed step.
  70. struct SettingItemView: View {
  71. let step: OnboardingStep
  72. let icon: String
  73. let title: String
  74. var body: some View {
  75. HStack(spacing: 15) {
  76. if step == .nightscout {
  77. Image(icon)
  78. .resizable()
  79. .scaledToFit()
  80. .frame(width: 40, height: 24)
  81. .colorMultiply(Color.green)
  82. } else {
  83. Image(systemName: icon)
  84. .font(.system(size: 24))
  85. .foregroundColor(.green)
  86. .frame(width: 40)
  87. }
  88. VStack(alignment: .leading, spacing: 2) {
  89. Text(title)
  90. .font(.headline)
  91. }
  92. Spacer()
  93. Image(systemName: "checkmark")
  94. .foregroundColor(.green)
  95. }
  96. .padding(.vertical, 8)
  97. }
  98. }