Fix trusted sources being enabled in onboarding process regardless of user choice

This commit is contained in:
Fabian Thies
2023-05-20 19:10:51 +02:00
parent 653d80b88e
commit f6252c3a8b
2 changed files with 12 additions and 54 deletions

View File

@@ -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)
})
}
}

View File

@@ -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)
}
}
}
}