-
Views are important because each of you define individually images or pieces of text are views to the horizontal or vertical scrolling containers
-
They can be composed together to form more complex user interfaces.
- Views form the content of scenes allowing them to be independently displayed by their platform. Those scenes can also be composed together to form more complex scenes.
- The Window Group scene manages the views though that are onboarding View render into. It can also create additional windows within the same window
- It needs to store its state value using a permanent storage on the device fot this functionality. To use wrapper @AppStorage to store state data even closing application.
// FruitsDic-App
import SwiftUI
@main
struct FruitsDic_AppApp: App {
// MARK: - APPStorage
@AppStorage("isOnboarding") var isOnoarding: Bool = true
var body: some Scene {
WindowGroup {
if isOnoarding {
OnboardingView()
} else {
ContentView()
}
}
}
}
// StartButtonView.swift
import SwiftUI
struct StartButtonView: View {
// MARK: - PROPERTY
// isOnboarding 을 optional 로 받아야 함
@AppStorage("isOnboarding") var isOnboarding: Bool?
// MARK: - BODY
var body: some View {
Button(action: {
// false 로 바꾸게 되면 @main 에서 설정한 대로 ContentView 로 이동
isOnboarding = true
}) {