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

Overview

Contributors Forks Stargazers Issues MIT License Build status

ASCollectionView

A SwiftUI implementation of UICollectionView & UITableView. Here's some of its useful features:

  • supports preloading and onAppear/onDisappear.
  • supports cell selection, with automatic support for SwiftUI editing mode.
  • supports autosizing of cells.
  • supports the new UICollectionViewCompositionalLayout, and any other UICollectionViewLayout
  • supports removing separators for ASTableView.
  • supports directly using FetchedResults as a data source

Pull requests and suggestions welcome :)

Report Bug · Suggest a feature

Table of Contents

Screenshots from demo app

Getting Started

ASCollectionView is a swift package.

Alternatively, if you're unable to use SPM for some reason, you can import it using cocoapods: pod 'ASCollectionView-SwiftUI', '~> 1.3'

Usage

Basic example - single section:

import ASCollectionView
import SwiftUI

struct SingleSectionExampleView: View
{
    @State var dataExample = (0 ..< 30).map { $0 }
    
    var body: some View
    {
        ASCollectionView(data: dataExample, dataID: \.self)
        { item, _ in
            Color.blue
                .overlay(Text("\(item)"))
        }
        .layout
        {
            .grid(
                layoutMode: .adaptive(withMinItemSize: 100),
                itemSpacing: 5,
                lineSpacing: 5,
                itemSize: .absolute(50))
        }
    }
}

Multiple sections with unique data sources

Below is an example of how to include a collection view with two sections (each with their own data source). For an extended example with a custom compositional layout see here. Or for more in-depth examples download the demo project included in this repo.

import SwiftUI
import ASCollectionView

struct ExampleView: View
{
    @State var dataExampleA = (0 ..< 21).map { $0 }
    @State var dataExampleB = (0 ..< 15).map { "ITEM \($0)" }
    
    var body: some View
    {
        ASCollectionView
        {
            ASCollectionViewSection(
                id: 0,
                data: dataExampleA,
                dataID: \.self)
            { item, _ in
                Color.blue
                    .overlay(
                        Text("\(item)")
                    )
            }
            ASCollectionViewSection(
                id: 1,
                data: dataExampleB,
                dataID: \.self)
            { item, _ in
                Color.green
                    .overlay(
                        Text("Complex layout - \(item)")
                    )
            }
            .sectionHeader
            {
                Text("Section header")
                    .padding()
                    .frame(maxWidth: .infinity, alignment: .leading) // Fill width and align text to the left
                    .background(Color.yellow)
            }
            .sectionFooter
            {
                Text("This is a section footer!")
                    .padding()
            }
        }
        .layout
        { sectionID in
            switch sectionID
            {
            case 0:
                // Here we use one of the provided convenience layouts
                return .grid(
                    layoutMode: .adaptive(withMinItemSize: 100),
                    itemSpacing: 5,
                    lineSpacing: 5,
                    itemSize: .absolute(50))
            default:
                return ASCollectionLayoutSection
                { environment in
                    // ...
                    // You could return any custom NSCollectionLayoutSection here. For an example see this file: /readmeAssets/SampleUsage.swift
                    // ...
                }
            }
        }
    }
}

Supplementary Views

ASCollectionView has support for supplementary views. To add a supplementary view, use the sectionHeader, sectionFooter, or sectionSupplementary modifiers on your ASCollectionViewSection.

  • sectionHeader and sectionFooter set the supplementary for UICollectionView.elementKindSectionHeader and UICollectionView.elementKindSectionHeader respectively.
  • sectionSupplementary lets you specify any supplementaryKind.
ASCollectionViewSection(...) { ... }
    .sectionHeader
    {
        Text("Section header")
            .background(Color.yellow)
    }
    .sectionFooter
    {
        Text("Section footer")
            .background(Color.blue)
    }
    .sectionSupplementary(ofKind: "someOtherSupplementaryKindRequestedByYourLayout")
    {
        Text("Section supplementary")
            .background(Color.green)
    }

Decoration Views

A UICollectionViewLayout can layout decoration views that do not relate to the data (eg. a section background). These cannot be configured so you must provide a View struct that can be initialised using .init().

  • To enforce this requirement, your view must conform to the Decoration protocol. The only requirement of this is an initialiser with no arguments.
  • You must register the view type with the layout.
  • See the Reminders screen of the Demo app for a working example.

Declaring a swift view conforming to Decoration:

struct GroupBackground: View, Decoration
{
    let cornerRadius: CGFloat = 12
    var body: some View
    {
        RoundedRectangle(cornerRadius: cornerRadius)
            .fill(Color(.secondarySystemGroupedBackground))
    }
}

Registering the decoration type with the layout (ASCollectionLayout):

