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

[#713] API to identify bundle resources (like images) #714

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruspl-afed
Copy link
Contributor

ImageIdentity interface with surrounding types

Fixes #713

`ImageIdentity` interface with surrounding types

Signed-off-by: Alexander Fedorov <[email protected]>
Copy link

github-actions bot commented Dec 5, 2024

Test Results

0 files   -   663  0 suites   - 663   0s ⏱️ - 1h 17m 23s
0 tests  - 2 209  0 ✅  - 2 161  0 💤  -  47  0 ❌  - 1 
0 runs   - 6 771  0 ✅  - 6 627  0 💤  - 143  0 ❌  - 1 

Results for commit 1de9829. ± Comparison against base commit caf78f7.

@fedejeanne
Copy link

fedejeanne commented Dec 6, 2024

Hi @ruspl-afed.

Just following up yesterday's discussion in the community call. I have a question: would it be possible with this approach to somehow "swap" images/icons in runtime?

The reason I ask is because a student of mine is taking a look at how to switch (all) icons at runtime based in some property (let's call it "icon theming") and I thought the solution you propose here might be useful for that?

Our initial idea was to provide the themes in bundles and to put (all) icons inside a folder with the name of the theme in there, something like:

themeA (bundle)
'-- resources
  '-- icons
       '-- themeA
           '-- ... (the icons)

themeB (bundle)
'-- resources
  '-- icons
       '-- themeB
           '-- ... (the icons)

So if one could switch from themeA to themeB in runtime then icons would be taken from another folder. I assume one would have to add one placeholder to the URL of the icons in the consumers (something like today's $nl).

Would that be doable with this approach?

@ruspl-afed
Copy link
Contributor Author

would it be possible with this approach to somehow "swap" images/icons in runtime

This approach suggest rather normalized way to work with image resources than direct solution for "swap" problem.
However with suggested approach it may be a bit easier to implement what you want.

  1. wrap ImageRegistry with another type ImageIdentityRegistry that works with ImageIdentity
  2. provide Theme-aware implementation of ImageIdentity that will calculate URL based on active Theme
  3. implement "change theme handling" for ImageIdentityRegistry -> it will clear and refill underlying ImageRegistry with images for new active Theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API to identify bundle resources (like images)
2 participants