automatic resetting of collections
This commit is contained in:
1 parent
913110be91
commit
60aa215d6b
3 files changed
+30
-3
No files matched your search
@@ -28,6 +28,23 @@ class PosterBoardManager: ObservableObject {
|
||||
return tendiesStoreURL
|
||||
}
|
||||
|
||||
func setSystemLanguage(to new_lang: String) -> Bool {
|
||||
var langManager: NSObject = NSObject()
|
||||
if #available(iOS 18.0, *) {
|
||||
guard let obj = objc_getClass("IPSettingsUtilities") as? NSObject else { return false }
|
||||
langManager = obj
|
||||
} else {
|
||||
guard let obj = objc_getClass("PSLanguageSelector") as? NSObject else { return false }
|
||||
langManager = obj
|
||||
}
|
||||
|
||||
if let success = langManager.perform(Selector(("setLanguage:")), with: new_lang) {
|
||||
return success != nil
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func openPosterBoard() -> Bool {
|
||||
guard let obj = objc_getClass("LSApplicationWorkspace") as? NSObject else { return false }
|
||||
let workspace = obj.perform(Selector(("defaultWorkspace")))?.takeUnretainedValue() as? NSObject
|
||||
|
||||
@@ -174,7 +174,17 @@ struct ContentView: View {
|
||||
.buttonStyle(TintedButton(color: .blue, fullwidth: true))
|
||||
}
|
||||
Button(action: {
|
||||
hideResetHelp = false
|
||||
guard let lang = UserDefaults.standard.stringArray(forKey: "AppleLanguages")?.first else {
|
||||
hideResetHelp = false // fallback to tutorial
|
||||
return
|
||||
}
|
||||
UIApplication.shared.confirmAlert(title: "Reset Collections", body: "Do you want to reset collections?", onOK: {
|
||||
if PosterBoardManager.shared.setSystemLanguage(to: lang) {
|
||||
UIApplication.shared.alert(title: "Collections Successfully Reset!", body: "Your PosterBoard will refresh automatically.")
|
||||
} else {
|
||||
UIApplication.shared.alert(body: "The API failed to call correctly.\nSystem Locale Code: \(lang)")
|
||||
}
|
||||
}, noCancel: false)
|
||||
}) {
|
||||
Text("Reset Collections")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user