Skip to content

Commit 61e4905

Browse files
authored
Add haptic feedback to todo list widget buttons (home-assistant#4355)
1 parent 76238c3 commit 61e4905

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Sources/Extensions/Widgets/TodoList/TodoItemCompleteAppIntent.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,27 @@ struct TodoItemCompleteAppIntent: AppIntent {
1717
@Parameter(title: "widgets.todo_list.parameter.item_id")
1818
var itemId: String
1919

20+
@Parameter(
21+
title: LocalizedStringResource(
22+
"app_intents.haptic_confirmation.title",
23+
defaultValue: "Haptic confirmation"
24+
),
25+
default: true
26+
)
27+
var hapticConfirmation: Bool
28+
2029
init() {
2130
self.serverId = ""
2231
self.listId = ""
2332
self.itemId = ""
33+
self.hapticConfirmation = true
2434
}
2535

2636
init(serverId: String, listId: String, itemId: String) {
2737
self.serverId = serverId
2838
self.listId = listId
2939
self.itemId = itemId
40+
self.hapticConfirmation = true
3041
}
3142

3243
func perform() async throws -> some IntentResult {
@@ -36,6 +47,10 @@ struct TodoItemCompleteAppIntent: AppIntent {
3647
return .result()
3748
}
3849

50+
if hapticConfirmation {
51+
AppIntentHaptics.notify()
52+
}
53+
3954
await withCheckedContinuation { continuation in
4055
connection.send(.completeTodoItem(listId: listId, itemId: itemId)).promise.pipe { result in
4156
switch result {

Sources/Extensions/Widgets/TodoList/TodoListRefreshAppIntent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ struct TodoListRefreshAppIntent: AppIntent {
99
static var isDiscoverable: Bool = false
1010

1111
func perform() async throws -> some IntentResult {
12+
AppIntentHaptics.notify()
1213
WidgetCenter.shared.reloadTimelines(ofKind: WidgetsKind.todoList.rawValue)
1314
return .result()
1415
}

0 commit comments

Comments
 (0)