Files
iOS/Sources/Extensions/Widgets/OpenPage/Control/ControlOpenPage.swift
Bruno Pantaleão Gonçalves 034e683f39 Add iOS 18 Open Page Control (#2975)
<!-- 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. -->
![CleanShot 2024-09-04 at 13 52
19@2x](https://github.com/user-attachments/assets/34905538-4c90-4f7c-8d47-41555554654f)

## 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-04 14:57:34 +02:00

26 lines
793 B
Swift

import AppIntents
import Foundation
import Shared
import SwiftUI
import WidgetKit
@available(iOS 18, *)
struct ControlOpenPage: ControlWidget {
var body: some ControlWidgetConfiguration {
AppIntentControlConfiguration(
kind: WidgetsKind.controlOpenPage.rawValue,
provider: ControlOpenPageValueProvider()
) { template in
ControlWidgetButton(action: {
let intent = OpenPageAppIntent()
intent.page = template.page
return intent
}()) {
// ControlWidget can only display SF Symbol
Label(template.page.panel.title, systemImage: template.icon.id)
}
}
.displayName(.init(stringLiteral: L10n.Widgets.OpenPage.title))
}
}