Grid

public class Grid<D> : ScrollView

Wrapper of UICollectionView An object that manages an ordered collection of data items and presents them using customizable layouts.

Example:

     struct GridView: View {

         @DataSource var dataSource: [Model] = [Model]()
         @DataSource var headerDataSource: [Model] = [Model]()
         @DataSource var footerDataSource: [Model] = [Model]()

         var body: View {

             Grid(data:$dataSource){ data in
                 Item(data)
             }
             .sectionHeader($headerDataSource) { data in
                 Header(data)
             }
             .sectionFooter($footerDataSource) { data in
                 Footer(data)
             }
             .cellSelected { (data, index) in
                 // Did Select item action
             }
         }

         func appendData(data: Model) {
             models.append(data)
             $dataSource.apply()
         }
     }
  • Initializer

         Grid {
             Item1()
             Item2()
             Item3()
         }
    

    Declaration

    Swift

    public convenience init(waterfall: Bool = false, @ArgoKitListBuilder content: @escaping () -> View) where D : ArgoKitNode

    Parameters

    waterfall

    Whether the grid syle is waterfall.

    content

    The content of the grid.

  • Initializer

         Grid(data: $dataSource) { item in
             Item(item)
         }
    

    Declaration

    Swift

    public convenience init(waterfall: Bool =  false,
                            data: DataSource<DataList<D>>,
                            @ArgoKitListBuilder itemContent: @escaping (D) -> View)

    Parameters

    waterfall

    Whether the grid syle is waterfall.

    data

    The data for populating the grid.

    itemContent

    A view builder that creates the view for a single item of the grid.

  • Initializer

         Grid(data: $sectionDataSource) { item in
             Item(item)
         }
    

    Declaration

    Swift

    public convenience init(waterfall:Bool = false,
                            data: DataSource<SectionDataList<D>>,
                            @ArgoKitListBuilder itemContent: @escaping (D) -> View)

    Parameters

    waterfall

    Whether the grid syle is waterfall.

    data

    The section data for populating the grid.

    itemContent

    A view builder that creates the view for a single item of the grid.

  • The view that is displayed in the header of the specified section of the grid.

    Declaration

    Swift

    @discardableResult
    public func sectionHeader(@ArgoKitListBuilder headerContent: @escaping () -> View) -> Self

    Parameters

    headerContent

    A view builder that creates the view for section header.

    Return Value

    Self

  • The view that is displayed in the header of the specified section of the grid.

    Declaration

    Swift

    @discardableResult
    public func sectionHeader(data: DataSource<DataList<D>>, @ArgoKitListBuilder headerContent: @escaping (D) -> View) -> Self

    Parameters

    data

    The data for populating the section header.

    headerContent

    A view builder that creates the view for section header.

    Return Value

    Self

  • The view that is displayed in the footer of the specified section of the grid.

    Declaration

    Swift

    @discardableResult
    public func sectionFooter(@ArgoKitListBuilder footerContent: @escaping () -> View) -> Self

    Parameters

    footerContent

    A view builder that creates the view for section footer.

    Return Value

    Self

  • The view that is displayed in the footer of the specified section of the grid.

    Declaration

    Swift

    @discardableResult
    public func sectionFooter(data: DataSource<DataList<D>>, @ArgoKitListBuilder footerContent: @escaping (D) -> View) -> Self

    Parameters

    data

    The data for populating the section footer.

    footerContent

    A view builder that creates the view for section footer.

    Return Value

    Self

  • Sets a Boolean value that controls whether users enable move item.

    Declaration

    Swift

    @discardableResult
    public func enableMoveItem(_ value: Bool) -> Self

    Parameters

    value

    A Boolean value that controls whether users enable move item.

    Return Value

    Self

  • Scrolls the grid contents until the specified item is visible.

    Declaration

    Swift

    @discardableResult
    public func scrollToItem(indexPath: IndexPath, scrollposition: UICollectionView.ScrollPosition, animated: Bool) -> Self

    Parameters

    indexPath

    The index path of the item to scroll into view.

    scrollposition

    An option that specifies where the item should be positioned when scrolling finishes. For a list of possible values, see UICollectionView.ScrollPosition.

    animated

    Specify true to animate the scrolling behavior or false to adjust the scroll view’s visible content immediately.

    Return Value

    Self

  • Scrolls a specific area of the content so that it is visible in the receiver.

    Declaration

    Swift

    @discardableResult
    public func scrollToItem(rect: CGRect, animated: Bool) -> Self

    Parameters

    rect

    A rectangle defining an area of the content view. The rectangle should be in the coordinate space of the scroll view.

    animated

    true if the scrolling should be animated, false if it should be immediate.

    Return Value

    Self

  • Sets a Boolean value that indicates whether users can select items in the grid.

    Declaration

    Swift

    @discardableResult
    public func allowsSelection(_ value: Bool) -> Self

    Parameters

    value

    A Boolean value that indicates whether users can select items in the grid.

    Return Value

    Self

  • Undocumented

    Declaration

    Swift

    public func allowsSelection() -> Bool
  • Sets a Boolean value that determines whether users can select more than one item in the grid.

    Declaration

    Swift

    @discardableResult
    public func allowsMultipleSelection(_ value: Bool) -> Self

    Parameters

    value

    A Boolean value that determines whether users can select more than one item in the grid.

    Return Value

    Self

  • Undocumented

    Declaration

    Swift

    public func allowsMultipleSelection() -> Bool
  • Undocumented

    Declaration

    Swift

    @discardableResult
    public func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionView.ScrollPosition) -> Self
  • Undocumented

    Declaration

    Swift

    @discardableResult
    public func deselectItem(at indexPath: IndexPath, animated: Bool) -> Self
  • Sets a Boolean value that determines whether the grid is in editing mode.

    Declaration

    Swift

    @available(iOS 14.0, *)
    @discardableResult
    public func editing(_ value: Bool) -> Self

    Parameters

    value

    A Boolean value that determines whether the grid is in editing mode.

    Return Value

    Self

  • Undocumented

    Declaration

    Swift

    public func isEditing() -> Bool
  • Sets a Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content.

    Declaration

    Swift

    @discardableResult
    public func bounceVertical(_ value: Bool) -> Self

    Parameters

    value

    A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content.

    Return Value

    Self

  • Sets a Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.

    Declaration

    Swift

    @discardableResult
    public func bounceHorizontal(_ value: Bool) -> Self

    Parameters

    value

    A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.

    Return Value

    Self

  • To enable intra-app drags on iPhone, set this to YES. You can also force drags to be disabled for this collection view by setting this to NO. By default, For iPad this will return YES and iPhone will return NO.

    Declaration

    Swift

    @discardableResult
    public func dragInteractionEnabled(_ value: Bool) -> Self

    Return Value

    Self

  • Reordering cadence affects how easily reordering occurs while dragging around a reorder-capable drop destination. Default is UICollectionViewReorderingCadenceImmediate.

    Declaration

    Swift

    @discardableResult
    public func reorderingCadence(_ value: Bool) -> Self

    Return Value

    Self

