Skip to content

Commit efe9855

Browse files
Copilotbgoncal
andauthored
Add confirmation dialog to gestures reset button (#4260)
## Summary Adds a confirmation dialog before resetting gesture settings to prevent accidental data loss. **Changes:** - Added `showResetConfirmation` state to manage dialog visibility - Modified reset button to trigger confirmation instead of immediate reset - Added `confirmationDialog` modifier applied directly to the button with Yes/No action buttons - Added localization strings: `gestures.reset.confirmation.title` and `gestures.reset.confirmation.message` Implementation follows existing patterns from `WatchConfigurationView` and `CarPlayConfigurationView`. ## Screenshots ## Link to pull request in Documentation repository Documentation: home-assistant/companion.home-assistant# ## Any other notes N/A <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > In GesturesView add a confirmation dialog to the reset button </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/home-assistant/iOS/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
1 parent 9c1e91e commit efe9855

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Sources/App/Resources/en.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@
303303
"gestures.category.page" = "Navigation";
304304
"gestures.category.servers" = "Servers";
305305
"gestures.footer.title" = "Customize gestures to be used on the frontend.";
306+
"gestures.reset.confirmation.message" = "This will reset all gestures to their default values.";
307+
"gestures.reset.confirmation.title" = "Reset Gestures?";
306308
"gestures.reset.title" = "Reset";
307309
"gestures.screen.body" = "Gestures below will be applied whenever you are using Home Assistant main UI.";
308310
"gestures.screen.title" = "Gestures";

Sources/App/Settings/Gestures/GesturesSetupView.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SwiftUI
44
struct GesturesSetupView: View {
55
@StateObject private var viewModel = GesturesSetupViewModel()
66
@State private var swipeRightState = HAGestureAction.showSidebar
7+
@State private var showResetConfirmation = false
78

89
@State var directions: [UISwipeGestureRecognizer.Direction] = [
910
.left, .right, .up,
@@ -66,10 +67,22 @@ struct GesturesSetupView: View {
6667
.toolbar {
6768
ToolbarItem(placement: .topBarTrailing) {
6869
Button(role: .destructive) {
69-
viewModel.resetGestures()
70+
showResetConfirmation = true
7071
} label: {
7172
Text(L10n.Gestures.Reset.title)
7273
}
74+
.confirmationDialog(
75+
L10n.Gestures.Reset.Confirmation.title,
76+
isPresented: $showResetConfirmation,
77+
titleVisibility: .visible
78+
) {
79+
Button(L10n.yesLabel, role: .destructive) {
80+
viewModel.resetGestures()
81+
}
82+
Button(L10n.noLabel, role: .cancel) {}
83+
} message: {
84+
Text(L10n.Gestures.Reset.Confirmation.message)
85+
}
7386
}
7487
}
7588
}

Sources/Shared/Resources/Swiftgen/Strings.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,12 @@ public enum L10n {
13381338
public enum Reset {
13391339
/// Reset
13401340
public static var title: String { return L10n.tr("Localizable", "gestures.reset.title") }
1341+
public enum Confirmation {
1342+
/// This will reset all gestures to their default values.
1343+
public static var message: String { return L10n.tr("Localizable", "gestures.reset.confirmation.message") }
1344+
/// Reset Gestures?
1345+
public static var title: String { return L10n.tr("Localizable", "gestures.reset.confirmation.title") }
1346+
}
13411347
}
13421348
public enum Screen {
13431349
/// Gestures below will be applied whenever you are using Home Assistant main UI.

0 commit comments

Comments
 (0)