-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Make textContainerInset configurable for ASEditableTextNode placehold… #794
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of the new property will only be recognized on first load. I would recommend extending setTextContainerInset:
to support value changes after the view has loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, added setter logic and tested that it works
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
ac9cc3c
to
879a01f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would accessing textView here cause the view to be created? Naturally that would be bad...it may be best to wrap the last two lines in a check of [self isNodeLoaded](I may have the exact property name wrong)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. Would that be the case if we were accessing self.textView
. In this case we're accessing the textView
property from _textKitComponents
which seems to be generated on self.textView
instead.
Also I just accidentally nuked my master branch so I'm going to try to reopen this :)
Thanks @samhsiung, this is a great extension to a lesser-used class. It is awesome to have some attention applied to these classes because it really helps round out the framework and provide a more confident developer experience when they are needed. |
Moved this PR here: #802 |
@samhsiung, I need textContainerInset configurable for ASTextNode but I can barely read obj-c since I'm learning Swift. Would you kindly make this change for ASTextNode also? |
@jospalding have you tried using ASInsetLayoutSpec to wrap your text node to give it padding? |
@samhsiung yes, ASInsetLayoutSpec partially solves my issue but my node has a backgroundColor and the inset does not respect it (not sure if this is expected). It adds the inset but the inset is transparent. |
@jospalding have you tried setting the background color of the parent node that has the inset instead of the ASTextNode? |
@samhsiung I can't set a background for the parent because it is also the parent of other nodes. override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
return ASInsetLayoutSpec(
insets: UIEdgeInsetsMake(10, 20, 30, 20),
child: ASStackLayoutSpec(
direction: .Vertical,
spacing: 5,
justifyContent: .Start,
alignItems: .Start,
children: [
channelNode,
titleNode,
ASRatioLayoutSpec(
ratio: 2/3,
child: imageNode
)
]
)
)
} And this is how it renders: I need the channelNode to have the padding/inset. I could wrap it inside another ASDisplayNode but this looks like a workaround for me. |
For now you can subclass
|
@jospalding could you create a separate issue for adding an |
@samhsiung nice, I will try to subclass it! I will open the issue and let you know! Thank you very much! |
@samhsiung the I ended up with something relatively simple, but I'm still not sure if it's the best soluiton. Thanks again! |
…layout is happening (facebookarchive#794)
Make textContainerInset configurable for ASEditableTextNode placeholder and typed textViews
Previously, it was only possible to configure the textContainerInset of the typed textView by accessing the textView property on didLoad. This would cause the placeholder and typed textViews to become desynced however, so in this commit we add the ability to configure both.