ScrollStackController
                                
                                 ScrollStackController copied to clipboard
                                
                                    ScrollStackController copied to clipboard
                            
                            
                            
                        Fix: `ScrollStackControllerDelegate` methods calls
This PR adresses an issue that causes calls to the ScrollStackControllerDelegate methods
- scrollStackRowDidBecomeVisible(_:row:index:state:)
- scrollStackRowDidBecomeHidden(_:row:index:state:)
before the completion of the ScrollStack layout process, when each rows still don't have a valid frame.
This can happen for example when a ViewController uses a ScrollStack as a subview and inserts rows in a for-loop inside its viewDidLoad() method.
Now these methods are called:
- Only once after all the rows have been added and the ScrollStackhas been fully laid out
- When the user scrolls
A fix has been also made to the dispatchRowsVisibilityChangesTo(_:) ScrollStack method: it now takes into account new inserted rows which still don't have a previous visibility state.
Finally, the call to askForCutomizedSizeOfContentView(animated:) of ScrollStackRow has been moved back in the updateConstraints() method following the best practices described in ModifyingConstraints:
To batch a change, instead of making the change directly, call the setNeedsUpdateConstraints method on the view holding the constraint. Then, override the view’s updateConstraints method to modify the affected constraints. Always call the superclasses implementation as the last step of your updateConstraints method’s implementation.
This is necessary because we call setNeedsUpdateConstraints() in the layoutUI() method of ScrollStackRow.
Hi @NicFontana , thank you for PR. I would also add the new logic to get the size of the view by reading contentView instead of stackView as described in this commit. Would you add it to this PR so we'll avoid to merge both of them.
I'm not sure I've correctly understood, where should I add this logic?
my bad, it was already on develop. merging it, thanks!