mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-04 21:15:17 -06:00
## Add display text parameter to Control Center controls - [x] Explore repository structure and understand Control Center controls - [x] Add displayText parameter to ControlButtonConfiguration (Button control) - [x] Update ControlButtonValueProvider to use displayText when available - [x] Add displayText parameter to ControlSwitchConfiguration (Switch control) - [x] Update ControlSwitchValueProvider to use displayText when available - [x] Add displayText parameter to ControlLightsConfiguration (Light control) - [x] Update ControlLightsValueProvider to use displayText when available - [x] Add displayText parameter to ControlCoverConfiguration (Cover control) - [x] Update ControlCoverValueProvider to use displayText when available - [x] Add displayText parameter to ControlSceneConfiguration (Scene control) - [x] Update ControlScenesValueProvider to use displayText when available - [x] Update ControlScene to use displayText in Label - [x] Add displayText parameter to ControlScriptsConfiguration (Script control) - [x] Update ControlScriptsValueProvider to use displayText when available - [x] Update ControlScript to use displayText in Label - [x] Add displayText parameter to ControlOpenPageConfiguration (OpenPage control) - [x] Update ControlOpenPageValueProvider to use displayText when available - [x] Update ControlOpenPage to use displayText in Label - [x] Add displayText parameter to ControlAssistConfiguration (Assist control) - [x] Update ControlAssistValueProvider to use displayText when available - [x] Update ControlAssist to use displayText in Label - [x] Add displayText parameter to all OpenEntity controls (Entity, Switch, Light, Cover, InputBoolean, Lock, Camera, Sensor) - [x] Update all OpenEntity value providers to use displayText when available - [x] Update all OpenEntity controls to use displayText in Labels - [x] Run code review - No issues found - [x] Run security checks - No vulnerabilities detected - [x] Fix SwiftFormat lint issues - wrapped long lines to meet 120 character limit ## Summary Successfully added an optional `displayText` parameter to all Control Center control configurations. This allows users to override the default display text shown on their controls without changing the underlying entity name. ### Implementation Details **Controls Updated (19 total):** 1. Button 2. Switch 3. Light 4. Cover 5. Scene 6. Script 7. OpenPage 8. Assist 9. OpenEntity 10. OpenSwitch 11. OpenLight 12. OpenCoverEntity 13. OpenInputBoolean 14. OpenLock 15. OpenCamera 16. OpenSensor **Pattern Applied:** - Added `@Parameter` for `displayText: String?` in each Configuration struct - Added `displayText: String?` field to each Item struct - Updated value providers to pass displayText through to items - Updated control widgets to use `displayText ?? defaultText` pattern for labels - Parameter is optional, maintaining backward compatibility - Fixed SwiftFormat lint issues by wrapping long lines **Files Modified:** 28 files total - 19 Configuration/ValueProvider files - 19 Control widget files (some combined in same file) All changes maintain backward compatibility - existing controls will continue to work without modification. <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > To each Control center control that we have, add a new parameter to control configuration where the user can override the display text </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
27 lines
960 B
Swift
27 lines
960 B
Swift
import AppIntents
|
|
import Foundation
|
|
import Shared
|
|
import SwiftUI
|
|
import WidgetKit
|
|
|
|
@available(iOS 18, *)
|
|
struct ControlOpenCoverEntity: ControlWidget {
|
|
var body: some ControlWidgetConfiguration {
|
|
AppIntentControlConfiguration(
|
|
kind: WidgetsKind.controlOpenCoverEntity.rawValue,
|
|
provider: ControlOpenCoverEntityValueProvider()
|
|
) { template in
|
|
ControlWidgetButton(action: {
|
|
let intent = OpenEntityAppIntent()
|
|
intent.entity = template.entity
|
|
return intent
|
|
}()) {
|
|
// ControlWidget can only display SF Symbol
|
|
Label(template.displayText ?? template.entity.displayString, systemImage: template.icon.id)
|
|
}
|
|
}
|
|
.displayName(.init(stringLiteral: L10n.Widgets.Controls.OpenCover.Configuration.title))
|
|
.description(.init(stringLiteral: L10n.Widgets.Controls.OpenCover.description))
|
|
}
|
|
}
|