action observer

  • Setshe cell’s background color.

    Declaration

    Swift

    @discardableResult
    public func cellBackgroudColor(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> UIColor) -> Self

    Parameters

    action

    Return Value

    Self

  • Sets the action that handle the item at the specified index path was selected.

    Declaration

    Swift

    @discardableResult
    public func cellItemWith(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> CGFloat) -> Self

    Parameters

    action

    The action that handle the item at the specified index path was selected.

    Return Value

    Self

  • Sets the action that handle the item at the specified index path was selected.

    Declaration

    Swift

    @discardableResult
    public func cellSelected(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the item at the specified index path was selected.

    Return Value

    Self

  • Sets the action that handle the item at the specified path was deselected.

    Declaration

    Swift

    @discardableResult
    public func cellDeselected(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the item at the specified path was deselected.

    Return Value

    Self

  • Sets the action that handle the specified cell is about to be displayed in the grid.

    Declaration

    Swift

    public func cellWillAppear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the specified cell is about to be displayed in the grid.

    Return Value

    Self

  • Sets the action that handle the specified cell was removed from the grid.

    Declaration

    Swift

    public func cellDidDisappear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the specified cell was removed from the grid.

    Return Value

    Self

  • Sets the action that handle the specified header view is about to be displayed in the grid.

    Declaration

    Swift

    public func headerWillAppear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the specified cell is about to be displayed in the grid.

    Return Value

    Self

  • Sets the action that handle the specified header view was removed from the grid.

    Declaration

    Swift

    public func headerDidDisappear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the specified cell was removed from the grid.

    Return Value

    Self

  • Sets the action that handle the specified footer view is about to be displayed in the grid.

    Declaration

    Swift

    public func footerWillAppear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the specified cell is about to be displayed in the grid.

    Return Value

    Self

  • Sets the action that handle the specified footer view was removed from the grid.

    Declaration

    Swift

    public func footerDidDisappear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self

    Parameters

    action

    The action that handle the specified cell was removed from the grid.

    Return Value

    Self

  • Sets the action that handle the item at the specified index path was highlighted.

    Declaration

    Swift

    public func cellDidHighlight(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> UIColor?) -> Self

    Parameters

    action

    The action that handle the item at the specified index path was highlighted.

    Return Value

    Self

  • Sets the action that handle the highlight was removed from the item at the specified index path.

    Declaration

    Swift

    public func cellDidUnhighlight(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> UIColor?) -> Self

    Parameters

    action

    The action that handle the highlight was removed from the item at the specified index path.

    Return Value

    Self

  • Asks the delegate if an action menu should be displayed for the specified item.

    Declaration

    Swift

    @available(iOS, introduced: 5.0, deprecated: 13.0)
    @discardableResult
    public func shouldShowMenu(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Asks the delegate if it can perform the specified action on an item in the grid.

    Declaration

    Swift

    @available(iOS, introduced: 5.0, deprecated: 13.0)
    @discardableResult
    public func canPerformAction(_ action: @escaping (_ action: Selector, _ data: D, _ indexPath: IndexPath, _ sender: Any?) -> Bool) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Sets the action that handle perform the specified action on an item in the grid.

    Declaration

    Swift

    @available(iOS, introduced: 5.0, deprecated: 13.0)
    @discardableResult
    public func performAction(_ action: @escaping (_ action: Selector, _ data: D, _ indexPath: IndexPath, _ sender: Any?) -> Void) -> Self

    Parameters

    action

    The action that handle perform the specified action on an item in the grid.

    Return Value

    Self

  • Asks the data source to return the titles for the index items to display for the grid.

    Declaration

    Swift

    @discardableResult
    public func indexTitles(_ action: @escaping () -> [String]?) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Asks the data source to return the index path of a grid item that corresponds to one of your index entries.

    Declaration

    Swift

    @discardableResult
    public func indexPathForIndexTitle(_ action: @escaping (_ title: String, _ index: Int) -> IndexPath) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Asks the delegate if it can perform the specified action on an item in the grid.

    Declaration

    Swift

    @discardableResult
    public func itemsCancelPrefetching(_ action: @escaping (_ indexPaths: [IndexPath]) -> Void) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Sets the action that handle perform the specified action on an item in the grid.

    Declaration

    Swift

    @discardableResult
    public func itemsPrefetch(_ action: @escaping (_ indexPaths: [IndexPath]) -> Void) -> Self

    Parameters

    action

    The action that handle perform the specified action on an item in the grid.

    Return Value

    Self

  • Asks the delegate whether the cell at the specified index path is itself focusable.

    Declaration

    Swift

    @discardableResult
    public func cellCanFocus(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Asks the delegate whether the focus update specified by the context is allowed to occur.

    Declaration

    Swift

    @discardableResult
    public func shouldUpdateFocus(_ action: @escaping (_ context: UITableViewFocusUpdateContext) -> Bool) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self

  • Sets the action that handle a focus update specified by the context has just occurred.

    Declaration

    Swift

    @discardableResult
    public func didUpdateFocus(_ action: @escaping (_ context: UITableViewFocusUpdateContext, _ coordinator: UIFocusAnimationCoordinator) -> Void) -> Self

    Parameters

    action

    The action that handle a focus update specified by the context has just occurred.

    Return Value

    Self

  • Asks the delegate for the list’s index path for the preferred focused view.

    Declaration

    Swift

    @discardableResult
    public func indexPathForPreferredFocusedView(_ action: @escaping () -> IndexPath?) -> Self

    Parameters

    action

    Result of the ask.

    Return Value

    Self