var layout: ASCollectionLayout<Section>
{
    ASCollectionLayout<Section>
    {
        // ... Here is an example of including a decoration in a compositional layout.
        let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background(elementKind: "groupBackground")
        sectionBackgroundDecoration.contentInsets = section.contentInsets
        section.decorationItems = [sectionBackgroundDecoration]
        // ...
    }
    .decorationView(GroupBackground.self, forDecorationViewOfKind: "groupBackground") // REGISTER the decoration view type
}

Layout

  • There is inbuilt support for the new UICollectionViewCompositionalLayout.
    • You can define layout on a per-section basis, including the use of a switch statement if desired.
    • Work in progress: There are some useful methods that allow for easy definition of list and grid-based layouts (including orthogonal grids).

Define layout for all sections:

ASCollectionView(...) { ... }
    .layout
    {
        ASCollectionLayoutSection
        { layoutEnvironment in
            // Construct and return a NSCollectionLayoutSection here
        }
    }

Define layout per section:

ASCollectionView(...) { ... }
    .layout
    { sectionID in
        switch sectionID
        {
        case .userSection:
            return ASCollectionLayoutSection
            { layoutEnvironment in
                // Construct and return a NSCollectionLayoutSection here
            }
        }
    case .postSection:
        return ASCollectionLayoutSection
        { layoutEnvironment in
            // Construct and return a NSCollectionLayoutSection here
        }
    }

Use a custom UICollectionViewLayout:

ASCollectionView(...) { ... }
    .layout
    {
        let someCustomLayout = CustomUICollectionViewLayout()
        someCustomLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
        return someCustomLayout
    }

Other tips

  • You can use an enum as your SectionID (rather than just an Int), this lets you easily determine the layout of each section.
  • See the demo project for more in-depth usage examples.
  • Please note that you should only use @State for transient visible state in collection view cells. Anything you want to persist long-term should be stored in your model.

Todo

