79 lines
2.4 KiB
Swift
79 lines
2.4 KiB
Swift
//
|
|
// OnboardingView.swift
|
|
// Bunch O' Dice
|
|
//
|
|
// Created by Rory Hinnen on 22/6/11.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct OnboardingView: View {
|
|
private let courses = DTCourse.pages
|
|
@State private var selection = 0
|
|
@EnvironmentObject var current: Roll
|
|
|
|
var body: some View {
|
|
VStack {
|
|
TabView(selection: $selection) {
|
|
ForEach(courses.indices, id: \.self) { idx in
|
|
VStack(spacing: 0) {
|
|
Spacer()
|
|
Text(courses[idx].title)
|
|
.font(.largeTitle)
|
|
Rectangle()
|
|
.fill(Color.secondary)
|
|
.frame(height: 1)
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Image(courses[idx].imageName)
|
|
.resizable()
|
|
.scaledToFit()
|
|
|
|
Text(courses[idx].subtitle)
|
|
|
|
Text(courses[idx].desc)
|
|
.foregroundColor(.secondary)
|
|
|
|
}.padding()
|
|
|
|
Spacer()
|
|
}
|
|
.tag(idx)
|
|
}
|
|
}
|
|
.tabViewStyle(.page(indexDisplayMode: .never))
|
|
HStack {
|
|
Spacer()
|
|
Button {
|
|
withAnimation {
|
|
if selection < courses.count - 1 {
|
|
selection += 1
|
|
} else {
|
|
current.currentPage = "Bunch"
|
|
}
|
|
}
|
|
} label: {
|
|
if selection == courses.count - 1 {
|
|
Image(systemName: "checkmark.circle")
|
|
.font(.largeTitle)
|
|
} else {
|
|
Image(systemName: "chevron.right.circle")
|
|
.font(.largeTitle)
|
|
}
|
|
}
|
|
}
|
|
.padding()
|
|
.foregroundColor(.primary)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
struct OnboardingView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
OnboardingView()
|
|
.environmentObject(Roll())
|
|
}
|
|
}
|