-
Notifications
You must be signed in to change notification settings - Fork 19
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
More flexibility possible? #1368
Comments
Regarding (2): I guess I should simply not generate code via annotations but use the |
You can change the doc ID with the Line 36 in c5af48b
I'm not sure what your goal is exactly for changing the rootNode, but you can create different functions with different root nodes and call the appropriate one at runtime. |
@StephanSchuster please let us know if the |
Hi @rylin8, thanks for catching up and sorry that I did not reply since my initial question. I haven't had time since then to work with ADC. Now this hopefully changes. You mentioned I think for (2) I will be good to proceed as I mentioned in my second comment. And for (1) I was hoping that you could add something like this into DocServer: // ...
val assetManager = context.assets
try {
@Suppress("DiscouragedApi")
val resourceId = context.resources.getIdentifier("figma_${id.lowercase()}_dcf", "raw", context.packageName)
val assetDoc = if (resourceId != 0) {
// If file exists in res/raw, load from there
context.resources.openRawResource(resourceId)
} else {
// Otherwise, load from assets (like done now)
assetManager.open("figma/$id.dcf")
}
val decodedDoc = decodeDiskDoc(assetDoc, null, docId, Feedback)
// ...
}
// ... Background: files in Maybe the order should be the other way round: Do you think there is a chance that you will add such functionality? |
@StephanSchuster we actually did earlier this week! #1778. We haven't added documentation for it, but the test that was added should show how to use it. It will be released as part of 0.32, and we cut 0.32.0-rc01 the other day. |
@timothyfroehlich, @dipenpradhan : Yes, yes, yes!!! This is awesome. Thank you so much. I think this is a great addition. I just tested it in rc-01. Works! One thing, however ... The current comment for The priorities as far as I can tell are:
For me, this totally makes sense. Can you confirm that the above is true and you will stick with this? |
Along the idea of "more flexibility", would it be possible to have a Background: We want/need to toggle various |
The comment regarding live update not working is a bit misleading. If you enable live update the design switcher will show errors and you likely won't be able to see your app. We are aware of this issue and filed #1802 to fix it. |
@rylin8 : I think the current logic/priorities/implementation is fine as it is (see 1.-4. above). It totally makes sense. Also the single res/raw. I did not experience any errors. I would not change anything. I would just fix the comment. |
Thanks for releasing 0.32.0 including the new resource loading. This is an important first step for how we plan to use ADC in the future. And while I know that this is only the first shot, I have some more comments, questions and findings (which you might already be aware of). Assume the following:
Based on the above:
Now that I am writing this, I am not 100% sure anymore if the same docId results from the dynamic way how we are using ADC or if this happens with static code as well. I could look it up, but I guess you know it by heart and can judge for yourself if this is a situation that you want to handle. The way I am currently handling this is by clearing the ADC cache similar to your fun clearCache(context: Context, figmaConfig: FigmaConfig) {
// Delete cache file to avoid outdated artifacts
deleteCacheFile(context, figmaConfig)
// Imitate "ClearStateTestRule" from ADC codebase
clearStates()
clearDocuments()
clearFileFetchStatus()
DesignSettings.setRawResourceId(Resources.ID_NULL)
// Additional stuff that seems required or useful
clearSubscriptions()
clearFirstFetch()
} Each method is currently using reflection. Yes, ugly, super ugly, but the only option I have as of now. Is there a chance that you offer a public API method to clear the cache in some way or the other? This might help others as well. Besides the scenario mentioned above, we also need to clear the ADC cache whenever we notice that because of a new configuration the list of needed Figma root nodes ("server params") changed. In that case we would also face the above "node not found" situation. Hence, we clear the cache and download a new doc with all needed root nodes. Okay, this now gets a bit wired, sorry. I guess in the end it boils down to: can we have a official One last related thing: just skimmed again over the DocServer code. If I have setRawResource() and no live updates enabled (we also do this dynamically) but some cached files on |
First, the Second, the load order is unfortunately a bit confusing at the moment. On app startup, it should load from assets/raw resources if it exists, at which point the doc is added to a memory cache. After that, the document will always be found in the cache. I realize this is not ideal for supporting RRO and changing the resource. This is a new feature that hasn't been full worked out yet. We will discuss this issue soon, I've filed #1814 to track the issue. Thanks for the input! |
@rylin8 : Thanks for your answer. We are looking forward to see this feature evolving. In case you want more input, also e.g. on our "dynamic usage" of ADC, we (@Elektrobit) would be happy to schedule a call. |
I just started evaluating ADC. Really cool and useful. Thanks for all your work so far.
Do you think the following two features would be possible in future releases of ADC in order to increase its flexibility:
docId
androotNode
(e.g. via params) instead of generating/hardcoding them --> enables custom loading logicAny feedback appreciated.
More details on (1):
As far as I can see, this is where you currently try to load offline
*.dcf
files from theassets/figma
dir:automotive-design-compose/designcompose/src/main/java/com/android/designcompose/DocServer.kt
Line 513 in 4dd69e2
Before doing so, you could check in
res/raw/
and then fall back toassets/figma
. In consequence we could apply new*.dcf
files via RRO which would be a great and mighty new feature.More details on (2):
Currently code like this
results in the following generated code:
See:
automotive-design-compose/codegen/src/main/kotlin/com/android/designcompose/codegen/BuilderProcessor.kt
Line 642 in 4dd69e2
automotive-design-compose/codegen/src/main/kotlin/com/android/designcompose/codegen/BuilderProcessor.kt
Line 779 in 4dd69e2
I think if we could provide
docId
androotNode
dynamically, e.g. via optional params to the generated Composable, this would provide a hook for custom loading mechanisms. I other words, I would wish for a way to load a dedicated Figma doc/branch like the DesignSwitcher but from my own code.The text was updated successfully, but these errors were encountered: