From f6252c3a8b8453aa1e7831d62c944f35134baa36 Mon Sep 17 00:00:00 2001 From: Fabian Thies Date: Sat, 20 May 2023 19:10:51 +0200 Subject: [PATCH] Fix trusted sources being enabled in onboarding process regardless of user choice --- .../Views/Onboarding/OnboardingStepView.swift | 48 ------------------- .../Views/Onboarding/OnboardingView.swift | 18 ++++--- 2 files changed, 12 insertions(+), 54 deletions(-) diff --git a/AltStore/Views/Onboarding/OnboardingStepView.swift b/AltStore/Views/Onboarding/OnboardingStepView.swift index 06b94018..c9000762 100644 --- a/AltStore/Views/Onboarding/OnboardingStepView.swift +++ b/AltStore/Views/Onboarding/OnboardingStepView.swift @@ -84,54 +84,6 @@ struct OnboardingStepView_Previews: PreviewProvider { } .buttonStyle(FilledButtonStyle()) }) - - OnboardingStepView(title: { - VStack(alignment: .leading) { - Text("Pair your Device") - } - }, hero: { - Image(systemSymbol: .link) - .resizable() - .aspectRatio(contentMode: .fit) - .foregroundColor(.accentColor) - .shadow(color: .accentColor.opacity(0.8), radius: 12) - }, content: { - VStack { - Text("Before you can start sideloading apps, there is some setup to do.") - Text("The following setup will guide you through the steps one by one.") - } - }, action: { - SwiftUI.Button("Continue") { - - } - .buttonStyle(FilledButtonStyle()) - }) - - OnboardingStepView(title: { - VStack(alignment: .leading) { - Text("Download WireGuard") - } - }, hero: { - Image(systemSymbol: .icloudAndArrowDown) - .resizable() - .aspectRatio(contentMode: .fit) - .foregroundColor(.accentColor) - .shadow(color: .accentColor.opacity(0.8), radius: 12) - }, content: { - VStack { - Text("Before you can start sideloading apps, there is some setup to do.") - Text("The following setup will guide you through the steps one by one.") - } - }, action: { - SwiftUI.Button("Show in App Store") { - - } - .buttonStyle(FilledButtonStyle()) - - AppStoreView(isVisible: self.$isWireGuardAppStorePageVisible, itunesItemId: 1441195209) - .frame(width: .zero, height: .zero) - }) - } } diff --git a/AltStore/Views/Onboarding/OnboardingView.swift b/AltStore/Views/Onboarding/OnboardingView.swift index e55b7d94..b67dedfe 100644 --- a/AltStore/Views/Onboarding/OnboardingView.swift +++ b/AltStore/Views/Onboarding/OnboardingView.swift @@ -15,7 +15,7 @@ import UniformTypeIdentifiers struct OnboardingView: View { - enum OnboardingStep: Int { + enum OnboardingStep: Int, CaseIterable { case welcome, pairing, wireguard, wireguardConfig, addSources, finish } @@ -374,6 +374,10 @@ extension OnboardingView { extension OnboardingView { func setupTrustedSources() { + guard self.areTrustedSourcesEnabled else { + return self.showNextStep() + } + self.isLoadingTrustedSources = true AppManager.shared.fetchTrustedSources { result in @@ -435,10 +439,12 @@ extension OnboardingView { struct OnboardingView_Previews: PreviewProvider { static var previews: some View { - Color.red - .ignoresSafeArea() - .sheet(isPresented: .constant(true)) { - OnboardingView() - } + ForEach(OnboardingView.OnboardingStep.allCases, id: \.self) { step in + Color.red + .ignoresSafeArea() + .sheet(isPresented: .constant(true)) { + OnboardingView(currentStep: step) + } + } } }