button to clear app cached files
This commit is contained in:
1 parent
67c3fdb36a
commit
7c0cb386a7
2 files changed
+32
No files matched your search
@@ -11,6 +11,10 @@ struct SettingsView: View {
|
||||
// Prefs
|
||||
@AppStorage("pbHash") var pbHash: String = ""
|
||||
|
||||
@State var showErrorAlert = false
|
||||
@State var errorAlertTitle: String?
|
||||
@State var errorAlertDescr: String?
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
Section {
|
||||
@@ -33,8 +37,29 @@ struct SettingsView: View {
|
||||
Text("Replay Tutorial")
|
||||
}
|
||||
.buttonStyle(TintedButton(color: .blue, fullwidth: true))
|
||||
|
||||
Button(action: {
|
||||
do {
|
||||
try PosterBoardManager.clearCache()
|
||||
errorAlertTitle = "App Cache Successfully Cleared!"
|
||||
errorAlertDescr = ""
|
||||
showErrorAlert = true
|
||||
} catch {
|
||||
errorAlertTitle = "Error"
|
||||
errorAlertDescr = error.localizedDescription
|
||||
showErrorAlert = true
|
||||
}
|
||||
}) {
|
||||
Text("Clear App Cache")
|
||||
}
|
||||
.buttonStyle(TintedButton(color: .red, fullwidth: true))
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.alert(errorAlertTitle ?? "Error", isPresented: $showErrorAlert) {
|
||||
Button("OK") {}
|
||||
} message: {
|
||||
Text(errorAlertDescr ?? "???")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user