Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action widgets, open page widgets, and gauges on the Lock Screen #2830

Merged
merged 32 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f718b01
Move the accessoryCircular button to a separate file
literally-anything Jun 27, 2024
f3b50ee
Add accessoryCircular family to the actions widget
literally-anything Jun 27, 2024
aff4022
Add accessoryCircular family to the open page widget
literally-anything Jun 27, 2024
55c727a
Merge branch 'home-assistant:master' into master
literally-anything Jun 27, 2024
5952a2e
Merge branch 'home-assistant:master' into master
literally-anything Jun 27, 2024
de5ed06
Add base gauge widget
literally-anything Jun 29, 2024
996ab5d
Add localization for the gauge widget
literally-anything Jun 29, 2024
a76099b
Add a push notification to reload the gauge widget
literally-anything Jun 29, 2024
cb1366e
Use server name instead of remote name for the server picker
literally-anything Jun 30, 2024
4b32660
Fix log message
literally-anything Jun 30, 2024
41ab442
Add placeholders and the details widget
literally-anything Jun 30, 2024
15bcc7c
Chnage the gauge and details identifiers
literally-anything Jun 30, 2024
9b53238
Run linter
literally-anything Jul 1, 2024
017a77c
Reorder min and max in the gauge widget app intent
literally-anything Jul 1, 2024
5be18f6
Move widget families into enums
literally-anything Jul 1, 2024
e59dcaf
Add comments for transparent widget families variable
literally-anything Jul 1, 2024
9c5b944
Merge branch 'master' into master
literally-anything Jul 2, 2024
def26b4
Add a legacy notification command for reloading widgets and move type…
literally-anything Jul 2, 2024
19e12d1
Fix the gauge and details widget kind
literally-anything Jul 2, 2024
abd90c0
Lower the widget reload time interval
literally-anything Jul 2, 2024
fbeac49
Add strings for gauge and details widget parameters
literally-anything Jul 2, 2024
b1b5d8c
Move widget kinds to a shared enum
literally-anything Jul 2, 2024
f1d1ec6
Merge branch 'master' into master
literally-anything Jul 2, 2024
d32bd63
Localize the parameters in the widget app intents
literally-anything Jul 2, 2024
adbc065
Localize the strings in the GagueType app enum
literally-anything Jul 2, 2024
dc6ebf7
Add english as a default when no localizaion exists
literally-anything Jul 3, 2024
8ca7e45
Update Sources/PushServer/SharedPush/Sources/NotificationParserLegacy…
literally-anything Jul 3, 2024
09692fe
Use the enum for the name of the command
literally-anything Jul 3, 2024
5533735
Merge branch 'master' into master
literally-anything Jul 4, 2024
cc1ae8f
Merge branch 'master' into master
literally-anything Jul 5, 2024
831e7f2
Make update_widgets only availible on iOS
literally-anything Jul 5, 2024
7555425
Merge remote-tracking branch 'refs/remotes/origin/master'
literally-anything Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions HomeAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,19 @@
399792712B7F909900231B54 /* MobileAppConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399792702B7F909900231B54 /* MobileAppConfig.swift */; };
399792722B7F909900231B54 /* MobileAppConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399792702B7F909900231B54 /* MobileAppConfig.swift */; };
39A32EE22C0E384E00985722 /* UIImage+scaledToSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39A32EE12C0E384E00985722 /* UIImage+scaledToSize.swift */; };
4008F0262C2D0A1A00E24001 /* WidgetCircularView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4008F0252C2D0A1A00E24001 /* WidgetCircularView.swift */; };
403AE9092C2E220200D48147 /* WidgetGauge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE9082C2E220200D48147 /* WidgetGauge.swift */; };
403AE90E2C2E28B200D48147 /* WidgetGaugeAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE90B2C2E28B200D48147 /* WidgetGaugeAppIntent.swift */; };
403AE9102C2E28B200D48147 /* WidgetGaugeAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE90B2C2E28B200D48147 /* WidgetGaugeAppIntent.swift */; };
403AE9122C2E2BFC00D48147 /* WidgetGaugeAppIntentTimelineProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE9112C2E2BFC00D48147 /* WidgetGaugeAppIntentTimelineProvider.swift */; };
403AE9272C2F333A00D48147 /* WidgetGaugeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE9262C2F333A00D48147 /* WidgetGaugeView.swift */; };
403AE92A2C2F3A9200D48147 /* IntentServerAppEntitiy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE9292C2F3A9200D48147 /* IntentServerAppEntitiy.swift */; };
403AE92B2C2F3A9200D48147 /* IntentServerAppEntitiy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403AE9292C2F3A9200D48147 /* IntentServerAppEntitiy.swift */; };
4080D5BE2C319AA000099C88 /* WidgetDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4080D5BD2C319AA000099C88 /* WidgetDetailsView.swift */; };
4080D5BF2C319AA000099C88 /* WidgetDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4080D5BC2C319AA000099C88 /* WidgetDetails.swift */; };
4080D5C42C319B0A00099C88 /* WidgetDetailsAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4080D5C12C319B0A00099C88 /* WidgetDetailsAppIntent.swift */; };
4080D5C52C319B0A00099C88 /* WidgetDetailsAppIntentTimelineProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4080D5C22C319B0A00099C88 /* WidgetDetailsAppIntentTimelineProvider.swift */; };
4080D5C62C319B0A00099C88 /* WidgetDetailsAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4080D5C12C319B0A00099C88 /* WidgetDetailsAppIntent.swift */; };
42070EE82BAC43240031E96F /* AssistSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42070EE72BAC43240031E96F /* AssistSession.swift */; };
42070EEB2BAC517A0031E96F /* AssistInAppIntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42070EE92BAC49D70031E96F /* AssistInAppIntentHandler.swift */; };
42070EEC2BAC517A0031E96F /* AssistInAppIntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42070EE92BAC49D70031E96F /* AssistInAppIntentHandler.swift */; };
Expand Down Expand Up @@ -1636,6 +1649,16 @@
399792702B7F909900231B54 /* MobileAppConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileAppConfig.swift; sourceTree = "<group>"; };
39A32EE12C0E384E00985722 /* UIImage+scaledToSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+scaledToSize.swift"; sourceTree = "<group>"; };
3F4DFB087A3A43F9A526B851 /* Pods_iOS_Shared_iOS_Tests_Shared.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_Shared_iOS_Tests_Shared.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4008F0252C2D0A1A00E24001 /* WidgetCircularView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetCircularView.swift; sourceTree = "<group>"; };
403AE9082C2E220200D48147 /* WidgetGauge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetGauge.swift; sourceTree = "<group>"; };
403AE90B2C2E28B200D48147 /* WidgetGaugeAppIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WidgetGaugeAppIntent.swift; path = Sources/Extensions/AppIntents/Widget/Gauge/WidgetGaugeAppIntent.swift; sourceTree = SOURCE_ROOT; };
403AE9112C2E2BFC00D48147 /* WidgetGaugeAppIntentTimelineProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetGaugeAppIntentTimelineProvider.swift; sourceTree = "<group>"; };
403AE9262C2F333A00D48147 /* WidgetGaugeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetGaugeView.swift; sourceTree = "<group>"; };
403AE9292C2F3A9200D48147 /* IntentServerAppEntitiy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntentServerAppEntitiy.swift; sourceTree = "<group>"; };
4080D5BC2C319AA000099C88 /* WidgetDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDetails.swift; sourceTree = "<group>"; };
4080D5BD2C319AA000099C88 /* WidgetDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDetailsView.swift; sourceTree = "<group>"; };
4080D5C12C319B0A00099C88 /* WidgetDetailsAppIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WidgetDetailsAppIntent.swift; path = Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift; sourceTree = SOURCE_ROOT; };
4080D5C22C319B0A00099C88 /* WidgetDetailsAppIntentTimelineProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDetailsAppIntentTimelineProvider.swift; sourceTree = "<group>"; };
42070EE72BAC43240031E96F /* AssistSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssistSession.swift; sourceTree = "<group>"; };
42070EE92BAC49D70031E96F /* AssistInAppIntentHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssistInAppIntentHandler.swift; sourceTree = "<group>"; };
420B10032B1CF6D800D383D8 /* SharedAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = SharedAssets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2526,6 +2549,7 @@
115560E227010DAB00A8F818 /* WidgetBasicView.swift */,
424A7F452B188946008C8DF3 /* WidgetBackground.swift */,
424A7F472B188BF3008C8DF3 /* WidgetContentMargin.swift */,
4008F0252C2D0A1A00E24001 /* WidgetCircularView.swift */,
);
path = Common;
sourceTree = "<group>";
Expand Down Expand Up @@ -2648,6 +2672,8 @@
115560DF27010D6700A8F818 /* Common */,
110E693E24E770BD004AA96D /* Actions */,
115560EA27012ED000A8F818 /* OpenPage */,
403AE9072C2E214D00D48147 /* Gauge */,
4080D5BB2C319A9100099C88 /* Details */,
1171508324DFCF960065E874 /* Resources */,
1171506F24DFCDE60065E874 /* Widgets.swift */,
110E694524E771AB004AA96D /* Color+Hex.swift */,
Expand Down Expand Up @@ -3226,6 +3252,42 @@
path = WebView;
sourceTree = "<group>";
};
403AE9072C2E214D00D48147 /* Gauge */ = {
isa = PBXGroup;
children = (
403AE9082C2E220200D48147 /* WidgetGauge.swift */,
403AE9262C2F333A00D48147 /* WidgetGaugeView.swift */,
);
path = Gauge;
sourceTree = "<group>";
};
403AE90A2C2E28A200D48147 /* Gauge */ = {
isa = PBXGroup;
children = (
403AE90B2C2E28B200D48147 /* WidgetGaugeAppIntent.swift */,
403AE9112C2E2BFC00D48147 /* WidgetGaugeAppIntentTimelineProvider.swift */,
);
path = Gauge;
sourceTree = "<group>";
};
4080D5BB2C319A9100099C88 /* Details */ = {
isa = PBXGroup;
children = (
4080D5BC2C319AA000099C88 /* WidgetDetails.swift */,
4080D5BD2C319AA000099C88 /* WidgetDetailsView.swift */,
);
path = Details;
sourceTree = "<group>";
};
4080D5C02C319AF400099C88 /* Details */ = {
isa = PBXGroup;
children = (
4080D5C12C319B0A00099C88 /* WidgetDetailsAppIntent.swift */,
4080D5C22C319B0A00099C88 /* WidgetDetailsAppIntentTimelineProvider.swift */,
);
path = Details;
sourceTree = "<group>";
};
420FE8472B5569ED00878E06 /* Actions */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3350,6 +3412,7 @@
children = (
4296C3722B91F06D0051B63C /* Widget */,
4296C36B2B90DB630051B63C /* IntentActionAppEntity.swift */,
403AE9292C2F3A9200D48147 /* IntentServerAppEntitiy.swift */,
4296C36C2B90DB630051B63C /* PerformAction.swift */,
);
path = AppIntents;
Expand All @@ -3359,6 +3422,8 @@
isa = PBXGroup;
children = (
4296C3732B91F0730051B63C /* Actions */,
403AE90A2C2E28A200D48147 /* Gauge */,
4080D5C02C319AF400099C88 /* Details */,
);
path = Widget;
sourceTree = "<group>";
Expand Down Expand Up @@ -5936,14 +6001,24 @@
115560E327010DAB00A8F818 /* WidgetBasicView.swift in Sources */,
1171507024DFCDE60065E874 /* Widgets.swift in Sources */,
424A7F462B188946008C8DF3 /* WidgetBackground.swift in Sources */,
4008F0262C2D0A1A00E24001 /* WidgetCircularView.swift in Sources */,
42F958992BB4684700497981 /* WidgetAssist.swift in Sources */,
4080D5C52C319B0A00099C88 /* WidgetDetailsAppIntentTimelineProvider.swift in Sources */,
4080D5C62C319B0A00099C88 /* WidgetDetailsAppIntent.swift in Sources */,
4296C3772B91F26A0051B63C /* IntentActionAppEntity.swift in Sources */,
115560F227012FE100A8F818 /* WidgetOpenPageProvider.swift in Sources */,
403AE9102C2E28B200D48147 /* WidgetGaugeAppIntent.swift in Sources */,
1165705627018C4E003906A7 /* WidgetEmptyView.swift in Sources */,
1171508124DFCEC50065E874 /* WidgetActions.swift in Sources */,
403AE92B2C2F3A9200D48147 /* IntentServerAppEntitiy.swift in Sources */,
403AE9272C2F333A00D48147 /* WidgetGaugeView.swift in Sources */,
4296C3782B91F6260051B63C /* PerformAction.swift in Sources */,
4080D5BE2C319AA000099C88 /* WidgetDetailsView.swift in Sources */,
4080D5BF2C319AA000099C88 /* WidgetDetails.swift in Sources */,
4296C37B2B92054C0051B63C /* WidgetActionsAppIntent.swift in Sources */,
403AE9092C2E220200D48147 /* WidgetGauge.swift in Sources */,
42F9589F2BB4707F00497981 /* WidgetAssistView.swift in Sources */,
403AE9122C2E2BFC00D48147 /* WidgetGaugeAppIntentTimelineProvider.swift in Sources */,
42F9589C2BB4691D00497981 /* WidgetAssistProvider.swift in Sources */,
110E694624E771AB004AA96D /* Color+Hex.swift in Sources */,
);
Expand Down Expand Up @@ -5997,6 +6072,7 @@
buildActionMask = 2147483647;
files = (
115F9D7025F4B7B700CC6A45 /* TemplateSection.swift in Sources */,
403AE92A2C2F3A9200D48147 /* IntentServerAppEntitiy.swift in Sources */,
1101568524D770B2009424C9 /* NFCReader.swift in Sources */,
B648AE262275918F006972AF /* Scenes.swift in Sources */,
1185DF9A271FE60F00ED7D9A /* OnboardingAuthStep.swift in Sources */,
Expand Down Expand Up @@ -6086,6 +6162,7 @@
111858DF24CB83DF00B8CDDC /* Intents.intentdefinition in Sources */,
B64BB3A81E9C6551001E8B46 /* WebViewController.swift in Sources */,
42FCCFE22B9B1B610057783F /* BarcodeScannerCamera.swift in Sources */,
4080D5C42C319B0A00099C88 /* WidgetDetailsAppIntent.swift in Sources */,
11A71C7124A4648000D9565F /* ZoneManagerEquatableRegion.swift in Sources */,
42FCD0132B9B29740057783F /* ThreadCredentialsManagementViewModel.swift in Sources */,
11E99A5027156854003C8A65 /* OnboardingTerminalViewController.swift in Sources */,
Expand Down Expand Up @@ -6169,6 +6246,7 @@
42DD84162B14D7AC00936F16 /* WebViewExternalBusMessage.swift in Sources */,
11EFCDD324F5F39100314D85 /* WebViewWindowController.swift in Sources */,
11EFCDE024F60E5900314D85 /* BasicSceneDelegate.swift in Sources */,
403AE90E2C2E28B200D48147 /* WidgetGaugeAppIntent.swift in Sources */,
42FCCFFF2B9B1C310057783F /* ThreadCredentialsSharingView.swift in Sources */,
429106872BA9D22500D452F9 /* AudioRecorder.swift in Sources */,
425573C92B5572DB00145217 /* CarPlayServerListViewModel.swift in Sources */,
Expand Down
6 changes: 5 additions & 1 deletion Sources/App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -854,4 +854,8 @@ Home Assistant is free and open source home automation software with a focus on
"widgets.open_page.description" = "Open a frontend page in Home Assistant.";
"widgets.open_page.not_configured" = "No Pages Available";
"widgets.open_page.title" = "Open Page";
"yes_label" = "Yes";
"widgets.gauge.description" = "Display numeric states from Home Assistant in a gauge";
"widgets.gauge.title" = "Gauge";
"widgets.details.description" = "Display states using from Home Assistant in text";
"widgets.details.title" = "Details";
"yes_label" = "Yes";
60 changes: 60 additions & 0 deletions Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import AppIntents
import Foundation
import Shared

@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
struct IntentServerAppEntity: AppEntity, Sendable {
static let typeDisplayRepresentation = TypeDisplayRepresentation(name: "MaterialDesignIcons")

struct IntentServerAppEntityQuery: EntityQuery, EntityStringQuery {
func entities(for identifiers: [IntentServerAppEntity.ID]) async throws -> [IntentServerAppEntity] {
getServerEntities().filter { identifiers.contains($0.id) }

Check warning on line 11 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L10-L11

Added lines #L10 - L11 were not covered by tests
}

func entities(matching string: String) async throws -> [IntentServerAppEntity] {
getServerEntities().filter { $0.getInfo()?.remoteName.contains(string) ?? false }

Check warning on line 15 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L14-L15

Added lines #L14 - L15 were not covered by tests
}

func suggestedEntities() async throws -> [IntentServerAppEntity] {
getServerEntities()

Check warning on line 19 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L18-L19

Added lines #L18 - L19 were not covered by tests
}

private func getServerEntities() -> [IntentServerAppEntity] {
Current.servers.all.map { IntentServerAppEntity(from: $0) }

Check warning on line 23 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L22-L23

Added lines #L22 - L23 were not covered by tests
}

func defaultResult() async -> IntentServerAppEntity? {
let server = Current.servers.all.first
if server == nil {
return nil
} else {
return IntentServerAppEntity(from: server!)

Check warning on line 31 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L26-L31

Added lines #L26 - L31 were not covered by tests
}
}
}

static let defaultQuery = IntentServerAppEntityQuery()

var id: String
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(
title: .init(stringLiteral: getInfo()?.name ?? "Unknown")
)

Check warning on line 42 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L39-L42

Added lines #L39 - L42 were not covered by tests
}

init (identifier: Identifier<Server>) {
self.id = identifier.rawValue

Check warning on line 46 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L45-L46

Added lines #L45 - L46 were not covered by tests
}

init(from server: Server) {
self.init(identifier: server.identifier)

Check warning on line 50 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L49-L50

Added lines #L49 - L50 were not covered by tests
}

func getServer() -> Server? {
Current.servers.server(for: .init(rawValue: id))

Check warning on line 54 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L53-L54

Added lines #L53 - L54 were not covered by tests
}

func getInfo() -> ServerInfo? {
getServer()?.info

Check warning on line 58 in Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/IntentServerAppEntitiy.swift#L57-L58

Added lines #L57 - L58 were not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import AppIntents
import AudioToolbox
import Foundation
import Shared

@available(iOS 17.0, macOS 14.0, watchOS 10.0, *)
struct WidgetDetailsAppIntent: WidgetConfigurationIntent {
static let title: LocalizedStringResource = "Details"
static let description = IntentDescription("Display states using from Home Assistant in text")

@Parameter(title: "Server", default: nil)
literally-anything marked this conversation as resolved.
Show resolved Hide resolved
var server: IntentServerAppEntity

@Parameter(title: "Upper Text Template", default: "", inputOptions: .init(capitalizationType: .none, multiline: true, autocorrect: false, smartQuotes: false, smartDashes: false))
var upperTemplate: String

@Parameter(title: "Lower Text Template", default: "", inputOptions: .init(capitalizationType: .none, multiline: true, autocorrect: false, smartQuotes: false, smartDashes: false))
var lowerTemplate: String

@Parameter(title: "Details Text Template (only in rectangular family)", default: "", inputOptions: .init(capitalizationType: .none, multiline: true, autocorrect: false, smartQuotes: false, smartDashes: false))
var detailsTemplate: String

@Parameter(title: "Run Action (only in rectangular family)", default: false)
var runAction: Bool

@Parameter(title: "Action", default: nil)
var action: IntentActionAppEntity?

static var parameterSummary: some ParameterSummary {
When(\WidgetDetailsAppIntent.$runAction, .equalTo, true) {
Summary() {
\.$server
\.$upperTemplate
\.$lowerTemplate
\.$detailsTemplate

Check warning on line 35 in Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift#L29-L35

Added lines #L29 - L35 were not covered by tests

\.$runAction
\.$action

Check warning on line 38 in Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift#L37-L38

Added lines #L37 - L38 were not covered by tests
}
} otherwise: {
Summary() {
\.$server
\.$upperTemplate
\.$lowerTemplate
\.$detailsTemplate

Check warning on line 45 in Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift#L40-L45

Added lines #L40 - L45 were not covered by tests

\.$runAction

Check warning on line 47 in Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Extensions/AppIntents/Widget/Details/WidgetDetailsAppIntent.swift#L47

Added line #L47 was not covered by tests
}
}
}
}
Loading
Loading