From ffdf68f2e0176a5b76f3eaba092b6ee03ceaaf68 Mon Sep 17 00:00:00 2001 From: zaehorang Date: Wed, 5 Jun 2024 16:02:54 +0900 Subject: [PATCH] feat: Migrate onboarding view from UserDefaults to AppStorage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - showcase를 위해 온보딩을 계속헤서 띄우게 했던 코드를 수정 - Userdefault로 작성되어 있던 코드를 AppStorage로 변경 --- MinGenie/MinGenie/ContentView.swift | 4 ++-- .../MinGenie/OnboardingViews/OnboardingLastPageView.swift | 3 ++- MinGenie/MinGenie/OnboardingViews/OnboardingTabView.swift | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/MinGenie/MinGenie/ContentView.swift b/MinGenie/MinGenie/ContentView.swift index 6ab8dbc..fb2bce0 100644 --- a/MinGenie/MinGenie/ContentView.swift +++ b/MinGenie/MinGenie/ContentView.swift @@ -12,10 +12,10 @@ import SwiftUI struct ContentView: View { @Environment(\.scenePhase) var phase - @StateObject private var shakeDetectionModel = ShakeDetectionModel() + @StateObject var shakeDetectionModel = ShakeDetectionModel() @StateObject var musicPlayerModel = MusicPlayerModel.shared - @State private var hasSeenOnboarding: Bool = false + @AppStorage("Onboarding") var hasSeenOnboarding = false var body: some View { if hasSeenOnboarding { diff --git a/MinGenie/MinGenie/OnboardingViews/OnboardingLastPageView.swift b/MinGenie/MinGenie/OnboardingViews/OnboardingLastPageView.swift index 5834877..ea3945d 100644 --- a/MinGenie/MinGenie/OnboardingViews/OnboardingLastPageView.swift +++ b/MinGenie/MinGenie/OnboardingViews/OnboardingLastPageView.swift @@ -8,9 +8,10 @@ import SwiftUI struct OnboardingLastPageView: View { + @Binding var hasSeenOnboarding: Bool + let title: String let imageName: String - @Binding var hasSeenOnboarding: Bool var body: some View { ZStack { diff --git a/MinGenie/MinGenie/OnboardingViews/OnboardingTabView.swift b/MinGenie/MinGenie/OnboardingViews/OnboardingTabView.swift index e6f7746..0be77cf 100644 --- a/MinGenie/MinGenie/OnboardingViews/OnboardingTabView.swift +++ b/MinGenie/MinGenie/OnboardingViews/OnboardingTabView.swift @@ -60,9 +60,9 @@ struct OnboardingTabView: View { ) } else if currentPage == 6 { OnboardingLastPageView( + hasSeenOnboarding: $hasSeenOnboarding, title: "음악과 함께\n일할 준비가 되셨나요?", - imageName: "headphone", - hasSeenOnboarding: $hasSeenOnboarding + imageName: "headphone" ) } }