Skip to content

Commit

Permalink
Avoid nil icon color in watch config (#3073)
Browse files Browse the repository at this point in the history
<!-- 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. -->
  • Loading branch information
bgoncal authored Sep 30, 2024
1 parent 1f6d31e commit 57e40ae
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ struct MagicItemCustomizationView: View {

Section {
ColorPicker(L10n.MagicItem.IconColor.title, selection: .init(get: {
Color(hex: viewModel.item.customization?.iconColor)
var color = Color(uiColor: Asset.Colors.haPrimary.color)
if let configIconColor = viewModel.item.customization?.iconColor {
color = Color(hex: configIconColor)
} else {
viewModel.item.customization?.iconColor = color.hex()
}
return color
}, set: { newColor in
viewModel.item.customization?.iconColor = newColor.hex()
}), supportsOpacity: false)
Expand Down

0 comments on commit 57e40ae

Please sign in to comment.