diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/Contents.json b/Pocket Poster/Assets.xcassets/ResetCollections/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Pocket Poster/Assets.xcassets/ResetCollections/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/CustomCollection.imageset/Contents.json b/Pocket Poster/Assets.xcassets/ResetCollections/CustomCollection.imageset/Contents.json new file mode 100644 index 0000000..b7b317c --- /dev/null +++ b/Pocket Poster/Assets.xcassets/ResetCollections/CustomCollection.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "CustomCollections.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/CustomCollection.imageset/CustomCollections.png b/Pocket Poster/Assets.xcassets/ResetCollections/CustomCollection.imageset/CustomCollections.png new file mode 100644 index 0000000..e9fc9f7 Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/CustomCollection.imageset/CustomCollections.png differ diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Contents.json b/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Contents.json new file mode 100644 index 0000000..1bbfba6 --- /dev/null +++ b/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Contents.json @@ -0,0 +1,52 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Language-light.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "Language_dark.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Language-light.png b/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Language-light.png new file mode 100644 index 0000000..b83901e Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Language-light.png differ diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Language_dark.png b/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Language_dark.png new file mode 100644 index 0000000..dd731b7 Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/Language.imageset/Language_dark.png differ diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/Contents.json b/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/Contents.json new file mode 100644 index 0000000..4c7a4d2 --- /dev/null +++ b/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/Contents.json @@ -0,0 +1,52 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "OriginalCollection-light.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "OriginalCollection-dark.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/OriginalCollection-dark.png b/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/OriginalCollection-dark.png new file mode 100644 index 0000000..318b794 Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/OriginalCollection-dark.png differ diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/OriginalCollection-light.png b/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/OriginalCollection-light.png new file mode 100644 index 0000000..1f25d2e Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/OriginalCollection.imageset/OriginalCollection-light.png differ diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/Contents.json b/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/Contents.json new file mode 100644 index 0000000..fca2bef --- /dev/null +++ b/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/Contents.json @@ -0,0 +1,52 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "SetPrimary-light.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "SetPrimary-dark.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/SetPrimary-dark.png b/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/SetPrimary-dark.png new file mode 100644 index 0000000..27c4170 Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/SetPrimary-dark.png differ diff --git a/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/SetPrimary-light.png b/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/SetPrimary-light.png new file mode 100644 index 0000000..c0c3fca Binary files /dev/null and b/Pocket Poster/Assets.xcassets/ResetCollections/SetPrimary.imageset/SetPrimary-light.png differ diff --git a/Pocket Poster/Pocket_PosterApp.swift b/Pocket Poster/Pocket_PosterApp.swift index f46598b..ef652ae 100644 --- a/Pocket Poster/Pocket_PosterApp.swift +++ b/Pocket Poster/Pocket_PosterApp.swift @@ -24,7 +24,7 @@ struct Pocket_PosterApp: App { if finishedTutorial { ContentView(selectedTendies: $selectedTendies) } else { - OnBoardingView() + OnBoardingView(cards: onBoardingCards, isFinished: $finishedTutorial) } } .transition(.opacity) diff --git a/Pocket Poster/Views/ContentView.swift b/Pocket Poster/Views/ContentView.swift index 8a4f2e3..23e1016 100644 --- a/Pocket Poster/Views/ContentView.swift +++ b/Pocket Poster/Views/ContentView.swift @@ -26,6 +26,7 @@ struct ContentView: View { @State var showErrorAlert = false @State var showSuccessAlert = false @State var lastError: String? + @State var hideResetHelp: Bool = true var body: some View { NavigationStack { @@ -45,7 +46,7 @@ struct ContentView: View { Text("Select Tendies") } .buttonStyle(TintedButton(color: .green, fullwidth: true)) - .padding(10) + .padding(.vertical, 10) if !selectedTendies.wrappedValue.isEmpty { HStack { @@ -64,36 +65,41 @@ struct ContentView: View { } Section { - if !selectedTendies.wrappedValue.isEmpty { - if pbHash == "" { - Text("Enter your PosterBoard app hash in Settings.") - } else { + if pbHash == "" { + Text("Enter your PosterBoard app hash in Settings.") + } else { + if !selectedTendies.wrappedValue.isEmpty { Button(action: { UIImpactFeedbackGenerator(style: .soft).impactOccurred() -// UIApplication.shared.alert(title: NSLocalizedString("Applying Tendies...", comment: ""), body: NSLocalizedString("Please wait", comment: ""), animated: false, withButton: false) + // UIApplication.shared.alert(title: NSLocalizedString("Applying Tendies...", comment: ""), body: NSLocalizedString("Please wait", comment: ""), animated: false, withButton: false) -// DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - do { - try PosterBoardManager.applyTendies(selectedTendies.wrappedValue, appHash: pbHash) - selectedTendies.wrappedValue.removeAll() - try? FileManager.default.removeItem(at: PosterBoardManager.getTendiesStoreURL()) - Haptic.shared.notify(.success) -// UIApplication.shared.dismissAlert(animated: true) - // TODO: Clear downloaded tendies - lastError = "The PosterBoard app will now open. Please close it from the app switcher." - showSuccessAlert.toggle() - } catch { - Haptic.shared.notify(.error) -// UIApplication.shared.dismissAlert(animated: true) - lastError = error.localizedDescription - showErrorAlert.toggle() - } -// } + // DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + do { + try PosterBoardManager.applyTendies(selectedTendies.wrappedValue, appHash: pbHash) + selectedTendies.wrappedValue.removeAll() + try? FileManager.default.removeItem(at: PosterBoardManager.getTendiesStoreURL()) + Haptic.shared.notify(.success) + // UIApplication.shared.dismissAlert(animated: true) + lastError = "The PosterBoard app will now open. Please close it from the app switcher." + showSuccessAlert.toggle() + } catch { + Haptic.shared.notify(.error) + // UIApplication.shared.dismissAlert(animated: true) + lastError = error.localizedDescription + showErrorAlert.toggle() + } + // } }) { Text("Apply") } .buttonStyle(TintedButton(color: .blue, fullwidth: true)) } + Button(action: { + hideResetHelp = false + }) { + Text("Reset Collections") + } + .buttonStyle(TintedButton(color: .red, fullwidth: true)) } } } @@ -130,6 +136,12 @@ struct ContentView: View { } message: { Text(lastError ?? "???") } + .overlay { + OnBoardingView(cards: resetCollectionsInfo, isFinished: $hideResetHelp) + .opacity(hideResetHelp ? 0.0 : 1.0) + .transition(.opacity) + .animation(.easeOut(duration: 0.5), value: hideResetHelp) + } } func delete(at offsets: IndexSet) { diff --git a/Pocket Poster/Views/OnBoarding/OnBoardingCardButtons.swift b/Pocket Poster/Views/OnBoarding/OnBoardingCardButtons.swift index 4c87138..fddc940 100644 --- a/Pocket Poster/Views/OnBoarding/OnBoardingCardButtons.swift +++ b/Pocket Poster/Views/OnBoarding/OnBoardingCardButtons.swift @@ -8,7 +8,7 @@ import SwiftUI struct OnBoardingCardButtons: View { - @AppStorage("finishedTutorial") var finishedTutorial: Bool? + @Binding var isFinished: Bool @Binding var idx: Int @Binding var isAnimating: Bool @@ -74,7 +74,7 @@ struct OnBoardingCardButtons: View { func playFinishAnimation() { isAnimating = false DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: { - finishedTutorial = true + isFinished = true }) } } @@ -83,6 +83,7 @@ struct OnBoardingCardView: View { var info: OnBoardingPage var pageCount: Int @Binding var idx: Int + @Binding var isFinished: Bool @State private var isAnimating: Bool = false @State private var imgCornerRadius: CGFloat = 10.0 @@ -130,7 +131,7 @@ struct OnBoardingCardView: View { .accentColor(Color.white) } - OnBoardingCardButtons(idx: $idx, isAnimating: $isAnimating, showDismiss: idx == 0, showFinish: idx == pageCount-1) + OnBoardingCardButtons(isFinished: $isFinished, idx: $idx, isAnimating: $isAnimating, showDismiss: idx == 0, showFinish: idx == pageCount-1) } .opacity(isAnimating ? 1.0 : 0.0) .animation(.easeOut(duration: 0.5), value: isAnimating) diff --git a/Pocket Poster/Views/OnBoarding/OnBoardingPage.swift b/Pocket Poster/Views/OnBoarding/OnBoardingPage.swift index ecca52f..ccc62ed 100644 --- a/Pocket Poster/Views/OnBoarding/OnBoardingPage.swift +++ b/Pocket Poster/Views/OnBoarding/OnBoardingPage.swift @@ -55,3 +55,26 @@ let onBoardingCards: [OnBoardingPage] = [ linkName: "Find Wallpapers" ) ] + +let resetCollectionsInfo: [OnBoardingPage] = [ + .init( + title: "How to Reset Collections", + description: "Due to the way this exploit works, it cannot delete files.\n\nHere is a guide on how to do it manually.", + image: "CustomCollection" + ), + .init( + title: "Open the Language Settings", + description: "Inside the Settings app, navigate to General > Language & Region", + image: "Language" + ), + .init( + title: "Set the Primary Language", + description: "It doesn't matter what you set it to.\n\nAfterwards set it back to your native language.", + image: "SetPrimary" + ), + .init( + title: "Verify That It Worked", + description: "Everything on PosterBoard should refresh. Check the Collections to see if they reset.", + image: "OriginalCollection" + ) +] diff --git a/Pocket Poster/Views/OnBoarding/OnBoardingView.swift b/Pocket Poster/Views/OnBoarding/OnBoardingView.swift index f03306c..4d7c6e8 100644 --- a/Pocket Poster/Views/OnBoarding/OnBoardingView.swift +++ b/Pocket Poster/Views/OnBoarding/OnBoardingView.swift @@ -8,11 +8,14 @@ import SwiftUI struct OnBoardingView: View { + let cards: [OnBoardingPage] + + @Binding var isFinished: Bool @State var currentIndex: Int = 0 var body: some View { VStack { - OnBoardingCardView(info: onBoardingCards[currentIndex], pageCount: onBoardingCards.count, idx: $currentIndex) + OnBoardingCardView(info: cards[currentIndex], pageCount: cards.count, idx: $currentIndex, isFinished: $isFinished) } } }