iOS/Sources/Extensions/Widgets/Scene/Control/ControlScene.swift
Bruno Pantaleão Gonçalves 4f2f2e4195
Fix control scene id when calling to activate scene (#3007)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2024-09-16 23:43:31 +00:00

35 lines
1.4 KiB
Swift

import Foundation
import Shared
import SwiftUI
import WidgetKit
@available(iOS 18, *)
struct ControlScene: ControlWidget {
var body: some ControlWidgetConfiguration {
AppIntentControlConfiguration(
kind: WidgetsKind.controlScene.rawValue,
provider: ControlScenesValueProvider()
) { template in
ControlWidgetButton(action: {
let intent = SceneAppIntent()
intent.scene = .init(
id: template.intentSceneEntity.id,
entityId: template.intentSceneEntity.entityId,
serverId: template.intentSceneEntity.serverId,
serverName: template.intentSceneEntity.serverName,
displayString: template.intentSceneEntity.displayString,
iconName: template.icon.id
)
intent.showConfirmationNotification = template.showConfirmationNotification
return intent
}()) {
// ControlWidget can only display SF Symbol
Label(template.intentSceneEntity.displayString, systemImage: template.icon.id)
}
.tint(.init(uiColor: Asset.Colors.haPrimary.color))
}
.displayName(.init(stringLiteral: L10n.Widgets.Controls.Scene.displayName))
.description(.init(stringLiteral: L10n.Widgets.Controls.Scene.description))
}
}