Skip to content

Generate lazy icon properties#66

Closed
Goooler wants to merge 2 commits into
ComposeGears:mainfrom
Goooler:use-lazy-for-icon-properties
Closed

Generate lazy icon properties#66
Goooler wants to merge 2 commits into
ComposeGears:mainfrom
Goooler:use-lazy-for-icon-properties

Conversation

@Goooler

@Goooler Goooler commented Jul 28, 2024

Copy link
Copy Markdown
Member

@egorikftp

Copy link
Copy Markdown
Member

Wow, so quick 🚀
Will check soon

@Goooler Goooler force-pushed the use-lazy-for-icon-properties branch from d5581d1 to a73b845 Compare July 28, 2024 10:32
@egorikftp

Copy link
Copy Markdown
Member

@Goooler Lazy delegate should be as an additional option for export, not an replacement for current 🙂

@Goooler

Goooler commented Jul 28, 2024

Copy link
Copy Markdown
Member Author

I'm not sure why Jetpack team used backing properties before, if there are no necessary reasons, we can fully migrate to lazy. Otherwise, we have to add an extra toggle for this, maybe with extra exporting steps?

@egorikftp

Copy link
Copy Markdown
Member

For my project I prefer backing property approach due to it uses less overhead. Someone prefer using lazy block, due to code more compact. (not remember any existing solutions which provides lazy generation out of the box)

I think plugin support both options 🙂
You can simply create basic generation logic, I will integrate it into plugin as additional setting

Comment on lines +93 to +114
val codeBlock = buildCodeBlock {
add(
imageVectorBuilderSpecs(
iconName = when {
config.iconNestedPack.isEmpty() -> config.iconName
else -> "${config.iconNestedPack}.${config.iconName}"
},
vector = vector,
path = {
vector.nodes.forEach { node -> addVectorNode(node) }
},
),
)
addStatement("")
addStatement("return %N!!", backingProperty)
}

delegate(
CodeBlock.builder()
.beginControlFlow("lazy(%T.NONE)", ClassNames.LazyThreadSafetyMode)
.add(codeBlock)
.endControlFlow()
.build(),
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All here, you can copy and paste anytime. I'll leave the PR here until I have more time to take or finish by you.

@egorikftp egorikftp added this to the 0.5 milestone Jul 29, 2024
@Goooler

Goooler commented Jul 31, 2024

Copy link
Copy Markdown
Member Author

Closed due to #70.

@Goooler Goooler closed this Jul 31, 2024
@Goooler Goooler deleted the use-lazy-for-icon-properties branch July 31, 2024 05:42
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.

2 participants