OverviewStepView.swift 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // OverviewStepView.swift
  3. // Trio
  4. //
  5. // Created by Cengiz Deniz on 06.04.25.
  6. //
  7. import SwiftUI
  8. struct OverviewStepView: View {
  9. var body: some View {
  10. VStack(alignment: .leading, spacing: 20) {
  11. Text("Here is an overview of what to expect:")
  12. .font(.headline)
  13. .padding(.horizontal)
  14. VStack(alignment: .center, spacing: 12) {
  15. ForEach(Array(OnboardingChapter.allCases.enumerated()), id: \.element.id) { index, chapter in
  16. overviewItem(
  17. stepIndex: index + 1,
  18. title: chapter.title,
  19. duration: chapter.duration,
  20. description: chapter.overviewDescription
  21. )
  22. if index < OnboardingChapter.allCases.count {
  23. Divider()
  24. }
  25. }
  26. }
  27. .padding()
  28. .background(Color.chart.opacity(0.65))
  29. .cornerRadius(10)
  30. }
  31. }
  32. @ViewBuilder private func overviewItem(
  33. stepIndex: Int,
  34. title: String,
  35. duration: String,
  36. description: String
  37. ) -> some View {
  38. VStack(alignment: .leading) {
  39. HStack {
  40. HStack(spacing: 14) {
  41. stepCount(stepIndex)
  42. Text(title).font(.headline)
  43. }
  44. Spacer()
  45. Text("\(duration) \(String(localized: "min"))")
  46. .font(.subheadline)
  47. }
  48. Text(description)
  49. .font(.footnote)
  50. .foregroundStyle(Color.secondary)
  51. .padding(.vertical, 8)
  52. .multilineTextAlignment(.leading)
  53. }
  54. }
  55. @ViewBuilder private func stepCount(_ count: Int) -> some View {
  56. Text(count.description)
  57. .font(.subheadline.bold())
  58. .frame(width: 26, height: 26, alignment: .center)
  59. .background(Color.blue)
  60. .foregroundStyle(.white)
  61. .clipShape(Capsule())
  62. }
  63. }