Add custom image/GIF option to icon state customizations#23
Conversation
|
Thank you for the effort! 👍 For me, the customizations represent a different state of the original options and I would like them to have a 1:1 relationship. What I mean is that I would also expect the new image option in the basic (non-customization) action settings. I know that this is also supported by vanilla StreamController, but it makes more sense to me to have the option in the action settings as well. So please also add the image field to the action settings and I'll happily merge the PR. |
|
Thanks for the feedback! Totally makes sense to have it as a base option as well. I'll add the image field to the action settings and update the PR. |
Extends the existing image customization (previously only available in state filters) to the main Show Icon action settings. A custom image overrides the icon, color, scale and opacity when set. The other fields are disabled when an image is active to make the relationship clear. Also hardens settings initialization to fill in missing keys from defaults, preventing KeyErrors on actions with incomplete saved state.
|
I cleaned up the code to align with my vision and fixed some issues. Please check whether the branch still works for you. If it does, I think it can be merged. |
|
I thought some more about this and realized something: it is a viable option to integrate the image into the icon field. If the entered text is a valid MDI string, the icon is used, otherwise it is treated as a file path. The only neccessary change to the current main branch would be adding a file picker and probably some checks and tweaks. I think I like that idea - what do you think? |
Instead of a separate image field, the icon field now accepts both MDI icon names and file paths. If the entered value is a valid MDI icon it is rendered as before, otherwise it is treated as an image/GIF path. Scale works for both. The filter customizations follow the same logic.
|
Thanks for the review and the idea, really like how it turned out! 🔥 Went ahead and merged the image option into the icon field, if the value is a valid MDI icon it works as before, otherwise it's treated as a file path. Noticed that scale actually works for images too so I left it enabled 🙌 |

Summary
Details
IconCustomizationgains an optionalcustom_imagefield (file path), stored and loaded viaexport()/from_dict()icon_helper.get_icon()returns the file path directly when a custom image is set, bypassing SVG rendering