ViGridSearchViewController
open class ViGridSearchViewController: ViBaseSearchViewController , ViFilterViewControllerDelegate
Display search results in a grid
This is the base class for Find Similar
, Search By Color
, Search By Image
widgets (ViFindSimilarViewController, ViColorSearchViewController, ViSearchImageViewController)
The products are layouted using collectionView flow layout which will push product items to the next line based on the item size
-
store the header layout height of collection view The header includes the query product (for Find Similar), the color preview box (for color search) , image preview box (for search by image)
Declaration
Swift
public var headerLayoutHeight : CGFloat = 0
-
store the filter configuration and also selected filter options
Declaration
Swift
open var filterItems : [ViFilterItem] = []
-
Undocumented
Declaration
Swift
open class ViGridSearchViewController: ViBaseSearchViewController , ViFilterViewControllerDelegate
-
title for filter controller
Declaration
Swift
open var filterControllerTitle : String = "Filter by"
-
Disable the static header of parent class. This is different from headerLayoutHeight which is refering to the header within collectionView
Declaration
Swift
open var headerLayout : Layout?
-
product card item size
Declaration
Swift
public override var itemSize: CGSize
-
spacing between rows
Declaration
Swift
public var rowSpacing : CGFloat = 4.0
-
calculate and set item width (for product card) constrained within view.bounds.width The items will display nicely within the specified number of columns after setting Note: if the view is not yet displayed and self.view.bounds.width is 0, no action will be taken
Parameter
Parameter numOfColumns: number of columnsDeclaration
Swift
public func setItemWidth(numOfColumns : Int)
Parameters
numOfColumns
number of columns
-
calculate and set item width (for product card) constrained within containerWidth The items will display nicely within the specified number of columns after setting
Parameter
Parameter numOfColumns: number of columnsParameter
Parameter containerWidth: width of the containerDeclaration
Swift
public func setItemWidth(numOfColumns : Int, containerWidth: CGFloat)
Parameters
numOfColumns
number of columns
containerWidth
width of the container
-
Refers to setItemWidth
Parameter
Parameter numOfColumns: number of columns to fit inDeclaration
Swift
public func recalculateItemWidth(numOfColumns : Int)
Parameters
numOfColumns
number of columns to fit in
-
Estimate item width for given number of columns and max width of container The items will display nicely within the specified number of columns if set to the estimated width
- Parameters:
- numOfColumns: number of columns
- containerWidth: container width e.g. self.view.bounds. Must be > 0.
Returns
estimated widthDeclaration
Swift
open func estimateItemWidth(numOfColumns : Int , containerWidth: CGFloat ) -> CGFloat
Parameters
numOfColumns
number of columns
containerWidth
container width e.g. self.view.bounds. Must be > 0.
Return Value
estimated width
- Parameters:
-
Refers to estimateItemWidth(numOfColumns : Int , containerWidth: CGFloat ) Helper method which set containerWidth to self.view.bounds.width. Note: will not work if self.view.bounds.width = 0
Parameter
Parameter numOfColumns: number of columnsReturns
estimated item widthDeclaration
Swift
open func estimateItemWidth(numOfColumns : Int ) -> CGFloat
Parameters
numOfColumns
number of columns
Return Value
estimated item width
-
Estimate item size so that it can fit within specified number of columns, constrained to containerWidth
- Parameters:
- numOfColumns: number of columns
- containerWidth: container width
Returns
item sizeDeclaration
Swift
open func estimateItemSize(numOfColumns: Int, containerWidth: CGFloat ) -> CGSize
Parameters
numOfColumns
number of columns
containerWidth
container width
Return Value
item size
- Parameters:
-
Configure layout as vertical layout
Declaration
Swift
open override func reloadLayout()
-
Undocumented
Declaration
Swift
open class ViGridSearchViewController: ViBaseSearchViewController , ViFilterViewControllerDelegate
-
Undocumented
Declaration
Swift
open class ViGridSearchViewController: ViBaseSearchViewController , ViFilterViewControllerDelegate
-
Generate layout for Power By ViSenze image
Returns
layoutDeclaration
Swift
public func getPowerByVisenzeLayout() -> Layout
Return Value
layout
-
Generate gray divider
Returns
layoutDeclaration
Swift
public func getDividerLayout() -> Layout
Return Value
layout
-
generate the layout for number of searched products and filter button at the right
Declaration
Swift
open func getLabelAndFilterLayout(emptyProductsTxt: String = "Products Found", displayStringFormat: String = "%d Products Found" ) -> Layout
-
Action taken when user tapped on filter button This will open the filter view controller
- Parameters:
- sender: filter button
- event: button event
Declaration
Swift
open func filterBtnTap(sender: UIButton, forEvent event: UIEvent)
Parameters
sender
filter button
event
button event
- Parameters:
-
need to be implemented by subclass Triggered when user taps on
Done
button for the Filter controller The filter parameters will be applied and a new search is triggeredDeclaration
Swift
open func applyFilter(_ filterItems : [ViFilterItem])
-
call back when filter is reset
Declaration
Swift
open func resetFilter()
-
Set the filter query parameters before calling search API
Declaration
Swift
open func setFilterQueryParamsForSearch()
-
Undocumented
Declaration
Swift
open class ViGridSearchViewController: ViBaseSearchViewController , ViFilterViewControllerDelegate
-
Undocumented
Declaration
Swift
open class ViGridSearchViewController: ViBaseSearchViewController , ViFilterViewControllerDelegate