OnboardingStepViews.swift 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. Text("You're All Set!")
  42. .font(.title)
  43. .fontWeight(.bold)
  44. .multilineTextAlignment(.center)
  45. Text(
  46. "You've successfully completed the initial setup of Trio. Tap 'Get Started' to save your settings and get ready to start using Trio."
  47. )
  48. .multilineTextAlignment(.center)
  49. .foregroundColor(.secondary)
  50. VStack(alignment: .leading, spacing: 12) {
  51. ForEach(OnboardingStep.allCases.filter { $0 != .welcome && $0 != .completed }, id: \.self) { step in
  52. SettingItemView(step: step, icon: step.iconName, title: step.title)
  53. }
  54. }
  55. .padding()
  56. .background(Color.green.opacity(0.1))
  57. .cornerRadius(12)
  58. Text("Remember, you can adjust these settings at any time in the app settings if needed.")
  59. .font(.caption)
  60. .foregroundColor(.secondary)
  61. .multilineTextAlignment(.center)
  62. .padding(.top)
  63. }
  64. .padding()
  65. .frame(maxWidth: .infinity)
  66. }
  67. }
  68. /// A reusable view for displaying setting items in the completed step.
  69. struct SettingItemView: View {
  70. let step: OnboardingStep
  71. let icon: String
  72. let title: String
  73. var body: some View {
  74. HStack(spacing: 15) {
  75. if step == .nightscout {
  76. Image(icon)
  77. .resizable()
  78. .scaledToFit()
  79. .frame(width: 40, height: 24)
  80. .colorMultiply(Color.green)
  81. } else {
  82. Image(systemName: icon)
  83. .font(.system(size: 24))
  84. .foregroundColor(.green)
  85. .frame(width: 40)
  86. }
  87. VStack(alignment: .leading, spacing: 2) {
  88. Text(title)
  89. .font(.headline)
  90. }
  91. Spacer()
  92. Image(systemName: "checkmark")
  93. .foregroundColor(.green)
  94. }
  95. .padding(.vertical, 8)
  96. }
  97. }