Skip to content

Commit

Permalink
hide the save confirmation popup
Browse files Browse the repository at this point in the history
  • Loading branch information
leminlimez committed Dec 21, 2023
1 parent 822ad1d commit b8c7339
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/views/navigation/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct SettingsView: View {
// Preference Variables
@State var updateInterval: Double = 1.0
@State var usesRotation: Bool = false
@State var hideSaveConfirmation: Bool = false

let formatter: NumberFormatter = {
let formatter = NumberFormatter()
Expand Down Expand Up @@ -82,7 +83,7 @@ struct SettingsView: View {

HStack {
Toggle(isOn: $usesRotation) {
Text("Hide On Rotation")
Text("Hide when Rotating")
.bold()
.minimumScaleFactor(0.5)
}
Expand All @@ -94,6 +95,20 @@ struct SettingsView: View {
}
}

HStack {
Toggle(isOn: $hideSaveConfirmation) {
Text("Hide Save Confirmation Popup")
.bold()
.minimumScaleFactor(0.5)
}
.onChange(of: hideSaveConfirmation) { _ in
UserDefaults.standard.setValue(hideSaveConfirmation, forKey: "hideSaveConfirmation", forPath: USER_DEFAULTS_PATH)
}
.onAppear {
hideSaveConfirmation = UserDefaults.standard.bool(forKey: "hideSaveConfirmation", forPath: USER_DEFAULTS_PATH)
}
}

HStack {
Text("Helium Data")
.bold()
Expand Down
8 changes: 6 additions & 2 deletions src/views/widgetset/EditWidgetSetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,13 @@ struct EditWidgetSetView: View {
}
.onDisappear {
if changesMade {
UIApplication.shared.confirmAlert(title: "Save Changes", body: "Would you like to save the changes to your current widget set?", onOK: {
if UserDefaults.standard.bool(forKey: "hideSaveConfirmation", forPath: USER_DEFAULTS_PATH) {
saveSet()
}, noCancel: false)
} else {
UIApplication.shared.confirmAlert(title: "Save Changes", body: "Would you like to save the changes to your current widget set?", onOK: {
saveSet()
}, noCancel: false)
}
}
}
.sheet(isPresented: $showingAddView, content: {
Expand Down

0 comments on commit b8c7339

Please sign in to comment.