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

.background color modifier #41

Open
AndrewSB opened this issue Nov 19, 2020 · 4 comments
Open

.background color modifier #41

AndrewSB opened this issue Nov 19, 2020 · 4 comments

Comments

@AndrewSB
Copy link

AndrewSB commented Nov 19, 2020

It would be nice to have a .background(Color.red) operator on a view, that sets the .backgroundColor of the ASDisplayNode. Is there a technical reason this isn't already in the library? If not, could that operator be added?

@muukii
Copy link
Collaborator

muukii commented Nov 19, 2020

@AndrewSB

Hi, thanks!
The reason why we can't use such as adding background what we want is Texture's layout spec is only for layout information. We must avoid to create a node inside returning layoutspec.

This issue also helps you to understand.
#21

@muukii
Copy link
Collaborator

muukii commented Nov 19, 2020

Or even if you mean that operator sets the background color of the node, that's not also a good practice.
While creating layout spec, as possible, we should keep the state of the nodes.

@AndrewSB
Copy link
Author

AndrewSB commented Nov 19, 2020

got it, there's that technical limitation I was looking for. apologies for not searching the issues before creating a new one, and thank you for your work building this!

@AndrewSB AndrewSB reopened this Nov 19, 2020
@AndrewSB
Copy link
Author

actually, as I'm looking through your demo, would it not be possible to wrap onDidLoad in a special modifier to just change the background color? like you've done here:
https://github.com/TextureCommunity/TextureSwiftSupport/blob/96eabb9681c2a7c7cf3f55af6348c828fd567d7a/Demo/InstagramPostCellViewController.swift#L103-L105

why is it a best practice to enforce that operators only modify the layout, not node style/state? does modifying state/style cause a re-render?

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

No branches or pull requests

2 participants