Add sensor widget sizes (#3187)

<!-- 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
Add bigger widget sizes for the sensors widget

## Screenshots
<img width="277" alt="Screenshot 2024-11-23 at 14 14 59"
src="https://github.com/user-attachments/assets/caef4acd-264a-4c61-9270-a4c43e2c07b4">
<img width="281" alt="Screenshot 2024-11-23 at 14 19 06"
src="https://github.com/user-attachments/assets/efcc6038-0d46-46f3-819d-50c3ddf82e83">
This commit is contained in:
Penait1
2024-11-26 11:39:01 +01:00
committed by GitHub
parent a28e412819
commit 0435970293
4 changed files with 8 additions and 4 deletions

View File

@@ -509,7 +509,6 @@
3E02C0F32CA8032500102131 /* WidgetSensorsAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E02C0E92CA7FD2A00102131 /* WidgetSensorsAppIntent.swift */; };
3E02C0F52CA8047000102131 /* WidgetSensorsAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E02C0E92CA7FD2A00102131 /* WidgetSensorsAppIntent.swift */; };
3E02C0F62CA8049500102131 /* WidgetSensorsAppIntentTimelineProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E02C0EA2CA7FD2A00102131 /* WidgetSensorsAppIntentTimelineProvider.swift */; };
3E02C0F72CA818A400102131 /* WidgetSensorsAppIntentTimelineProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E02C0EA2CA7FD2A00102131 /* WidgetSensorsAppIntentTimelineProvider.swift */; };
3E4087EB2CD9047B0085DF29 /* ReloadWidgetsAppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 420F53F02C4EA314003C8415 /* ReloadWidgetsAppIntent.swift */; };
3E4087ED2CE62B5A0085DF29 /* WidgetBasicViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4087EC2CE62B5A0085DF29 /* WidgetBasicViewInterface.swift */; };
3E4087EE2CE62B5A0085DF29 /* WidgetBasicViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4087EC2CE62B5A0085DF29 /* WidgetBasicViewInterface.swift */; };
@@ -6745,7 +6744,6 @@
D0FF79D220D87D200034574D /* ClientEventTableViewController.swift in Sources */,
42D5ACCE2C636F2B00D9C4E2 /* WatchConfigurationViewModel.swift in Sources */,
117D8A0824A9347F00580913 /* UIColor+CSSRGB.swift in Sources */,
3E02C0F72CA818A400102131 /* WidgetSensorsAppIntentTimelineProvider.swift in Sources */,
11F3D74C2495377B00C05BBA /* SensorListViewController.swift in Sources */,
42FCCFFA2B9B1C310057783F /* ThreadCredentialsSharingToKeychainViewModel.swift in Sources */,
B6617EED1CFE79AD004DEE6D /* NSURL+QueryDictionary.swift in Sources */,

View File

@@ -14,6 +14,9 @@ struct WidgetSensorsAppIntent: WidgetConfigurationIntent {
title: .init("app_intents.choose_sensor.title", defaultValue: "Choose Sensor"),
size: [
.systemSmall: 2,
.systemMedium: 4,
.systemLarge: 10,
.systemExtraLarge: 20,
]
)
var sensors: [IntentSensorsAppEntity]?

View File

@@ -17,7 +17,7 @@ struct WidgetSensorsAppIntentTimelineProvider: AppIntentTimelineProvider {
) async -> WidgetSensorsEntry {
do {
let suggestions = await suggestions()
configuration.sensors = Array(suggestions.flatMap { key, value in
configuration.sensors = await Array(suggestions.flatMap { key, value in
value.map { sensor in
IntentSensorsAppEntity(
id: sensor.id,
@@ -27,7 +27,7 @@ struct WidgetSensorsAppIntentTimelineProvider: AppIntentTimelineProvider {
icon: sensor.icon
)
}
}.prefix(upTo: 2))
}.prefix(WidgetBasicContainerView.maximumCount(family: context.family)))
return try await entry(for: configuration, in: context)
} catch {
Current.Log.error("Using placeholder for sensor widget snapshot")

View File

@@ -47,5 +47,8 @@ enum WidgetDetailsTableSupportedFamilies {
@available(iOS 17.0, *)
static let families: [WidgetFamily] = [
.systemSmall,
.systemMedium,
.systemLarge,
.systemExtraLarge,
]
}