create singleton for PBManager
This commit is contained in:
1 parent
eb280c5ecb
commit
35e58b88eb
4 files changed
+33
-33
No files matched your search
@@ -13,8 +13,6 @@ struct Pocket_PosterApp: App {
|
||||
@AppStorage("finishedTutorial") var finishedTutorial: Bool = false
|
||||
@AppStorage("pbHash") var pbHash: String = ""
|
||||
|
||||
@State var selectedTendies: [URL] = []
|
||||
|
||||
@State var downloadURL: String? = nil
|
||||
@State var showDownloadAlert = false
|
||||
|
||||
@@ -22,7 +20,7 @@ struct Pocket_PosterApp: App {
|
||||
WindowGroup {
|
||||
Group {
|
||||
if finishedTutorial {
|
||||
ContentView(selectedTendies: $selectedTendies)
|
||||
ContentView()
|
||||
} else {
|
||||
OnBoardingView(cards: onBoardingCards, isFinished: $finishedTutorial)
|
||||
}
|
||||
@@ -43,7 +41,7 @@ struct Pocket_PosterApp: App {
|
||||
// prohibit to only tendies files
|
||||
if !url.absoluteString.hasSuffix(".tendies") {
|
||||
UIApplication.shared.alert(body: "Only .tendies files can be downloaded!")
|
||||
} else if selectedTendies.count >= PosterBoardManager.MaxTendies {
|
||||
} else if PosterBoardManager.shared.selectedTendies.count >= PosterBoardManager.MaxTendies {
|
||||
UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
|
||||
} else {
|
||||
downloadURL = url.absoluteString.replacingOccurrences(of: "pocketposter://download?url=", with: "")
|
||||
@@ -55,13 +53,13 @@ struct Pocket_PosterApp: App {
|
||||
pbHash = url.absoluteString.replacingOccurrences(of: "pocketposter://app-hash?uuid=", with: "")
|
||||
}
|
||||
else if url.pathExtension == "tendies" {
|
||||
if selectedTendies.count >= PosterBoardManager.MaxTendies {
|
||||
if PosterBoardManager.shared.selectedTendies.count >= PosterBoardManager.MaxTendies {
|
||||
UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
|
||||
} else {
|
||||
// copy it over to the KFC bucket
|
||||
do {
|
||||
let newURL = try DownloadManager.copyTendies(from: url)
|
||||
selectedTendies.append(newURL)
|
||||
PosterBoardManager.shared.selectedTendies.append(newURL)
|
||||
Haptic.shared.notify(.success)
|
||||
UIApplication.shared.alert(title: "Successfully imported \(url.lastPathComponent)", body: "")
|
||||
} catch {
|
||||
@@ -81,7 +79,7 @@ struct Pocket_PosterApp: App {
|
||||
Task {
|
||||
do {
|
||||
let newURL = try await DownloadManager.downloadFromURL(string: downloadURL!)
|
||||
selectedTendies.append(newURL)
|
||||
PosterBoardManager.shared.selectedTendies.append(newURL)
|
||||
Haptic.shared.notify(.success)
|
||||
UIApplication.shared.dismissAlert(animated: true)
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user