ViHorizontalSearchViewController

open class ViHorizontalSearchViewController: ViBaseSearchViewController

Display the search results in a horizontal scroll view This is used currently by You May Also Like widget i.e. ViRecommendationViewController

  • Given the number of visible items (products) to appear on the containerWidth, return the estimated item width The items are displayed in a horizontal scroll view. The width of the visible rectange is containerWidth. The scroll view contain size may be much larger than containerWidth We want a number of items (itemsVisibleOnContainerCount) to be shown in the visible rectange

  • Parameters:

    • itemsVisibleOnContainerCount: number of items visible on container e.g. 2.5 mean 2 items will appear on screen + half partial item will show
    • containerWidth: container width e.g. self.view.bounds
  • Returns

    estimated width for an item i.e. a product card

    Declaration

    Swift

    open func estimateItemWidth(_ itemsVisibleOnContainerCount : CGFloat , containerWidth: CGFloat) -> CGFloat

    Parameters

    itemsVisibleOnContainerCount

    number of items visible on container e.g. 2.5 mean 2 items will appear on screen + half partial item will show

    containerWidth

    container width e.g. self.view.bounds

    Return Value

    estimated width for an item i.e. a product card

  • Given the number of visible items (products) to appear on this view, return the estimated item width The items are displayed in a horizontal scroll view. The width of the visible rectange is self.view.bounds.width. We want a number of items (itemsVisibleOnContainerCount) to be shown in the visible rectange Note: this method will return 0 if the current view controller is not yet displayed i.e. view.bounds.width is 0

    Parameter

    Parameter itemsVisibleOnContainerCount: number of items visible on container e.g. 2.5 mean 2 items will appear on screen + half partial item will show

    Returns

    estimated width for an item

    Declaration

    Swift

    open func estimateItemWidth(_ itemsVisibleOnContainerCount : CGFloat ) -> CGFloat

    Parameters

    itemsVisibleOnContainerCount

    number of items visible on container e.g. 2.5 mean 2 items will appear on screen + half partial item will show

    Return Value

    estimated width for an item

  • reload layout.. configure layout as a horizontal layout

    Declaration

    Swift

    open override func reloadLayout()