Skip to content

Entries with the composition tag

Pull request Correctly calculate `CollectionFlowLayoutEnvironment.contentSize` on composed-swift/Composed


Here's a small PR for a bug that I think has just gone unnoticed because we've never used the sectionInset property of the UICollectionViewFlowLayout, and we've never used the contentInset property of UICollectionView.

The issues looks to be that the layout's sectionInset property is applied on a per-section basis, but the collection view's contentInset was not being honoured.

It was also calculated using insetBy(dx:dy:), which will modify the width by -dx * 2, which would double the expected insets.

Pull request Cache `SingleElementSections.numberOfElements` on composed-swift/Composed


Overall this is pretty minor but when dealing with a lot of SingleElementSections that are infrequently updated is does start to slow down.

I thought a faster approach would be to use generics on replace(element:) to only check for nil when the value is Optional, but generics don't allow for this kind of overload.

Also added some basic tests. The performance tests show a ~9% performance increase.

Pull request Cache nib registrations to improve performance on composed-swift/Composed


@bill201207 found that UINib(nibName:bundle:) is a big part of the poor performance when our app launches.

Ultimately batching updates will help with a lot of things like this, but really that'll just be masking some of the performance issues so it's useful to find issues like this now.

Pull request Merge ComposedLayout and ComposedUI packages on composed-swift/Composed


This adds the ComposedLayout and ComposedUI packages, which will close #16.

The base for this is 2.0-beta, which we can use for testing new changes, which can also break API.

If you go to the repo settings you can (temporarily) set the default branch to 2.0-beta and we can add a note to the README stating this is the beta release and the stable release is available in the master branch.

Once merged and these changes are made the READMEs for ComposedLayout and ComposedUI repos can be updated to point to this repo and their repos archived.

Pull request Add `FlatSection` on composed-swift/Composed


This is a new type of section that is similar to ComposedSectionProvider, but rather than flattening each of the children in to a single SectionProvider it flattens them in to a single Section.

The ComposedUI side of this has been updated to support multiple cells per section, with a convenience for FlatSection that delegates the calls to each of the flattened sections.

This is a breaking change since the protocol requirements have changed. I have set the base of the PR to merge-all-libraries since that's also a breaking change and this PR relies on those changes.

edit: We've moved to our own fork to allow for more rapid development. The latest changes are in https://github.com/opennetltd/Composed/tree/feature/FlatSection, which will eventually be merged back in to this repo once some of the other PRs/issues have been resolved.

Pull request Use default Xcode version on composed-swift/Composed


In my open source frameworks I usually use the last major Xcode (currently 11.7), latest (currently 12.3) and latest beta (soon to be 12.4), but this project has only been setup for the latest version of Xcode.

If we feel it's good to run the tests across multiple Xcode versions I have created https://github.com/JosephDuffy/update-xcode-version-action, which we can use to keep the versions in-sync with the versions available as part of GitHub actions.

For now I've removed all use a explicit Xcode versions.

Pull request Fix crash switching segmented provider's segment on composed-swift/Composed


Regression introduce in 1.1.1.

Would occur when a segmented provider was the last child of a composed provider and the selected segment changed.

This could have also been fixed in SegmentedSectionProvider but changing the _currentIndex after the delegate has been notified (which is closer to what ComposedSectionProvider does) but we have nothing in the API contract stating this must be done, so really it's an issue with the caching in ComposedSectionProvider.

Pull request Cache `sections` and `numberOfSection` on composed-swift/Composed


These properties are accessed quite frequently and can be cached with a little extra processing.

This is another finding from screens that have a large number of composed sections.

This and https://github.com/composed-swift/ComposedUI/pull/15 seem to be the main areas of performance issues, although that doesn't mean that once these are working and merged we won't uncover more 😅

Thanks to @bill201207 for their contributions to this change.

Pull request Add collection view batch updates on composed-swift/ComposedUI


The idea of this is that without breaking the API the collection view will batch updates.

Inserting a large number of sections is the main area of performance loss we are currently encountering, because the sections are inserted individually and not batched. This change alone has reduce the initial load time of one our screens (which has 100-150 sections added at once) from 30-45 seconds down to less than a second (at least it is not noticeable).

I had created https://github.com/composed-swift/Composed/pull/17 to try and address this, which has the advantage that it would apply to other view types (e.g. UITableView), but I believe does not offer the same performance improvements and it is restricted to a single ComposedSectionProvider.

This is a draft to collect feedback; as you can see there are some TODOs but I think there's enough implemented to provide an overview of the changes that would be required to implement this.

This does not currently work; there are situations that cause the collection NSInternalInconsistencyException', reason: 'Invalid update error. I have some failing tests that demonstrate what the result should be.

Pull request Add `performBatchUpdates(_:)` function on composed-swift/Composed


When adding a lot of sections (we have a screen which inserts 100~175 on initial load) the performance is quite poor.

Along with the improve-composed-section-provider-performance branch (which I want to fully validate before making a PR) performing these changes in batch helps a lot.