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
numOfColumnsnumber 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
numOfColumnsnumber of columns
containerWidthwidth of the container
-
Refers to setItemWidth
Parameter
Parameter numOfColumns: number of columns to fit inDeclaration
Swift
public func recalculateItemWidth(numOfColumns : Int)Parameters
numOfColumnsnumber 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 ) -> CGFloatParameters
numOfColumnsnumber of columns
containerWidthcontainer 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 ) -> CGFloatParameters
numOfColumnsnumber 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 ) -> CGSizeParameters
numOfColumnsnumber of columns
containerWidthcontainer 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() -> LayoutReturn Value
layout
-
Generate gray divider
Returns
layoutDeclaration
Swift
public func getDividerLayout() -> LayoutReturn 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
senderfilter button
eventbutton 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
View on GitHub
ViGridSearchViewController Class Reference