Giter Site home page Giter Site logo

apptekstudios / ascollectionview Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 159.0 13.67 MB

A SwiftUI collection view with support for custom layouts, preloading, and more.

License: MIT License

Swift 99.45% Ruby 0.55%
collection-view collectionview grid ios swift swift-package-manager swiftui uicollectionview

ascollectionview's People

Contributors

adamschroder avatar andersio avatar apptekstudios avatar atdrendel avatar cederache avatar diegostamigni avatar dreampowder avatar gettoset avatar grangej avatar inamiy avatar kerrmarin avatar kiliankoe avatar kkla320 avatar nferruzzi avatar noefroidevaux avatar panini-prnd avatar posix88 avatar robertjpayne avatar skunkworker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ascollectionview's Issues

SwiftUI incorrectly reusing ASCollectionView within TabView (with workaround)

I have an issue where sometimes the ASCollectionView disappears from a Tab when I go to another tab containing an ASCollectionView. This never happens if I switch to a different tab in-between.

See attached video. The Following and Test tabs are virtually identical code (basically AdjustableGridScreen with an additional filter text field that isn't visible or being used), except attached to different datasources, and with the observed layout variable renamed incase it was causing an issue.

MissingASCollectionView.mov.zip

The second attached video is a quick hack of the ASCollectionView demo app to add two tabs to the Experimental test. I created another class called SecondGridView, copied the code from "AdjustableGridScreen", adjusting as needed and reversed the posts. I can switch tabs more often before it loses the ASCollectionView but it does happen.

ASCollectionViewShowingSameMissingASCollectionView.mov.zip

Also I notice that the scroll location in ASCollectionView in one tab, is the same in the other tab even though they should be different. Also that changes to the number of columns in the first tab is reflected in the second tab, even though I've a separate instance of LayoutState called SecondLayoutState and I renamed the variables.

Feature: access itemSize in ASCollectionView.Coordinator extension

Hi everyone,

I don't have a bug but rather a question regarding the implementation and access to the layouts itemSize property:
I cloned the repo in order to implement a snapping behaviour by adding scrollViewWillEndDragging right below scrollViewDidScroll to the ASCollectionView.Coordinator extension and it works as expected with static values for the itemSize and spacing. Since I use ASCollectionView in several Views where I have different values for itemSize and spacing, I would like to access these values given to the layout somehow. Can you give me a hint on how to access them? Thank you!

Fatal error: Reading Environment<UIEdgeInsets> outside View.body

Getting this error only on iPhone 7+ (iPhone X and 11 Pro Max don't exhibit the error)

image

I've tried on V1.2.2, master and dev with the same results, and happens regardless if I actually set contentInsets on the ASCollectionView. I'm using ASWaterfallLayout, but other than that pretty standard.

Pagination with ASCollectionView

How to enable pagination with ASCollectionView. Need to integrate page control.

To Reproduce
Not getting any documentation for enabling pagination.

Expected behaviour
Way to enable pagination and integrate page controller.

Xcode Version:

  • 11.3.1

Simulator, Device, Both?

  • Both

List disappears on layout update

Describe the bug
ASCollectionViewSection disappears entirely when you navigate to a new view and come back. It comes back if you scroll

To Reproduce
I don't exactly know? I am using the same code posted in #88

Expected behaviour
List stays visible

Screenshots
https://youtu.be/EKA92UlwtuA

Xcode Version:

  • 11.3.1 (11C504)

Simulator, Device, Both?

  • Tested on Device: IPhone 6s

Context Menus break Auto Layout

Preface

Not really this library's problem, but it could help solve it by bringing in support for UIKit Context Menu as opposed to relying on SwiftUI's problematic implementation.

Issue

The issue is as follows: whenever a Context Menu is accessed, Xcode throws an error regarding some broken constraints — on any view in any configuration (screenshots attached), but sometimes a context menu preview is recovered by being placed on top of the source view.

If, however, a view has dynamic content/Button in it, it's simply not displayed.

Proposed Solution

Implement per-cell Context Menus using UICollectionView API.

I think that you have created a fantastic framework that is simply necessary to create any sort of a complex and dynamic user interface in SwiftUI (at least until Apple adds a CollectionView analog) and it would greatly increase its value by providing a solution to this issue. Pretty Please?

To Reproduce

Interact with a Context Menu

Screenshots

Code
Screen Shot 2020-01-14 at 11 58 31 PM

Rendered Result
One

Example with dynamic content/Button
IMG_1E51CA355FDF-1

Xcode Output
image

Xcode Version:

13.3.1

Simulator, Device, Both?

Both

Demo for infinite collection view list?

Hey, definitely isn’t an issue but it’d be great to get some advice on the best way to implement and infinite loading list (get to the bottom of the section within a scroll view and for it to load more cells).

Cheers!

Question about flows: how would you bind the width of an element to an external slider ?

Hi,
thanks for the package! I'm evaluating it and at the moment work like a charm (on both iOS and catalyst). I've been trying to make a custom layout pinned to an external @State .. something like this based on your PhotoGridScreen

    @State private var minWidth: CGFloat = 0.5

...
     Slider(value: self.$minWidth, in: 0.1...1.0, step: 0.01)
...

    var widthLayout: ASCollectionLayout<Int> {
        debugPrint("Called with \(self.minWidth)")
        return ASCollectionLayout(scrollDirection: .vertical, interSectionSpacing: 0) {
            ASCollectionLayoutSection { environment in
                let width = environment.container.effectiveContentSize.width

                let itemWidth = environment.container.effectiveContentSize.width * self.minWidth

                /// This closure is called when the minWidth changes but it always see the "initial" value
                /// it changes only when I do resize. Funny enough it jumps back to 0.5 when I move the slider after resizing the parent view
                 debugPrint("Min width: \(self.minWidth) Item width: \(itemWidth)")

                let gridItemInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
                let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(itemWidth),
                                                      heightDimension: .absolute(itemWidth))

                let item = NSCollectionLayoutItem(layoutSize: itemSize)
                item.contentInsets = gridItemInsets

                let count = Int(width / itemWidth)

                let rowGroupSize = NSCollectionLayoutSize(widthDimension: .absolute(itemWidth * CGFloat(count)),
                                                          heightDimension: .absolute(itemWidth))
                let rowGroup = NSCollectionLayoutGroup.horizontal(layoutSize: rowGroupSize, subitem: item, count: count)

                let section = NSCollectionLayoutSection(group: rowGroup)
                return section
            }
        }
    }

but the layout is not refreshed when I move the slider, I also need to resize the parent view (I've built the Demo for catalyst). So the question is, how can I achieve something like this?

an output example

"Called with 0.5"
"Binding<CGFloat>(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.StoredLocation<CoreGraphics.CGFloat>, _value: 0.5) Min width: 0.5 Item width: 395.75"
"Binding<CGFloat>(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.StoredLocation<CoreGraphics.CGFloat>, _value: 0.5) Min width: 0.5 Item width: 395.75"
"Called with 0.53"
"Binding<CGFloat>(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.StoredLocation<CoreGraphics.CGFloat>, _value: 0.5) Min width: 0.5 Item width: 395.75"

thanks in advance

NavigationLink crashes on pop

I got a crash adding a simple NavigationLink in the PhotoGridScreen

	var section: ASCollectionViewSection<SectionID>
	{
		ASCollectionViewSection(
			id: 0,
			data: data,
			onCellEvent: onCellEvent,
			onDragDropEvent: onDragDropEvent,
			itemProvider: { item in
				//Example of returning a custom item provider (eg. to support drag-drop to other apps)
				NSItemProvider(object: item.url as NSURL)
		})
		{ item, state in
            NavigationLink(destination: Text("Hello")) {
                ZStack(alignment: .bottomTrailing)
                {
                    GeometryReader
                    { geom in
                        ASRemoteImageView(item.squareThumbURL)
                            .aspectRatio(1, contentMode: .fill)
                            .frame(width: geom.size.width, height: geom.size.height)
                            .clipped()
                            .opacity(state.isSelected ? 0.7 : 1.0)
                    }

                    if state.isSelected
                    {
                        ZStack
                        {
                            Circle()
                                .fill(Color.blue)
                            Circle()
                                .strokeBorder(Color.white, lineWidth: 2)
                            Image(systemName: "checkmark")
                                .font(.system(size: 10, weight: .bold))
                                .foregroundColor(.white)
                        }
                        .frame(width: 20, height: 20)
                        .padding(10)
                    }
                }
            }
		}
	}

Tapping works but when I tap the "<" back button it crashes with this error

2019-11-19 18:42:40.641781+0100 Inks[24522:5610591] *** Assertion failure in -[UINavigationController popToViewController:transition:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3900.12.16/UINavigationController.m:8129
2019-11-19 18:42:40.694210+0100 Inks[24522:5610591] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'```

How should I set up my project to avoid such a thing?  or how would you think I should present a child screen from the collection view ?

thank you in advance 

Question about: This is used as a workaround for SwiftUI failing to call updateUIViewController for static sections.

Hey,

I have a static section that doesn't update when a subview's data changes. Is this related to that live above where you say:

This is used as a workaround for SwiftUI failing to call updateUIViewController for static sections.. If so, do I need to do anything? The view updates when I go back off then back on the view, or open a modal. Once again, might be SwiftUI but any advice would be super appreciated!

Adding .onLongPressGesture {} breaks scrolling unless you also add .onTapGesture{}

Describe the bug
If you add .onLongPressGesture to whatever is being displayed in ASCollectionView, you can no longer scroll the collection view, unless you manage to touch on the space left by insets.

The workaround appears to be to add .onTapGesture{} before .onLongPressGesture{}. (after doesn't work)

To Reproduce
In the ASCollectionView demo app, open AdjustableGridScreen,
In the ASCollectionViewSectionJust after creating the ASRemoteImageView add
.onLongPressGesture { print("LongPress") }

Build and run, and attempt to scroll by swiping on the images.
Add insets, touch in the inset and then drag.

Stop app,
before .onLongPressGesture{} add
.onTapGesture { print("Tap") }

Build and run the app, swipe to scroll on the image. Scrolling now works as expected.

Expected behaviour
The view should continue to scroll with only an .onLongPressGesture added to the view.

Xcode Version:
11.2.1GM

Simulator, Device, Both?
Both simulator and device.

TODO: UITableViewDiffableDataSource doesn't support headers/footers

The current implementation of ASTableView uses UITableViewDiffableDataSource, which for some reason does not allow for providing header/footer views.

Ideal solution:

  • Apple implements this (as they did for UICollectionViewDiffableDataSource)
    → Radar has been filed

Considerations for temporary solutions:

  • Consider subclassing UITableViewDiffableDataSource to implement the methods??
  • Perform diffing using the Swift library and use the old delegate methods

question: automatic height with UICollectionViewFlowLayout

Hey! First of all, thank you very much for providing this package, it's really useful.

Dislaimer: I'm sorry for asking a question here, and I completely understand if you don't have time to answer, but I was unable to solve this on my own after digging for quite some time.

I used the tags demo layout in my app. Is there any way to make the Collection view resize automatically to the height of its contents? As you can see in the screenshot provided below, the height is much larger than the actual text. (PS: I directly copied the tags example code, only exchanged the tags for some gibberish text and gave the ASCollectionView.layout(…) a background colour.

height issue screenshot

Tags disappear when running if Tags as part of List Item.

Describe the bug
I put the demo(TagsScreen) tags into list item, but it disappear when running.

ASCollectionView(
				section:
				ASCollectionViewSection(id: 0, data: store.items)
				{ item, _ in
					Text(item.displayString)
						.fixedSize()
						.padding(5)
						.background(Color(.systemGray))
						.cornerRadius(5)
			})
				.layout
			{
				let fl = AlignedFlowLayout()
				fl.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
				return fl
			}
			.shrinkToContentSize(isEnabled: shrinkToSize, $contentSize, dimensionToShrink: .vertical)

To Reproduce
Steps to reproduce the behaviour:

Expected behaviour
A description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Xcode Version:

Simulator, Device, Both?

  • Where is the problem occuring

Update Readme

Please update the readme with very basic usage example.
Am an android developer learning SwiftUi, so all these can be a little daunting!

Here is what i tried but am getting errors:

ASCollectionView(data: dataExample,
                         id: \.self,
                         layout: .init(layout: ASCollectionViewLayoutGrid(layoutMode: .adaptive(withMinItemSize: 100),
                        itemSpacing: 10,
                        lineSpacing: 10,
                        itemSize: .absolute(100))))
        { item in
            Color.blue
                .overlay(
                    Text("\(item)")
            )
        }

found that Grid example on stackoverflow. But am am getting this error message in Xcode
"Use of unresolved identifier 'ASCollectionViewLayoutGrid'"

Fatal error: Can't form Range with upperBound < lowerBound

Error: Can't form Range with upperBound < lowerBound
XCode Version: Version 11.2 beta (11B41)

Occurs when reloading SwiftUI view VERY fast.
Create a button that is reloading the collection view with changing amount of items.
Click that button very fast.

I admit this is an unusal user interaction but as it reloads on changes in Combine those could fire more often for some setups.

In my setup this is not a big problem as the button is inside a popover and that will disappear after one click. I just wanted to challenge the reloading 🤓

Bildschirmfoto 2019-10-21 um 20 04 05

Layout is created on `makeUIViewController` only, therefore custom layouts are not really updated

Hi,

I'm back with the same story but in a different sauce and still talking about the AdjustableGridScreen.
A few hours ago I understood that my columns were not changing due to 2 distinct problems, the first one is solved and the second one is what I'm writing about now.

First a short recap:
my observable object state was living within the screen itself, therefore losing all its custom values every time the parent view was recreating the screen itself (my fault).
In my demo project that happened frequently due to a global @EnvironmentObject with other models triggering the refresh.

Moving the state outside the view fixed this and with the layout closure capturing that global state the layout was properly refreshed.

But that was regardless of shouldInvalidateLayoutOnStateChange, the closure is called but the collectionView layout is still the one created from makeUIViewController, and this is the reason variable wrapped with @State are seen as the "old" ones because they are captured by the closure as values.

To make this case working I suggest a change like this in updateUIViewController to really recreate the layout.

public func updateUIViewController(_ collectionViewController: AS_CollectionViewController, context: Context)
{
    context.coordinator.parent = self
    updateCollectionViewSettings(collectionViewController.collectionView, delegate: context.coordinator.delegate)
    if context.coordinator.parent.shouldInvalidateLayoutOnStateChange {
        debugPrint("Really recreate the layout")
        collectionViewController.collectionViewLayout = layout.makeLayout(withCoordinator: context.coordinator)
        collectionViewController.collectionView.collectionViewLayout = collectionViewController.collectionViewLayout
    }
    context.coordinator.updateLayout()
    context.coordinator.updateContent(collectionViewController.collectionView, animated: true, refreshExistingCells: true)
}

and eventually, add another modifier like shouldRecreateLayoutOnStateChange.

thank you!

ASCollectionViewLayoutFlow calculates widths are wrong

As a user I want to get a simple flow layout working by using ASCollectionViewLayoutFlow.

Using ASCollectionViewLayoutFlow with simple Text Views does not result in the expected output.
I would expect that the Text can grow in width until the collection view width (vertical scroll) is reached. But even a small text gets truncated at the moment.

EXC_BREAKPOINT on didEndDisplayingCell

Error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1de7daa94)
XCode Version: Version 11.2 beta (11B41)

Bildschirmfoto 2019-10-20 um 21 09 29

Initialized ASCollectionView in the most simple way.

Bildschirmfoto 2019-10-20 um 21 19 00

How to add section headers to custom layouts?

I saw that you recently added section header support for the WaterfallLayout but how can we add similar support for custom layouts? I can't find the ASWaterfallLayout definition to try to copy the header implementation. Will this be possible do you think? Many thanks.

Weird layout behavior during scrolling

Describe the bug

Off-screen views are not loaded and appear truncated, and if a cell changes it's content dynamically, the layout breaks completely on scroll attempt.

To Reproduce

Not really sure, I guess just load a large amount of data to the ASCV and apply AlignedFlowLayout (one from the tags screen from the demo).

Expected behaviour
Layout not breaking?

Screenshots
If applicable, add screenshots to help explain your problem.

Video

https://imgur.com/uBudbT1

Xcode Version:
11.3.1

Simulator, Device, Both?
Both

Issue with initial loading on release builds

The last days I try to track down a bug that is not there when running my app with XCode development builds. But TestFlight Beta Builds / Production builds have this problem.

The app is SwiftUI from the start.

  • ScenesDelegate > NavigationView > Main View
    The main view has a Store which is set as environment object.
    This store is an OberservableObject and has an @published Array.

The main view contains a vertical scrollview. One subview there is the ASCollectionView.
It basically shows some "Tag buttons" horizontally.

So when I get to this initial Screen, the cells are not shown all the time. The store has loaded the content of the array fine. When navigating to another view the content immediately appears. Also when showing a sheet.

I tried many approaches. But none really worked out long.

I don't know if that is a bug of ASCollectionView or SwiftUI / Combine lifecycle with the Representable views.

Cannot embed in a list or form since version 1.2

Describe the bug
When embedding the ASCollectionView in a List or Form it shows an empty cell.

To Reproduce
struct Mock: View {
let data = ["1"]
var body: some View {
Form {
ASCollectionView(data: data, dataID: .self) { item, _ in
Text(item)
}
}
}
}

Expected behaviour
It would ve great if the ASCollectionView showed its content and resized the List/Form cell to fit the ASCollectionView size. This behaviour was working in v 1.1.6 even though sometimes the List/Form cell would not update its height properly.

Screenshots
in a VStack:
with a VStack

in a Form:
with a Form

Xcode Version:
11.3 (11C29)

Simulator, Device, Both?

  • Device (probably both)

Trying to pop to a missing destination

Describe the bug
push TagsScreen from RemindersScreen, then back to RemindersScreen...
report "Trying to pop to a missing destination at /BuildRoot/Library/Caches/com.apple.xbs/Sources/Monoceros/Monoceros-39.4.4/UIKit/UIKitNavigationBridge.swift:391"

To Reproduce
Steps to reproduce the behaviour:
modify RemindersScreen code like this:
ASCollectionView { ASCollectionViewSection<Section>(id: .upper, data: self.upperData) { model, _ in NavigationLink(destination: TagsScreen()) { GroupLarge(model: model) } } ...

Expected behaviour
A description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Xcode Version:

Simulator, Device, Both?

  • Where is the problem occuring

MacOS catalyst 10.15.1 - Assertion failure in -[_UICollectionLayoutItemSolver _solveGroup]

Describe the bug
So basically after I've upgraded from 10.15 to 10.15.1 most Dem layouts just crashes with the exception below (tags, and magazine are working fine).

To Reproduce
Run the Demo project enabling Catalyst

Expected behaviour
Working like in the sim

Screenshots

Thread 1 Queue : com.apple.uikit.datasource.diffing (serial)

2019-11-09 11:30:43.798628+0100 ASCollectionViewDemo[13658:253069] *** Assertion failure in -[_UICollectionLayoutItemSolver _solveGroup], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3900.12.4.906/_UICollectionLayoutItemSolver.m:546
2019-11-09 11:30:43.857480+0100 ASCollectionViewDemo[13658:253069] [General] An uncaught exception was raised
2019-11-09 11:30:43.857609+0100 ASCollectionViewDemo[13658:253069] [General] Cannot solve for a non-group item.
2019-11-09 11:30:43.857849+0100 ASCollectionViewDemo[13658:253069] [General] (
	0   CoreFoundation                      0x00007fff37955f53 __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff6da1b835 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff37971810 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff3a0515d1 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   UIKitCore                           0x00007fff758e4877 -[_UICollectionLayoutItemSolver _solveGroup] + 3778
	5   UIKitCore                           0x00007fff758e32f0 -[_UICollectionLayoutItemSolver _solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:solutionRecursionDepth:] + 253
	6   UIKitCore                           0x00007fff758e1c48 -[_UICollectionLayoutItemSolver solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:] + 110
	7   UIKitCore                           0x00007fff758e1bbf -[_UICollectionLayoutItemSolver solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:] + 77
	8   UIKitCore                           0x00007fff758f571f -[_UICollectionLayoutSectionFixedSolver _solve] + 317
	9   UIKitCore                           0x00007fff758ca213 -[_UICollectionCompositionalLayoutSolver _solveWithSectionLayouts:preferredSizesDict:dataSourceSnapshot:update:] + 1491
	10  UIKitCore                           0x00007fff758c9c29 -[_UICollectionCompositionalLayoutSolver _solve] + 201
	11  UIKitCore                           0x00007fff758c053d -[_UICollectionCompositionalLayoutSolver initWithContainer:traitCollection:layoutAxis:dataSourceSnapshot:options:sectionProvider:] + 659
	12  UIKitCore                           0x00007fff758bc235 -[UICollectionViewCompositionalLayout _fullResolve] + 1216
	13  UIKitCore                           0x00007fff758ba08d -[UICollectionViewCompositionalLayout prepareLayout] + 84
	14  UIKitCore                           0x00007fff755f2dff -[UICollectionViewData _prepareToLoadData] + 297
	15  UIKitCore                           0x00007fff755f1b33 -[UICollectionViewData validateLayoutInRect:] + 53
	16  UIKitCore                           0x00007fff755f1080 -[UICollectionView layoutSubviews] + 240
	17  UIKitCore                           0x00007fff7553b4cc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2560
	18  QuartzCore                          0x00007fff430fdba5 -[CALayer layoutSublayers] + 337
	19  QuartzCore                          0x00007fff430fd57f _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 525
	20  UIKitCore                           0x00007fff7553a7cb -[UIView(Hierarchy) layoutBelowIfNeeded] + 1299
	21  UIKitCore                           0x00007fff75525e18 -[UICollectionView reloadData] + 1620
	22  UIKit                               0x00007fff6f0a7e5c -[UICollectionViewAccessibility reloadData] + 42
	23  UIKitCore                           0x00007fff7595d36e -[UICollectionView _performDiffableUpdate:] + 44
	24  UIKitCore                           0x00007fff7591c335 -[_UIDiffableDataSourceViewUpdater _reloadData] + 136
	25  UIKitCore                           0x00007fff7590fc7c __56-[__UIDiffableDataSource reloadFromSnapshot:completion:]_block_invoke + 310
	26  UIKitCore                           0x00007fff7590fcc6 __56-[__UIDiffableDataSource reloadFromSnapshot:completion:]_block_invoke.193 + 31
	27  libdispatch.dylib                   0x000000010072978f _dispatch_client_callout + 8
	28  libdispatch.dylib                   0x000000010073a4cb _dispatch_lane_barrier_sync_invoke_and_complete + 135
	29  UIKitCore                           0x00007fff7590f93b -[__UIDiffableDataSource reloadFromSnapshot:completion:] + 668
	30  UIKitCore                           0x00007fff7590fd92 -[__UIDiffableDataSource applyDifferencesFromSnapshot:animatingDifferences:completion:] + 68
	31  libswiftUIKit.dylib                 0x00007fff78c81a4a $s5UIKit34UICollectionViewDiffableDataSourceC5apply_20animatingDifferences10completionyAA010NSDiffableeF8SnapshotVyxq_G_SbyycSgtFTm + 186
	32  ASCollectionViewDemo                0x00000001000e5518 $s16ASCollectionViewAAV11CoordinatorC18populateDataSource8animatedySb_tF + 1272
	33  ASCollectionViewDemo                0x00000001000e5dd1 $s16ASCollectionViewAAV11CoordinatorC13updateContent_8animated20refreshExistingCellsySo012UICollectionB0C_S2btF + 1441
	34  ASCollectionViewDemo                0x00000001000e052b $s16ASCollectionViewAAV22updateUIViewController_7contextyAA013AS_CollectionbE0C_7SwiftUI0dE20RepresentableContextVyAByxGGtF + 891
	35  ASCollectionViewDemo                0x00000001000ead89 $s16ASCollectionViewAAVyxG7SwiftUI29UIViewControllerRepresentableAadEP06updateeF0_7contexty0eF4TypeQz_AD0efG7ContextVyxGtFTW + 9
	36  SwiftUI                             0x00007fff719ec9d1 $s7SwiftUI42PlatformViewControllerRepresentableAdaptorV06updateD8Provider_7contexty06UIViewE4TypeQz_AA0cdF7ContextVyACyxGGtF + 289
	37  SwiftUI                             0x00007fff71aae81b $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLV6update7contexty14AttributeGraph0O7ContextVyADyxGGz_tFyyXEfU_ + 2331
	38  SwiftUI                             0x00007fff71aa94e6 $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLV6update7contexty14AttributeGraph0O7ContextVyADyxGGz_tF + 310
	39  SwiftUI                             0x00007fff71aafbd0 $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLVyxG14AttributeGraph07UntypedM0AafGP7_update_5graph9attributeySv_So10AGGraphRefaSo11AGAttributeatFZTW + 32
	40  AttributeGraph                      0x00007fff4b548399 $sTA + 25
	41  AttributeGraph                      0x00007fff4b52fa9b _ZN2AG5Graph11UpdateStack6updateEv + 1111
	42  AttributeGraph                      0x00007fff4b52fd59 _ZN2AG5Graph16update_attributeEjb + 377
	43  AttributeGraph                      0x00007fff4b534969 _ZN2AG8Subgraph6updateEj + 929
	44  SwiftUI                             0x00007fff7196b310 $s7SwiftUI9ViewGraphC14runTransaction33_D63C4EB7F2B205694B6515509E76E98BLL2inySo10AGGraphRefa_tF + 224
	45  SwiftUI                             0x00007fff7196b727 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tFSb5prefs_Sb9idealSizeAC0F0V7outputstSo10AGGraphRefaXEfU_ + 103
	46  SwiftUI                             0x00007fff7196b3e1 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tF + 145
	47  SwiftUI                             0x00007fff71c516b9 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_yyXEfU_ + 1001
	48  SwiftUI                             0x00007fff71c510ca $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_ + 634
	49  SwiftUI                             0x00007fff71c46364 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtF + 436
	50  SwiftUI                             0x00007fff71dd2752 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyF + 226
	51  SwiftUI                             0x00007fff71dd2775 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyFTo + 21
	52  UIKitCore                           0x00007fff7553b4cc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2560
	53  QuartzCore                          0x00007fff430fdba5 -[CALayer layoutSublayers] + 337
	54  QuartzCore                          0x00007fff430fd57f _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 525
	55  QuartzCore                          0x00007fff432223fb _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 323
	56  QuartzCore                          0x00007fff430ec75e _ZN2CA11Transaction6commitEv + 638
	57  QuartzCore                          0x00007fff430ec432 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 66
	58  CoreFoundation                      0x00007fff3790166e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	59  CoreFoundation                      0x00007fff37901594 __CFRunLoopDoObservers + 457
	60  CoreFoundation                      0x00007fff378a4852 __CFRunLoopRun + 1514
	61  CoreFoundation                      0x00007fff378a3fe3 CFRunLoopRunSpecific + 499
	62  HIToolbox                           0x00007fff3642b67d RunCurrentEventLoopInMode + 292
	63  HIToolbox                           0x00007fff3642b3bd ReceiveNextEventCommon + 600
	64  HIToolbox                           0x00007fff3642b147 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	65  AppKit                              0x00007fff34ab0864 _DPSNextEvent + 990
	66  AppKit                              0x00007fff34aaf5d4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
	67  AppKit                              0x00007fff34aa9d76 -[NSApplication run] + 658
	68  AppKit                              0x00007fff34a9b95d NSApplicationMain + 777
	69  AppKit                              0x00007fff34f1c094 _NSApplicationMainWithInfoDictionary + 16
	70  UIKitMacHelper                      0x00007fff686d4731 UINSApplicationMain + 322
	71  UIKitCore                           0x00007fff754c7ba4 UIApplicationMain + 2206
	72  ASCollectionViewDemo                0x000000010002affb main + 75
	73  libdyld.dylib                       0x00007fff6ed7e2e5 start + 1
)
2019-11-09 11:30:43.907697+0100 ASCollectionViewDemo[13658:253069] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot solve for a non-group item.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff37955f53 __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff6da1b835 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff37971810 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff3a0515d1 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   UIKitCore                           0x00007fff758e4877 -[_UICollectionLayoutItemSolver _solveGroup] + 3778
	5   UIKitCore                           0x00007fff758e32f0 -[_UICollectionLayoutItemSolver _solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:solutionRecursionDepth:] + 253
	6   UIKitCore                           0x00007fff758e1c48 -[_UICollectionLayoutItemSolver solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:] + 110
	7   UIKitCore                           0x00007fff758e1bbf -[_UICollectionLayoutItemSolver solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:] + 77
	8   UIKitCore                           0x00007fff758f571f -[_UICollectionLayoutSectionFixedSolver _solve] + 317
	9   UIKitCore                           0x00007fff758ca213 -[_UICollectionCompositionalLayoutSolver _solveWithSectionLayouts:preferredSizesDict:dataSourceSnapshot:update:] + 1491
	10  UIKitCore                           0x00007fff758c9c29 -[_UICollectionCompositionalLayoutSolver _solve] + 201
	11  UIKitCore                           0x00007fff758c053d -[_UICollectionCompositionalLayoutSolver initWithContainer:traitCollection:layoutAxis:dataSourceSnapshot:options:sectionProvider:] + 659
	12  UIKitCore                           0x00007fff758bc235 -[UICollectionViewCompositionalLayout _fullResolve] + 1216
	13  UIKitCore                           0x00007fff758ba08d -[UICollectionViewCompositionalLayout prepareLayout] + 84
	14  UIKitCore                           0x00007fff755f2dff -[UICollectionViewData _prepareToLoadData] + 297
	15  UIKitCore                           0x00007fff755f1b33 -[UICollectionViewData validateLayoutInRect:] + 53
	16  UIKitCore                           0x00007fff755f1080 -[UICollectionView layoutSubviews] + 240
	17  UIKitCore                           0x00007fff7553b4cc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2560
	18  QuartzCore                          0x00007fff430fdba5 -[CALayer layoutSublayers] + 337
	19  QuartzCore                          0x00007fff430fd57f _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 525
	20  UIKitCore                           0x00007fff7553a7cb -[UIView(Hierarchy) layoutBelowIfNeeded] + 1299
	21  UIKitCore                           0x00007fff75525e18 -[UICollectionView reloadData] + 1620
	22  UIKit                               0x00007fff6f0a7e5c -[UICollectionViewAccessibility reloadData] + 42
	23  UIKitCore                           0x00007fff7595d36e -[UICollectionView _performDiffableUpdate:] + 44
	24  UIKitCore                           0x00007fff7591c335 -[_UIDiffableDataSourceViewUpdater _reloadData] + 136
	25  UIKitCore                           0x00007fff7590fc7c __56-[__UIDiffableDataSource reloadFromSnapshot:completion:]_block_invoke + 310
	26  UIKitCore                           0x00007fff7590fcc6 __56-[__UIDiffableDataSource reloadFromSnapshot:completion:]_block_invoke.193 + 31
	27  libdispatch.dylib                   0x000000010072978f _dispatch_client_callout + 8
	28  libdispatch.dylib                   0x000000010073a4cb _dispatch_lane_barrier_sync_invoke_and_complete + 135
	29  UIKitCore                           0x00007fff7590f93b -[__UIDiffableDataSource reloadFromSnapshot:completion:] + 668
	30  UIKitCore                           0x00007fff7590fd92 -[__UIDiffableDataSource applyDifferencesFromSnapshot:animatingDifferences:completion:] + 68
	31  libswiftUIKit.dylib                 0x00007fff78c81a4a $s5UIKit34UICollectionViewDiffableDataSourceC5apply_20animatingDifferences10completionyAA010NSDiffableeF8SnapshotVyxq_G_SbyycSgtFTm + 186
	32  ASCollectionViewDemo                0x00000001000e5518 $s16ASCollectionViewAAV11CoordinatorC18populateDataSource8animatedySb_tF + 1272
	33  ASCollectionViewDemo                0x00000001000e5dd1 $s16ASCollectionViewAAV11CoordinatorC13updateContent_8animated20refreshExistingCellsySo012UICollectionB0C_S2btF + 1441
	34  ASCollectionViewDemo                0x00000001000e052b $s16ASCollectionViewAAV22updateUIViewController_7contextyAA013AS_CollectionbE0C_7SwiftUI0dE20RepresentableContextVyAByxGGtF + 891
	35  ASCollectionViewDemo                0x00000001000ead89 $s16ASCollectionViewAAVyxG7SwiftUI29UIViewControllerRepresentableAadEP06updateeF0_7contexty0eF4TypeQz_AD0efG7ContextVyxGtFTW + 9
	36  SwiftUI                             0x00007fff719ec9d1 $s7SwiftUI42PlatformViewControllerRepresentableAdaptorV06updateD8Provider_7contexty06UIViewE4TypeQz_AA0cdF7ContextVyACyxGGtF + 289
	37  SwiftUI                             0x00007fff71aae81b $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLV6update7contexty14AttributeGraph0O7ContextVyADyxGGz_tFyyXEfU_ + 2331
	38  SwiftUI                             0x00007fff71aa94e6 $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLV6update7contexty14AttributeGraph0O7ContextVyADyxGGz_tF + 310
	39  SwiftUI                             0x00007fff71aafbd0 $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLVyxG14AttributeGraph07UntypedM0AafGP7_update_5graph9attributeySv_So10AGGraphRefaSo11AGAttributeatFZTW + 32
	40  AttributeGraph                      0x00007fff4b548399 $sTA + 25
	41  AttributeGraph                      0x00007fff4b52fa9b _ZN2AG5Graph11UpdateStack6updateEv + 1111
	42  AttributeGraph                      0x00007fff4b52fd59 _ZN2AG5Graph16update_attributeEjb + 377
	43  AttributeGraph                      0x00007fff4b534969 _ZN2AG8Subgraph6updateEj + 929
	44  SwiftUI                             0x00007fff7196b310 $s7SwiftUI9ViewGraphC14runTransaction33_D63C4EB7F2B205694B6515509E76E98BLL2inySo10AGGraphRefa_tF + 224
	45  SwiftUI                             0x00007fff7196b727 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tFSb5prefs_Sb9idealSizeAC0F0V7outputstSo10AGGraphRefaXEfU_ + 103
	46  SwiftUI                             0x00007fff7196b3e1 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tF + 145
	47  SwiftUI                             0x00007fff71c516b9 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_yyXEfU_ + 1001
	48  SwiftUI                             0x00007fff71c510ca $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_ + 634
	49  SwiftUI                             0x00007fff71c46364 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtF + 436
	50  SwiftUI                             0x00007fff71dd2752 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyF + 226
	51  SwiftUI                             0x00007fff71dd2775 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyFTo + 21
	52  UIKitCore                           0x00007fff7553b4cc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2560
	53  QuartzCore                          0x00007fff430fdba5 -[CALayer layoutSublayers] + 337
	54  QuartzCore                          0x00007fff430fd57f _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 525
	55  QuartzCore                          0x00007fff432223fb _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 323
	56  QuartzCore                          0x00007fff430ec75e _ZN2CA11Transaction6commitEv + 638
	57  QuartzCore                          0x00007fff430ec432 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 66
	58  CoreFoundation                      0x00007fff3790166e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	59  CoreFoundation                      0x00007fff37901594 __CFRunLoopDoObservers + 457
	60  CoreFoundation                      0x00007fff378a4852 __CFRunLoopRun + 1514
	61  CoreFoundation                      0x00007fff378a3fe3 CFRunLoopRunSpecific + 499
	62  HIToolbox                           0x00007fff3642b67d RunCurrentEventLoopInMode + 292
	63  HIToolbox                           0x00007fff3642b3bd ReceiveNextEventCommon + 600
	64  HIToolbox                           0x00007fff3642b147 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	65  AppKit                              0x00007fff34ab0864 _DPSNextEvent + 990
	66  AppKit                              0x00007fff34aaf5d4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
	67  AppKit                              0x00007fff34aa9d76 -[NSApplication run] + 658
	68  AppKit                              0x00007fff34a9b95d NSApplicationMain + 777
	69  AppKit                              0x00007fff34f1c094 _NSApplicationMainWithInfoDictionary + 16
	70  UIKitMacHelper                      0x00007fff686d4731 UINSApplicationMain + 322
	71  UIKitCore                           0x00007fff754c7ba4 UIApplicationMain + 2206
	72  ASCollectionViewDemo                0x000000010002affb main + 75
	73  libdyld.dylib                       0x00007fff6ed7e2e5 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Xcode Version:

XCode 11.2
MacOSX 10.15.1

Simulator, Device, Both?
Sim is ok
MacOSX catalyst 10.15 is ok
MacOSX catalyst 10.15.1 is crashing

Well I think it is happening to a lot of projects, see

https://forums.developer.apple.com/thread/124504

so it may not be related to ASCollectionView per se but I wanted to create a bug to keep track of the evolution of this problem with you :) just in case you know any workaround or are already in contact with apple for a fix.

For instance, in my case, I need a simple grid layout with squared items so at the moment I'm using a layout based on the magazine layout because luckily it doesn't crash.

Crash "supplied identifiers are not unique"

I got this crash after rearranging items in the "Photo grid (with edit mode, selection)".

2020-01-18 09:33:41.198336-0500 ASCollectionViewDemo[37163:6025667] *** Assertion failure in -[_UIDiffableDataSourceUpdate initWithIdentifiers:sectionIdentifiers:action:desinationIdentifier:relativePosition:destinationIsSection:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3901.4.905/_UIDiffableDataSource.m:1417
2020-01-18 09:33:41.207312-0500 ASCollectionViewDemo[37163:6025667] [General] Fatal: supplied identifiers are not unique.
2020-01-18 09:33:41.245737-0500 ASCollectionViewDemo[37163:6025667] [General] (
	0   CoreFoundation                      0x00007fff2dc718ab __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff63ee2805 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2dc9ad10 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff30393221 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   UIKitCore                           0x00007fff6bf39269 -[_UIDiffableDataSourceUpdate initWithIdentifiers:sectionIdentifiers:action:desinationIdentifier:relativePosition:destinationIsSection:] + 725
	5   UIKitCore                           0x00007fff6bf395d8 -[_UIDiffableDataSourceUpdate initWithItemIdentifiers:appendingToDestinationSectionIdentifier:] + 90
	6   UIKitCore                           0x00007fff6bf2e86d -[__UIDiffableDataSource appendItemsWithIdentifiers:intoSectionWithIdentifier:] + 165
	7   libswiftUIKit.dylib                 0x00007fff6f1dc141 $s5UIKit28NSDiffableDataSourceSnapshotV11appendItems_9toSectionySayq_G_xSgtF + 241
	8   ASCollectionViewDemo                0x00000001000f7c74 $s16ASCollectionViewAAV11CoordinatorC18populateDataSource8animatedySb_tFyAA9ASSectionVyxGXEfU0_ + 452
	9   libswiftCore.dylib                  0x00007fff648035f4 $sSTsE7forEachyyy7ElementQzKXEKF + 452
	10  ASCollectionViewDemo                0x00000001000f7898 $s16ASCollectionViewAAV11CoordinatorC18populateDataSource8animatedySb_tF + 968
	11  ASCollectionViewDemo                0x00000001000f8333 $s16ASCollectionViewAAV11CoordinatorC13updateContent_8animated20refreshExistingCellsySo012UICollectionB0C_S2btF + 1123
	12  ASCollectionViewDemo                0x00000001000f1c9b $s16ASCollectionViewAAV22updateUIViewController_7contextyAA013AS_CollectionbE0C_7SwiftUI0dE20RepresentableContextVyAByxGGtF + 891
	13  ASCollectionViewDemo                0x0000000100101759 $s16ASCollectionViewAAVyxG7SwiftUI29UIViewControllerRepresentableAadEP06updateeF0_7contexty0eF4TypeQz_AD0efG7ContextVyxGtFTW + 9
	14  SwiftUI                             0x00007fff67ebefe1 $s7SwiftUI42PlatformViewControllerRepresentableAdaptorV06updateD8Provider_7contexty06UIViewE4TypeQz_AA0cdF7ContextVyACyxGGtF + 289
	15  SwiftUI                             0x00007fff67f7ff7b $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLV6update7contexty14AttributeGraph0O7ContextVyADyxGGz_tFyyXEfU_ + 2331
	16  SwiftUI                             0x00007fff67f7ac46 $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLV6update7contexty14AttributeGraph0O7ContextVyADyxGGz_tF + 310
	17  SwiftUI                             0x00007fff67f81330 $s7SwiftUI17PlatformViewChild33_A513612C07DFA438E70B9FA90719B40DLLVyxG14AttributeGraph07UntypedM0AafGP7_update_5graph9attributeySv_So10AGGraphRefaSo11AGAttributeatFZTW + 32
	18  AttributeGraph                      0x00007fff41877399 $sTA + 25
	19  AttributeGraph                      0x00007fff4185ea9b _ZN2AG5Graph11UpdateStack6updateEv + 1111
	20  AttributeGraph                      0x00007fff4185ed59 _ZN2AG5Graph16update_attributeEjb + 377
	21  AttributeGraph                      0x00007fff41863969 _ZN2AG8Subgraph6updateEj + 929
	22  SwiftUI                             0x00007fff67e3d6b0 $s7SwiftUI9ViewGraphC14runTransaction33_D63C4EB7F2B205694B6515509E76E98BLL2inySo10AGGraphRefa_tF + 224
	23  SwiftUI                             0x00007fff67e3d486 $s7SwiftUI9ViewGraphC17flushTransactionsyyFySo10AGGraphRefaXEfU_ + 262
	24  SwiftUI                             0x00007fff67e3d125 $s7SwiftUI9ViewGraphC17flushTransactionsyyF + 229
	25  SwiftUI                             0x00007fff67e3d29f $s7SwiftUI9ViewGraphC16asyncTransaction_8mutation5styleyAA0F0V_xAA01_D14Mutation_StyleOtAA0dI0RzlFyycfU_yACXEfU_ + 15
	26  SwiftUI                             0x00007fff67e3b459 $s7SwiftUI9ViewGraphCIgg_ACytIeggr_TR03$s7a3UI9cD92C16asyncTransaction_8mutation5styleyAA0F0V_xAA01_D14Mutation_StyleOtAA0dI0RzlFyycfU_yACXEfU_Tf3nnpf_n + 9
	27  SwiftUI                             0x00007fff68115797 $s7SwiftUI16ViewRendererHostPAAE06updateC5Graph4bodyqd__qd__AA0cG0CXE_tlF + 71
	28  SwiftUI                             0x00007fff68115743 $s7SwiftUI14_UIHostingViewCyqd__GAA0D13GraphDelegateA2aEP06updatedE04bodyqd__qd__AA0dE0CXE_tlFTW + 19
	29  SwiftUI                             0x00007fff67e3d27a $s7SwiftUI9ViewGraphC16asyncTransaction_8mutation5styleyAA0F0V_xAA01_D14Mutation_StyleOtAA0dI0RzlFyycfU_ + 122
	30  SwiftUI                             0x00007fff67e5ac4c $sIeg_ytIegr_TR + 12
	31  SwiftUI                             0x00007fff67cbd941 $sIeg_ytIegr_TRTA + 17
	32  SwiftUI                             0x00007fff67cbd797 $sSo9NSRunLoopC7SwiftUIE14flushObserversyyFZ + 119
	33  SwiftUI                             0x00007fff67cbd719 $sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_ + 9
	34  SwiftUI                             0x00007fff67cbd80b $sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_To + 43
	35  CoreFoundation                      0x00007fff2dbf50ee __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	36  CoreFoundation                      0x00007fff2dbf5014 __CFRunLoopDoObservers + 457
	37  CoreFoundation                      0x00007fff2dbf3c0e CFRunLoopRunSpecific + 558
	38  HIToolbox                           0x00007fff2c74a65d RunCurrentEventLoopInMode + 292
	39  HIToolbox                           0x00007fff2c74a39d ReceiveNextEventCommon + 600
	40  HIToolbox                           0x00007fff2c74a127 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	41  AppKit                              0x00007fff2adbbeb4 _DPSNextEvent + 990
	42  AppKit                              0x00007fff2adba690 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
	43  AppKit                              0x00007fff2adac3ae -[NSApplication run] + 658
	44  AppKit                              0x00007fff2ad7e775 NSApplicationMain + 777
	45  AppKit                              0x00007fff2b0a196c _NSApplicationMainWithInfoDictionary + 16
	46  UIKitMacHelper                      0x00007fff5eb888f1 UINSApplicationMain + 322
	47  UIKitCore                           0x00007fff6ba292c3 UIApplicationMain + 2105
	48  ASCollectionViewDemo                0x000000010002bb8b main + 75
	49  libdyld.dylib                       0x00007fff652507fd start + 1

Section header for Waterfall layout?

When adding a .sectionHeader modifier to a collectionview with ASWaterfallLayout, the section doesn't show up anywhere. If I remove the custom layout, then i see the header just fine.

Is there any current way to achieve a section header with the waterfall layout?

Support for RandomAccessCollection when initialise ASCollectionView with sections

Similar to my earlier problem initialising the collectionView with FetchedResults but this time when trying to use sections. The data parameter of ASCollectionViewSection still seems to be expecting an Array rather than the RandomAccessCollection that describes FetchedResults. Can the change you made to the ASCollectionView initialiser (to accept FetchedResults) be made to the section-wise initialisers?

Crash in Demo project

Describe the bug
The app starts fine, but then any of the options I choose leads to EXC_BAD_ACCESS. Both simulator and device.

To Reproduce
Run demo app, tap on any of the options in the list.

Screenshots
If applicable, add screenshots to help explain your problem.

Xcode Version:
11.2.1

Simulator, Device, Both?
Both

How can I disable the animation when ASCollectionView refreshing.

Describe the bug
A clear and concise description of what the bug is.

I found an animation occurs when ASCollectionView refresh because of data updated or modal view disappear. How can I disable the animation.

There is no animation if just a static ASCollectionView(eg. RemindersScreen demo).

To Reproduce
Steps to reproduce the behaviour:

Here is modified source code of RemindersScreen, when tap the "Create new list", modal show the TagsScreen, when I dismiss TagsScreen, RemindersScreen jumps(animation) to refresh the content.

{
	...
    
    @State private var sheetShowing = false                                     // <- modified

	var body: some View
	{
        NavigationView{
            ASCollectionView
            {   
....
                ASCollectionViewSection<Section>(id: .addNew)
                {
                    GroupSmall(model: self.addNewModel).onTapGesture {
                        self.sheetShowing = true                                     // <- modified
                    }
                }
...
            }
            .layout(self.layout)
            .contentInsets(.init(top: 20, left: 0, bottom: 20, right: 0))
            .alwaysBounceVertical()
            .background(Color(.systemGroupedBackground))
            .edgesIgnoringSafeArea(.all)
            .navigationBarTitle("Reminders", displayMode: .inline)
            .sheet(isPresented: $sheetShowing) {                                      // <- modified
                TagsScreen()
            }
        }
		
	}```

**Expected behaviour**
A description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Xcode Version:**
- 

**Simulator, Device, Both?**
- Where is the problem occuring

Weird stuttering on scroll

Describe the bug
The whole list stutters slightly while scrolling, also, when the view is loaded the list does a weird wobble. Using SDWebImageSwiftUI for image loading

To Reproduce
Layout:

var layout : ASCollectionLayout<Int> {
        return ASCollectionLayout(scrollDirection: .vertical, interSectionSpacing: 10)
        { sectionID in
            return ASCollectionLayoutSection
                { environment in
                    let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(
                        widthDimension: .fractionalWidth(1.0),
                        heightDimension: .fractionalHeight(1.0)))
                    let itemsGroup = NSCollectionLayoutGroup.horizontal(
                        layoutSize: NSCollectionLayoutSize(
                            widthDimension: .absolute(FeaturedView.THUMBNAIL_WIDTH),
                            heightDimension: .absolute(FeaturedView.THUMBNAIL_HEIGHT)),
                        subitems: [item])
                    let header = NSCollectionLayoutBoundarySupplementaryItem(
                        layoutSize: NSCollectionLayoutSize(
                            widthDimension: .fractionalWidth(1.0),
                            heightDimension: .estimated(40)),
                        elementKind: UICollectionView.elementKindSectionHeader,
                        alignment: .top)
                    let loader = NSCollectionLayoutBoundarySupplementaryItem(
                        layoutSize: NSCollectionLayoutSize(
                            widthDimension: .fractionalWidth(1.0),
                            heightDimension: .absolute(FeaturedView.THUMBNAIL_HEIGHT)),
                        elementKind: "loader",
                        alignment: .leading)
                    let section = NSCollectionLayoutSection(group: itemsGroup)
                    section.boundarySupplementaryItems = [header, loader]
                    section.contentInsets = .init(top: 10, leading: 15, bottom: 5, trailing: 15)
                    section.interGroupSpacing = 15
                    section.orthogonalScrollingBehavior = .continuous
                    return section
            }
        }
    }

One of the Sections:

ASCollectionViewSection(id: 0, data: self.featuredViewModel.updates){ manga, _ in
                MangaTile(thumbnailUrl: manga.absoluteThumbUrl, title: manga.title,
                          subTitle: String(manga.chapterUpdates[0].name), primaryItem: EmptyView(),
                          secondaryItem: ImageText(image: .clockFill, text: Text(manga.chapterUpdates[0].humanTime)
                            .font(.system(size: self.SECONDARY_FONT))
                            .bold()
                            .lineLimit(1), size: self.SECONDARY_FONT-1)
                            .foregroundColor(Color(white:0.7)))
                    .onTapGesture(perform: {
                        self.mangaDetailViewModel.setMangaId(id: manga.id)
                        self.navigated.toggle()
                    })
            }.sectionHeader {
                HStack {
                    Text("Latest Updates")
                        .font(.system(.title))
                        .bold()
                        .foregroundColor (GlobalStyles.bodyTextColor)
                    Spacer()
                }.padding(.top)
            }
            .sectionSupplementary(ofKind: "loader") {
                
                ActivityIndicator(isAnimating: .constant(self.featuredViewModel.updates.count == 0), style: .large, color: GlobalStyles.bodyTextColorUIColor)
            }

Expected behaviour
No stuttering while scrolling

Screenshots
https://youtu.be/CBtzpVQD2FE

Xcode Version:
11.3.1

Simulator, Device, Both?

  • Device: IPhone 6s

Feature Request: macOS support

Just importing UIKit means it won't build on Mac.
It's possible conditionally importing AppKit would make it macOS compatible.

Crash when using .sectionFooter

Hey,

Receiving the following crash when initialising the ASCollectionView with the following:

ASCollectionView(sections: self.sections).layout(self.layout), which causes the following:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindSectionFooter with identifier 42E2D4F8-919E-4EFD-9E98-7803857EFA55 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'.

Only seems to happen with that type of initialisation as the demo apps work?

Thread 1: Fatal error: Index out of range

Getting a crash on line 194, parent.sections[sectionIndex].id in ASCollectionSwift when the views have dynamic sections:

Thread 1: Fatal error: Index out of range. Let me know if I can help with anymore debug!

Feature request: Scroll To Position Programatically (? via Binding)

I would like to be able to programmatically jump the ASCollectionView to the bottom by way of a binding variable. This would replicate the behavior in the Shortcuts application, where you can tap on the Shortcuts tab bar icon to move the collection view to the bottom.

TagsScreen does not accommodate long tags

When the tags in TagsScreen are very long, the following errors are repeatedly logged in the console:

2020-01-22 11:06:38.781109-0500 ASCollectionViewDemo[62547:7909342] The behavior of the UICollectionViewFlowLayout is not defined because:
2020-01-22 11:06:38.781265-0500 ASCollectionViewDemo[62547:7909342] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
2020-01-22 11:06:38.781351-0500 ASCollectionViewDemo[62547:7909342] Please check the values returned by the delegate.
2020-01-22 11:06:38.781885-0500 ASCollectionViewDemo[62547:7909342] The relevant UICollectionViewFlowLayout instance is <ASCollectionViewDemo.AlignedFlowLayout: 0x7fd1aef42720>, and it is attached to <UICollectionView: 0x7fd1af8cb000; frame = (-171.5 -222.5; 343 445); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600001a73d50>; layer = <CALayer: 0x60000148d5c0>; contentOffset: {0, 0}; contentSize: {343, 230}; adjustedContentInset: {0, 0, 0, 0}; layout: <ASCollectionViewDemo.AlignedFlowLayout: 0x7fd1aef42720>; dataSource: <_TtGC5UIKit34UICollectionViewDiffableDataSourceSiV16ASCollectionView28ASCollectionViewItemUniqueID_: 0x6000016f7e80>>.
2020-01-22 11:06:38.781985-0500 ASCollectionViewDemo[62547:7909342] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

You can reproduce this easily by changing TagStore to return very long tags, and then running in a narrow device's simulator (i.e., not the iPad):

static func randomItems() -> [Item] {
    TagStore.allWords.indices.shuffled()[0 ... Int.random(in: 8 ... 18)].map {
        // Item(id: $0, displayString: TagStore.allWords[$0])
        Item(id: $0, displayString: UUID().uuidString + UUID().uuidString + UUID().uuidString)
    }
}

There probably needs some extra sizing logic in the layout to handle the case when the tag's width is wider than the available space.

Add feature scrollToItem

I have a feature request, that might fit in the scope of your library.

On a UICollectionView we have the possibility to scrollToItem(at:at:animated:) is that somehow already possible or are you planning to add such features?

Thanks in advance.

Cocoapods support

Great product. Thanks for making it available.

Any chance you could set this up to work with Cocoapods? (The online build tool I'm using doesn't support SPM.)

Enviroment Data lost in SwiftUI view

When using an environment object, or any data in the environment, e.g. managed object context, it causes an intermittent crash.

To Reproduce
Steps to reproduce the behaviour:

  • Create standard grid with ASCollectionView
  • Using environment to pass data to SwiftUI view (managedObjectContext is a good example)
  • Experience crash

Expected behaviour

  • No crash, or documentation on expected behaviour/implementation?

Xcode Version:

  • 11.3

Simulator, Device, Both?
Both, iOS 11.3.

How to initialise ASCollectionView with FetchedResults from a @FetchRequest?

When I supply my FetchedResults to the data parameter of the initialisation method I get "Cannot convert value of type 'FetchedResults' to expected argument type '[_]'"

Is there a way to feed the ASCollectionView with my managedObjects directly? I'm currently working around the problem with an array of data (maintained in parallel with the fetchedResults) limited to visible cell content. This is unpleasant.

Great work on this!

EXC_BAD_ACCESS when choosing release build configuration

Error: EXC_BAD_ACCESS (code=1, address=0x0)
XCode Version: Version 11.2 beta (11B41)

When selecting release build configuration in my scheme, ASCollectionView crashes.

I tried to track down a bug in my app where the collection view loaded fine in development builds.
The TestFlight version does not crash but is not loading the content on first change of the data behind. When setting the data again, the view loads without crash.
So I thought to run the App as Release Build and now it crashes.

Bildschirmfoto 2019-10-22 um 08 29 44

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.