See the open issues for a list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

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

    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

    opened by nferruzzi 20
  • Recent update broke cells auto-sizing and updating.

    Recent update broke cells auto-sizing and updating.

    Describe the bug A recent update (not sure which one, but I've switched from the dev branch (now non-existent) to the master branch) completely and utterly destroyed my layout (I'm using the layout from the TagsScreen Demo). Now cells not only flicker and are of incorrect sizes, but also not interactable while updating. Context menus (awesome menus tho) also do not work.

    I'm attaching videos of behavior before the update and after.

    I'm currently building an application that heavily relies on your wonderful library, so it would be very sad if I was unable to continue using it.

    Love your work ❤️❤️❤️

    To Reproduce I could send you my project if you're interested.

    Expected behaviour Everything working gracefully.

    Screenshots https://imgur.com/a/fppwCwn

    Xcode Version: 11.4 Beta

    Simulator, Device, Both? Both

    opened by alexeyprimechaev 19
  • Cannot Hide Navigation Bar

    Cannot Hide Navigation Bar

    Describe the bug If you try to hide the navigation bar on a view with ASCollectionView, the navigation bar always shows to some degree.

    To Reproduce Steps to reproduce the behavior: On the TagsScreen of the demo project add the following to the outermost VStack:

    .navigationBarTitle("") .navigationBarHidden(true) .navigationBarBackButtonHidden(true)

    Expected behaviour The navigation bar should be completely hidden, and there should be not available space for it.

    Screenshots I colored the outer most VStack red to show that its not taking but the full height. Screen Shot 2020-06-01 at 5 26 42 PM

    Simulator, Device, Both? Tested on Xcode 11.5 simulator

    opened by Rspoon3 11
  • NavigationLink crashes on pop

    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 
    
    Resolved AppleBug 
    opened by nferruzzi 11
  • Crash on iOS 15 occurs when sections do not have a .sectionHeader

    Crash on iOS 15 occurs when sections do not have a .sectionHeader

    In iOS 15, a crash occurs in some circumstances when a .sectionHeader is not provided:

    the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath: does not match the element kind it is being used for. When asked for a view of element kind 'UICollectionElementKindSectionHeader' the data source dequeued a view registered for the element kind 'A2E5C23F-9496-4722-A001-F258D15C2873

    and this particular code is hit:

    image

    This crash only occurs in iOS15, as the exact code does not crash in iOS14. More details can be found here:

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

    I was able to workaround the issue in my codebase by adding a dummy section header to each section:

    .sectionHeader {
        EmptyView()
    }
    

    I believe this is critical in nature because without action, many apps hitting this codepath will start crashing on September 20 when iOS 15 is made available to the general public.

    opened by sjmueller 10
  • question: automatic height with UICollectionViewFlowLayout

    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
    opened by juliuste 10
  • How to hide/show an ASCollectionViewSection in conditional?

    How to hide/show an ASCollectionViewSection in conditional?

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

    I found we cannot use if in ASCollectionView, how to hide/show an ASCollectionViewSection in conditional?

    ASCollectionView
                {
                    if somecondition {
                        ASCollectionViewSection<Section>(id: .upper, data: self.upperData)
                        { model, _ in
                                GroupLarge(model: model)
                            }
                        }
                  }
    ...
    

    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
    opened by foolbear 9
  • archive error: “xxx-master.dia:1:1: Could not read serialized diagnostics file: Cannot Load File: Failed to open diagnostics file”

    archive error: “xxx-master.dia:1:1: Could not read serialized diagnostics file: Cannot Load File: Failed to open diagnostics file”

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

    I upgraded my xcode to 11.4 yesterday, now I can not archive my SwiftUI code to submit appstore.

    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:

    • 11.4 Swift version 5.2

    Simulator, Device, Both?

    • Where is the problem occuring
    1. Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
    2. While emitting SIL for getter for body (at /path/UI/HomeView.swift:29:9)
    3. While silgen emitFunction SIL function "@$s14StudyCardsPlus8HomeViewV4bodyQrvg". for getter for body (at /path/UI/HomeView.swift:29:9)
    4. While silgen closureexpr SIL function "@$s14StudyCardsPlus8HomeViewV4bodyQrvg7SwiftUI0E0P9FoolToastE04foolJ0QryFQOyAgEE18navigationBarItems8trailingQrqd___tAeFRd__lFQOyAgEE0lM5Title_11displayModeQrAE4TextV_AE010NavigationM4ItemV0p7DisplayR0OtFQOyAgEE5sheet11isPresented9onDismiss7contentQrAE7BindingVySbG_yycSgqd__yctAeFRd__lFQOyAgEE21edgesIgnoringSafeAreayQrAE4EdgeO3SetVFQOyAgEE10background_9alignmentQrqd___AE9AlignmentVtAeFRd__lFQOyAG012ASCollectionE0E20alwaysBounceVerticalyQrSbFQOyAGA9_E13contentInsetsyQrSo12UIEdgeInsetsVFQOyA9_A9_VyAC7SectionOG_Qo__Qo__AE5ColorVQo__Qo__AC0W7ContentQrvpQOy_Qo_Qo__Qo__AC0lM8TrailingQrvpQOy_Qo_Qo__Qo_yXEfU_". for expression at [/path/UI/HomeView.swift:30:24 - line:74:9] RangeText="{ ASCollectionView { ASCollectionViewSection
      (id: .main) { NavigationLink(destination: BooksView()) { BlockItemView(item: .itemBook, count: bookCount) } NavigationLink(destination: CardsView(book: nil)) { BlockItemView(item: .itemCard, count: cardCount) } NavigationLink(destination: TagsView()) { BlockItemView(item: .itemTag, count: tagCount) } } #if PLUSVERSION #else ASCollectionViewSection
      (id: .ad) { FoolGADBannerView(adUnitId: adUnitIdForBannerInHomeView).frame(width: sizeOfGADBanner.width, height: sizeOfGADBanner.height) } #endif ASCollectionViewSection
      (id: .new, data: newItems) { item, state in VStack(spacing: 0) { ListItemView(item: item) { item in self.onNew(item: item) } if !state.isLastInSection { Divider() } } }.sectionHeader { HStack { Text("New Item".localized).font(.headline).bold().foregroundColor(manager.userMode == .edit ? .primary : .gray).padding(); Spacer() } } ASCollectionViewSection
      (id: .userMode) { HStack { Text("Use mode".localized).font(.headline).bold().foregroundColor(.primary).padding() Spacer() Picker(selection: $manager.userMode, label: Text("")) { ForEach(UserMode.allCases) { userMode in Text("(userMode.toString())").tag(userMode) } }.pickerStyle(SegmentedPickerStyle()).frame(maxWidth: 180).padding() } } } .layout(layout) .contentInsets(UIEdgeInsets(top: 20, left: 0, bottom: 20, right: 0)) .alwaysBounceVertical() .background(Color(.systemGroupedBackground)) .edgesIgnoringSafeArea(.all) .sheet(isPresented: $sheetShowing) { self.sheetContent } .navigationBarTitle(Text("Title".localized), displayMode: .inline) .navigationBarItems(trailing: navigationBarTrailing) .foolToast()

    0 swift 0x0000000109ce84ea PrintStackTraceSignalHandler(void*) + 42 1 swift 0x0000000109ce7cc0 SignalHandler(int) + 352 2 libsystem_platform.dylib 0x00007fff6c4485fd _sigtramp + 29 3 swift 0x0000000106a5f4b3 swift::ValueDecl::getEffectiveAccess() const + 1635 4 swift 0x0000000105f221c8 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 12680 5 swift 0x0000000105f1f028 swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 136 6 swift 0x0000000105e9f886 swift::Lowering::Conversion::emit(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::SGFContext) const + 710 7 swift 0x0000000105e4182d (anonymous namespace)::ScalarResultPlan::finish(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, llvm::ArrayRefswift::Lowering::ManagedValue&) + 1021 8 swift 0x0000000105e5cc28 swift::Lowering::SILGenFunction::emitApply(std::__1::unique_ptr<swift::Lowering::ResultPlan, std::__1::default_deleteswift::Lowering::ResultPlan >&&, swift::Lowering::ArgumentScope&&, swift::SILLocation, swift::Lowering::ManagedValue, swift::SubstitutionMap, llvm::ArrayRefswift::Lowering::ManagedValue, swift::Lowering::CalleeTypeInfo const&, swift::Lowering::ApplyOptions, swift::Lowering::SGFContext) + 1784 9 swift 0x0000000105e6a7bf (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3951 10 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 11 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 12 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 13 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 14 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 15 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 16 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 17 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 18 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 19 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 20 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 21 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 22 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 23 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 24 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 25 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 26 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 27 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 28 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 29 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 30 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 31 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 32 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 33 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 34 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 35 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 36 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 37 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 38 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 39 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 40 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 41 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 42 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 43 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 44 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 45 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 46 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 47 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 48 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 49 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 50 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 51 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 52 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 53 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 54 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 55 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 56 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 57 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 58 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 59 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 60 swift 0x0000000105eb9223 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optionalswift::SILLocation) + 131 61 swift 0x0000000105f3dc1d swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 845 62 swift 0x0000000105f392fe swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 12590 63 swift 0x0000000105f36316 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 326 64 swift 0x0000000105ee9ac0 swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 640 65 swift 0x0000000105e52f14 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 244 66 swift 0x0000000105ecd088 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 40 67 swift 0x0000000105e62afb (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 5243 68 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 69 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 70 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 71 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 72 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 73 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 74 swift 0x0000000105e624f5 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3701 75 swift 0x0000000105e5e3b3 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 163 76 swift 0x0000000105e706ce (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238 77 swift 0x0000000105e70549 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapperswift::SILFunctionType, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus) && + 537 78 swift 0x0000000105e6e208 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapperswift::FunctionType&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapperswift::SILFunctionType, llvm::Optionalswift::ForeignErrorConvention const&, swift::ImportAsMemberStatus, llvm::SmallVectorImplswift::Lowering::ManagedValue&, llvm::Optionalswift::SILLocation&, swift::CanTypeWrapperswift::FunctionType&) + 1032 79 swift 0x0000000105e6a6b8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3688 80 swift 0x0000000105e66c47 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2567 81 swift 0x0000000105ebeb9a swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 22410 82 swift 0x0000000105eb9223 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optionalswift::SILLocation) + 131 83 swift 0x0000000105f3dc1d swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 845 84 swift 0x0000000105f392fe swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 12590 85 swift 0x0000000105f36316 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 326 86 swift 0x0000000105ee8fdf swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 799 87 swift 0x0000000105e4f1b9 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 953 88 swift 0x0000000105f4aa18 void llvm::function_ref<void (swift::AccessorDecl*)>::callback_fn<(anonymous namespace)::SILGenType::visitAccessors(swift::AbstractStorageDecl*)::'lambda'(swift::AccessorDecl*)>(long, swift::AccessorDecl*) + 24 89 swift 0x0000000105f4a97c (anonymous namespace)::SILGenType::visitVarDecl(swift::VarDecl*) + 1948 90 swift 0x0000000105f4753b (anonymous namespace)::SILGenType::emitType() + 1163 91 swift 0x0000000105e595e2 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 82 92 swift 0x0000000105e587ac swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 1356 93 swift 0x0000000105e5a88a swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 1530 94 swift 0x0000000105a3c3cb swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 55595 95 swift 0x00000001059b24d3 main + 1283 96 libdyld.dylib 0x00007fff6c24fcc9 start + 1

    opened by foolbear 8
  • Memory Leak when using ASCollectionView

    Memory Leak when using ASCollectionView

    It seems as though the ASCollectionView code has a memory leak. I noticed that anytime I display a ASCollectionView in my app the memory jumps and doesn't come back down when the view disappears. You can see the same behavior in the demo project. The issue occurs on the 1.2.2 release as well as on the current commit on master.

    To Reproduce Remove the caching functionality from the Demo project, you'll see that each time you view the waterfall layout or scroll through the images the memory jumps for each cell displayed and it never comes back down even after leaving the view.

    Expected behaviour When the view is removed from the view hierarchy you should be able to see a drop in memory usage.

    Xcode Version:

    • 11.3

    Simulator, Device, Both? Device

    Resolved 
    opened by mwilsoncricut 7
  • Drag and drop does not work between sections if the destination section is empty

    Drag and drop does not work between sections if the destination section is empty

    Drag and drop does not work between sections if the destination section is empty. It works within the same section and also between sections if the destination section has at least one item.

    I created a on drag and drop event function as shown in one of your examples.

    thanks for looking into this.

    opened by DominikButz 7
  • Feature request: Scroll To Position Programatically (? via Binding)

    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.

    enhancement 
    opened by adamtow 7
  • IOS16: NSInternalInconsistencyException: UICollectionViewLayoutAttributes: -setSize: requires finite dimensions

    IOS16: NSInternalInconsistencyException: UICollectionViewLayoutAttributes: -setSize: requires finite dimensions

    Hello, first of all, thanks a lot for this wonderful library.

    From time to time, i see a random crash log in crashlytics, which i couldn't reproduce on my side whatever i do.

    Fatal Exception: NSInternalInconsistencyException
    UICollectionViewLayoutAttributes: -setSize: requires finite dimensions <UICollectionViewLayoutAttributes: 0x14b2c0140> index path: (1-0); element kind: (groupBackground); frame = (0 377.667; 390 294.333); alpha = 0; - {inf, inf}
    

    the groupBackground is registered like this:

        var collectionViewLayouts:ASCollectionLayout<SeasonScreenSections>{
            let layout =  ASCollectionLayout<SeasonScreenSections>(scrollDirection: .vertical, interSectionSpacing: 0.0,layoutPerSection: {sectionId in
                switch(sectionId){
                case .beatpacks:
                    return SeasonLayoutGenerator.beatpackLayout(columnCount: 2)
                case .spotlight:
                    return SeasonLayoutGenerator.beatpackLayout(columnCount: 1)
                case .creators:
                    return SeasonLayoutGenerator.creatorLayout()
                case .season_header:
                    return SeasonLayoutGenerator.seasonHeaderLayout(height: seasonImgHeight ?? 0)
                }
            }).decorationView(GroupBackground.self, forDecorationViewOfKind: "groupBackground")
            return layout
        }
    

    and GroupBackground is like this:

    struct GroupBackground: View, Decoration
    {
        var body: some View
        {
            Color.gray
        }
    }
    

    Thanks a lot for your time.

    opened by dreampowder 1
  • ASTableView warning (view does not load)

    ASTableView warning (view does not load)

    Describe the bug On first load the tableview works as expected, when switching to another view and going back the view is empty and this is the warning I get: "[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window)."

    To Reproduce

    @EnvironmentObject var hvm: HomeViewModel
    ZStack(alignment: .top) {
                    if self.hvm.moments.isEmpty && !self.isPreparingView {
                        VStack(alignment: .center, spacing: self.viewPadding) {
                            Text("Nothing to see here!")
                                .font(Font.pjsBold(size: 17))
                            Text("Check back later to see your Story Moments.")
                                .font(Font.pjsMedium(size: 16))
                        }
                        .foregroundColor(Color.theme.textLight)
                        .frame(width: geoSize.width, height: geoSize.height)
                    } else if !self.isPreparingView {
                        ASTableView(section: ASTableViewSection(id: 0, data: self.hvm.moments, contentBuilder: { moment, cell in
                            MediaView(showSaveAnimation: self.$showSaveAnimation, currentUserData: self.$currentUserData, moments: self.$hvm.moments, moment: moment, geo: geo, viewPadding: self.viewPadding)
                        }))
                        .onScrollDidEnd({ scrollView, velocity in
                            if velocity.y > 1.5 && self.hvm.momentIndex != (self.hvm.moments.count - 1) {
                                self.hvm.momentIndex += 1
                                self.scrollPosition = .pageDown(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                            } else if velocity.y < -1.5 && self.hvm.momentIndex != 0 {
                                self.hvm.momentIndex -= 1
                                self.scrollPosition = .pageUp(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                            } else {
                                self.scrollPosition = .pageZero(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                            }
                        })
                        .scrollPositionSetter(self.$scrollPosition)
                        .scrollIndicatorEnabled(false)
                        .separatorsEnabled(false)
                        
                        CustomNotifView(showNotifAnimation: self.$showSaveAnimation, imageSystemName: "checkmark", text: "Saved to your moments", notifTimeShown: 1.0, geoSize: geoSize)
                            .frame(width: geoSize.width, height: geoSize.height, alignment: .center)
                    }
                }
                .ignoresSafeArea(.all, edges: .top)
                .onAppear {
                    print(self.hvm.moments)
                    guard self.hvm.moments.isEmpty else {
                        self.scrollPosition = .pageZero(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                        return
                    }
                    if let userLiveStory = self.userLiveStory {
                        self.hvm.getNewLiveMedias(userData: self.currentUserData, userLiveStory: userLiveStory) {
                            self.isPreparingView = false
                            self.scrollPosition = .top
                        }
                    } else {
                        self.udm.getLiveUserStory(userID: self.currentUserData.id) { userLiveStory in
                            guard let userLiveStory = userLiveStory else { return }
                            self.userLiveStory = userLiveStory
                            self.hvm.getNewLiveMedias(userData: self.currentUserData, userLiveStory: userLiveStory) {
                                self.isPreparingView = false
                                self.scrollPosition = .top
                            }
                        }
                    }
                }
    

    Expected behaviour I expect the view to show the original view after switching back since the data is store in an environmentobject. (cacheCells() does not work)

    Xcode Version:

    • 13.3

    Simulator, Device, Both?

    • device
    opened by trevordevelops 0
  • Keep Showing Hidden Navbar

    Keep Showing Hidden Navbar

    Describe the bug I was hide the navigation bar, but when I use ASCollectionView to showing a grid. the hidden navigation bar is force showing

    To Reproduce Steps to reproduce the behaviour: Wrap a collection view with navigation bar and hide the nabber

    Expected behaviour Collection showing without navbar

    opened by gusadi09 0
  • Unable to set scroll position of a cell

    Unable to set scroll position of a cell

    Using ASCollectionView, I want to be able to set the scrolllposition of a cell and save it so the view does not lose its position when switching to another view. So far I can only set it to top, bottom, etc. and not a specific cell. Is this even possible?

    opened by trevordevelops 0
  • The operation couldn’t be completed. (SwiftPM.SPMRepositoryError error 3.)

    The operation couldn’t be completed. (SwiftPM.SPMRepositoryError error 3.)

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

    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
    opened by wisepmlin 0
Releases(2.1.1)
  • 2.1.1(Sep 22, 2021)

    • This contains fixes for some undocumented extra checks introduced in iOS15 on supplementary views that caused some crashes.
    • Fix some SwiftUI warnings for AttributeGraphCycle (thanks @robertjpayne)
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Jun 26, 2021)

    Fix a subtle bug affecting animation/appearance of cells on reuse (thanks @andersio) Add support for disabling keyboard handling on ASTableView (thanks @diegostamigni)

    Source code(tar.gz)
    Source code(zip)
  • 1.7.1(Jun 3, 2020)

    • Workaround for SwiftUI bug (viewDidAppear not being called when nested in ScrollView)

    V1.7.0:

    • Add support for setting scrollPosition through binding (Fix #89)
    • Improve function builders, support for unlimited number of static views, support for arrays
    • Improve default self-sizing settings
    • Support for automatic keyboard avoidance
    • Fix for layoutSubviews cycle in certain animation conditions (Fix #149)
    Source code(tar.gz)
    Source code(zip)
  • 1.7.0(Jun 2, 2020)

    • Add support for setting scrollPosition through binding (Fix #89)
    • Improve function builders, support for unlimited number of static views, support for arrays
    • Improve default self-sizing settings
    • Support for automatic keyboard avoidance
    • Fix for layoutSubviews cycle in certain animation conditions (Fix #149)
    Source code(tar.gz)
    Source code(zip)
  • 1.6.3(May 3, 2020)

    • New diffing algorithm: now uses DifferenceKit diffing for improved performance and flexibility
    • New drag&drop implementation (see demo project → photoGrid screen, tableview drag&drop screen)
    • Fix drag & drop on 13.4 (work around SwiftUI bug preventing drop)
    • UIContextMenu support for ASTableView
    • Cache supplementary views
    • Refactor code behind the scenes
    • Fix for tableView self-sizing (sometimes cells would be too large)
    • Fixes a bug related to cell-recycling in 1.6.2
    Source code(tar.gz)
    Source code(zip)
  • 1.6.2(May 2, 2020)

    • New diffing algorithm: now uses DifferenceKit diffing for improved performance and flexibility
    • New drag&drop implementation (see demo project → photoGrid screen, tableview drag&drop screen)
    • Fix drag & drop on 13.4 (work around SwiftUI bug preventing drop)
    • UIContextMenu support for ASTableView
    • Cache supplementary views
    • Refactor code behind the scenes
    • Fix for tableView self-sizing (sometimes cells would be too large)
    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Apr 30, 2020)

    • New diffing algorithm: now uses DifferenceKit diffing for improved performance and flexibility
    • New drag&drop implementation (see demo project → photoGrid screen, tableview drag&drop screen)
    • Fix drag & drop on 13.4 (work around SwiftUI bug preventing drop)
    • UIContextMenu support for ASTableView
    • Cache supplementary views
    • Refactor code behind the scenes
    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Apr 30, 2020)

    • New diffing algorithm: now uses DifferenceKit diffing for improved performance and flexibility
    • New drag&drop implementation (see demo project → photoGrid screen, tableview drag&drop screen)
    • Fix drag & drop on 13.4 (work around SwiftUI bug preventing drop)
    • UIContextMenu support for ASTableView
    • Cache supplementary views
    • Refactor code behind the scenes
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Apr 5, 2020)

    • Fix ASTableView header/footer updating
    • Add support for onScroll modifier.
    • CODE BREAKING: Replace environment modifiers with direct functions (work around Swift 5.2 compiler bug) → Note: many modifiers have been renamed slightly (eg .collectionViewContentInsets().contentInsets(...)) → Note: the new modifiers must precede any swiftUI modifiers (eg .disableSeparators() must come before .frame(...))
    • Add support for optional section in SectionBuilder (function builder)
    Source code(tar.gz)
    Source code(zip)
  • 1.4.2(Mar 31, 2020)

    • Reintroduces automatic cell-caching for improved performance
    • Improve tableview cell resizing (on invalidateLayout call)
    • Move canExceedCollectionSize to SelfSizingConfig (instead of environment)
    • Fix lingering cell refresh issues
    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Mar 31, 2020)

  • 1.4.0(Mar 29, 2020)

    • Improve automatic cell-caching so that on-screen cells are not needlessly recreated
    • Improve shrinkToSize support, no longer requiring a binding
    • Changed selection API to be on a per-section basis. Refer to the Waterfall demo page to see an example of how to track this across many sections.
    • Add support for shouldAllowSelection and shouldAllowDeselection → fix #115
    • Add a PodSpec (cocoapods support). Thanks @kerrmarin
    Source code(tar.gz)
    Source code(zip)
  • 1.3.2(Mar 16, 2020)

    This version changes some cell lifecycle code under the hood to improve performance. It is a known issue that some environment objects are not correctly passed down to the cells, this is a SwiftUI bug; The workaround is to pass the environment objects directly when defining the contents of your section.

    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Mar 10, 2020)

    • Implement cacheCells modifier to allow for marking sections that should be cached even when moving off screen (eg. for nested collectionViews)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Mar 5, 2020)

    • Allow to disable default animation on data refresh (#87 thanks @cederache)
      • note that animation is now disabled by default
    • Improve self-sizing config options + Add support for constraining cells to fit within contentSize of collectionView
    • Improve sectionBuilder function-builder (fix #97)
    • Add support for UIContextMenuConfiguration (fix #77)
    • Support for section headers in ASWaterfallLayout
    • Add perSection configuration support to ASWaterfallLayout
    • Workaround for bug where SwiftUI does not add the view controller to a parent
    • Add pullToRefresh to collectionView (#107 thanks @cederache)
    • Fix a number of leaks due to closure implicit captures
    Source code(tar.gz)
    Source code(zip)
  • 1.2.2(Jan 6, 2020)

    • Make ASCollectionView importable by old projects ( Thanks to @grangej )
    • Minor bug-fixes
    • ASTableView support for OnPullToRefresh, OnSwipeToDelete
    • Fix static section content reloading
    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Jan 1, 2020)

    • Add support for onReachedBoundary closure
    • Improve initial loading of data
    • Implement DataSource support for RandomAccessCollection (allows use of FetchedResults directly)
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jan 1, 2020)

    • Add support for onReachedBoundary closure
    • Improve initial loading of data
    • Implement DataSource support for RandomAccessCollection (allows use of FetchedResults directly)
    Source code(tar.gz)
    Source code(zip)
  • 1.1.6(Nov 26, 2019)

    • Maintain scroll position on orientation change
    • Add option for initialScrollPosition
    • Add support for shrinking the collectionView to fit its content
    Source code(tar.gz)
    Source code(zip)
  • 1.1.5(Nov 13, 2019)

  • 1.1.4(Nov 11, 2019)

  • 1.1.3(Nov 10, 2019)

  • 1.1.2(Nov 8, 2019)

  • 1.1.1(Nov 6, 2019)

  • 1.1.0(Nov 6, 2019)

    NOTE: This breaks some code that was valid in V1.0 (too soon to be strictly semantic and jump to 2.0)

    • This version improves upon the layout syntax to greatly simplify its use.
    • This version provides a function that custom delegates can use to access underlying data for a particular index path (eg. to make use of sizing data stored in the model)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Nov 5, 2019)

  • 0.9.3(Oct 22, 2019)

  • 0.9.2(Oct 20, 2019)

Owner
Apptek Studios
Australian based developer 🇦🇺 Have my open source repos been useful to you? buymeacoffee.com/tobeasbrennan
Apptek Studios
A custom paging behavior that peeks the previous and next items in a collection view

MSPeekCollectionViewDelegateImplementation Version 3.0.0 is here! ?? The peeking logic is now done using a custom UICollectionViewLayout which makes i

Maher Santina 353 Dec 16, 2022
Lightweight custom collection view inspired by Airbnb.

ASCollectionView Lightweight custom collection view inspired by Airbnb. Screenshots Requirements ASCollectionView Version Minimum iOS Target Swift Ver

Abdullah Selek 364 Nov 24, 2022
Generic collection view controller with external data processing

FlexibleCollectionViewController Swift library of generic collection view controller with external data processing of functionality, like determine ce

Dmytro Pylypenko 3 Jul 16, 2018
A component to quickly scroll between collection view sections

SectionScrubber The scrubber will move along when scrolling the UICollectionView it has been added to. When you pan the scrubber you 'scrub' over the

Elvis 190 Aug 17, 2022
Easy and type-safe iOS table and collection views in Swift.

Quick Start TL;DR? SimpleSource is a library that lets you populate and update table views and collection views with ease. It gives you fully typed cl

Squarespace 96 Dec 26, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 157 Nov 25, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 155 May 12, 2022
TLIndexPathTools is a small set of classes that can greatly simplify your table and collection views.

TLIndexPathTools TLIndexPathTools is a small set of classes that can greatly simplify your table and collection views. Here are some of the awesome th

SwiftKick Mobile 347 Sep 21, 2022
This component allows for the transfer of data items between collection views through drag and drop

Drag and Drop Collection Views Written for Swift 4.0, it is an implementation of Dragging and Dropping data across multiple UICollectionViews. Try it

Michael Michailidis 508 Dec 19, 2022
Modern Collection Views

The goal is to showcase different compositional layouts and how to achieve them. Feel free to use any code you can find and if you have interesting layout idea - open PR!

Filip Němeček 536 Dec 28, 2022
A Swift mixin for reusing views easily and in a type-safe way (UITableViewCells, UICollectionViewCells, custom UIViews, ViewControllers, Storyboards…)

Reusable A Swift mixin to use UITableViewCells, UICollectionViewCells and UIViewControllers in a type-safe way, without the need to manipulate their S

Olivier Halligon 2.9k Jan 3, 2023
Custom CollectionViewLayout class for CollectionView paging mode to work properly

PagingCollectionViewLayout About How to use About ⚠️ Custom class, which is inherited from UICollectionViewFlowLayout, developed for properly work Col

Vladislav 2 Jan 17, 2022
A modest attempt to port UICollectionView to SwiftUI.

LazyCollectionView A modest attempt to port UICollectionView to SwiftUI. Table of Contents Description Requirements Installation Usage Components Impr

Unsplash 109 Dec 27, 2022
An iOS drop-in UITableView, UICollectionView and UIScrollView superclass category for showing a customizable floating button on top of it.

MEVFloatingButton An iOS drop-in UITableView, UICollectionView, UIScrollView superclass category for showing a customizable floating button on top of

Manuel Escrig 298 Jul 17, 2022
Automates prefetching of content in UITableView and UICollectionView

Automates preheating (prefetching) of content in UITableView and UICollectionView. Deprecated on iOS 10. This library is similar to UITableViewDataSou

Alexander Grebenyuk 633 Sep 16, 2022
A data-driven UICollectionView framework for building fast and flexible lists.

A data-driven UICollectionView framework for building fast and flexible lists. Main Features ?? Never call performBatchUpdates(_:, completion:) or rel

Instagram 12.5k Jan 1, 2023
Netflix and App Store like UITableView with UICollectionView, written in pure Swift 4.2

GLTableCollectionView Branch Status master develop What it is GLTableCollectionView is a ready to use UITableViewController with a UICollectionView fo

Giulio 708 Nov 17, 2022
Incremental update tool to UITableView and UICollectionView

EditDistance is one of the incremental update tool for UITableView and UICollectionView. The followings show how this library update UI. They generate

Kazuhiro Hayashi 90 Jun 9, 2022
PJFDataSource is a small library that provides a simple, clean architecture for your app to manage its data sources while providing a consistent user interface for common content states (i.e. loading, loaded, empty, and error).

PJFDataSource PJFDataSource is a small library that provides a simple, clean architecture for your app to manage its data sources while providing a co

Square 88 Jun 30, 2022