ViBaseSearchViewController
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
Base controller for all search widgets
-
search client for making API requests. if not set, will use the default client in ViSearch.sharedInstance
Declaration
Swift
public var searchClient: ViSearchClient? = nil
-
reuse identifer for header collection view cell
Declaration
Swift
public let headerCollectionViewCellReuseIdentifier = "ViHeaderReuseCellId"
-
collection view that holds the search results
Declaration
Swift
public var collectionView : UICollectionView?
-
associated collection view layout
Declaration
Swift
public var collectionViewLayout: UICollectionViewLayout
-
title label. Used for displaying the widget title in header view Currently this is only used for
You May Also Like
widgetDeclaration
Swift
public var titleLabel : UILabel?
-
show/hide the title label in header
Declaration
Swift
public var showTitleHeader: Bool = true
-
delegate for various events
Declaration
Swift
public weak var delegate: ViSearchViewControllerDelegate?
-
last known successful search request Id to Visenze API
Declaration
Swift
public var reqId : String? = ""
-
search parameters
Declaration
Swift
public var searchParams: ViBaseSearchParams? = nil
-
schema mappings to UI elements
Declaration
Swift
public var schemaMapping: ViProductSchemaMapping = ViProductSchemaMapping()
-
UI settings Configuration for product image
Declaration
Swift
public var imageConfig: ViImageConfig = ViImageConfig()
-
Configuration for heading view e.g. for displaying product tile
Declaration
Swift
public var headingConfig: ViLabelConfig = ViLabelConfig.default_heading_config
-
Configuring for label view e.g. displaying brand in label
Declaration
Swift
public var labelConfig: ViLabelConfig = ViLabelConfig.default_label_config
-
Configuration for product price
Declaration
Swift
public var priceConfig: ViLabelConfig = ViLabelConfig.default_price_config
-
Configuration for discount price
Declaration
Swift
public var discountPriceConfig: ViLabelConfig = ViLabelConfig.default_discount_price_config
-
true if similar button (at bottom right) is available for a product card in search results
Declaration
Swift
public var hasSimilarBtn: Bool = true
-
Configuration for similar button if available
Declaration
Swift
public var similarBtnConfig: ViButtonConfig = ViButtonConfig.default_similar_btn_config
-
true if action button (at top right) is available for a product card in search results The default action button is the heart icon with add to wish list action tracked when tapped
Declaration
Swift
public var hasActionBtn: Bool = true
-
Configuration for action button if available
Declaration
Swift
public var actionBtnConfig: ViButtonConfig = ViButtonConfig.default_action_btn_config
-
background color for a product card in the search results
Declaration
Swift
public var productCardBackgroundColor: UIColor = ViTheme.sharedInstance.default_product_card_background_color
-
product card border color. Default to no border
Declaration
Swift
public var productCardBorderColor: UIColor? = nil
-
product card border width. Default to 0 for no border
Declaration
Swift
public var productCardBorderWidth : CGFloat = 0
-
which border(s) to draw for the product card by default all borders are drawn
Declaration
Swift
public var productBorderStyles : [ViBorderType] = [.LEFT , .RIGHT , .BOTTOM , .TOP]
-
show/hide Power by Visenze image
Declaration
Swift
public var showPowerByViSenze : Bool = true
-
extract products data from ViSenze API response
Declaration
Swift
public var products: [ViProduct] = []
-
product card size
Declaration
Swift
public var itemSize: CGSize = CGSize(width: 1, height: 1)
-
Spacing between product items on same row
Declaration
Swift
public var itemSpacing : CGFloat = 4.0
-
view background color
Declaration
Swift
public var backgroundColor : UIColor = UIColor.white
-
left padding
Declaration
Swift
public var paddingLeft: CGFloat = 0
-
right padding
Declaration
Swift
public var paddingRight: CGFloat = 0
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
Undocumented
Declaration
Swift
open class ViBaseSearchViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ViSearchViewControllerProtocol, ViProductCellDelegate
-
estimate product card item size based on image width in image config
Declaration
Swift
open func estimateItemSize() -> CGSize
-
estimate product card item size for a max width of maxWidth depend on the product configurations e.g. label is optional, the height would be dynamic and changes
Declaration
Swift
open func estimateItemSize(constrainedToWidth maxWidth: CGFloat) -> CGSize
-
to be override by subclasses. Subclass must call delegate.configureLayout to allow further customatization
Declaration
Swift
open func reloadLayout()
-
Set the meta query parameters based on provided schema mapping The parameters are needed to retrieve the relevant product information
Declaration
Swift
open func setMetaQueryParamsForSearch()
-
to be implemented by subclasses to call ViSenze APIs and refresh views
Declaration
Swift
open func refreshData()
-
fixed header size
Declaration
Swift
open var headerSize : CGSize
-
By default return a UILabel that shows the widget/view controller title For example, return
You May Also Like
header inYou May Also Like
widget solutionReturns
header view at the topDeclaration
Swift
open func headerView() -> UIView?
Return Value
header view at the top
-
By default, return Power By ViSenze image view and positions it at the bottom right of the footer
Returns
footer viewDeclaration
Swift
open func footerView() -> UIView?
Return Value
footer view
-
footer size
Declaration
Swift
open var footerSize : CGSize
-
show the generic error message when an error occurs after search e.g. network error or API error
Declaration
Swift
open var showDefaultErrMsg : Bool = true
-
show message when no search results is found
Declaration
Swift
open var showNoSearchResultsMsg : Bool = true
-
Generate view to display when there is no search results
Returns
no search results viewDeclaration
Swift
open func noSearchResultView() -> UIView?
Return Value
no search results view
-
Generate view to display generic error messages e.g. during network timeout or api error
Returns
default generic error viewDeclaration
Swift
open func genericErrSearchResultView() -> UIView?
Return Value
default generic error view
-
display default error messages. Currently it ignore all errors and just display a generic error message
An error has occured. Please try again later.
- Parameters:
- searchType: current search
- err: network related error
- apiErrors: api Errors
Declaration
Swift
open func displayDefaultErrMsg(searchType: ViSearchType, err: Error?, apiErrors: [String])
Parameters
searchType
current search
err
network related error
apiErrors
api Errors
- Parameters:
-
display no search results message. Currently display
No Results Found
Declaration
Swift
open func displayNoResultsFoundMsg()
-
hide the message view that display error messages such as network errors, no results found
Declaration
Swift
open func hideMsgView()
-
show the message view that display error messages such as network errors, no results found
Declaration
Swift
open func showMsgView()
-
Set custom message view
Parameter
Parameter view: custom message view for displaying errorsDeclaration
Swift
open func setMsgView(_ msgView: UIView)
Parameters
view
custom message view for displaying errors
-
user clicks on
Similar
button on a product card cell Copy the revelvant parameters from current search and open theFind Similar
view controllerDeclaration
Swift
@IBAction open func similarBtnTapped(_ cell: ViProductCollectionViewCell)
-
user tapped on action button of a product card cell
Declaration
Swift
@IBAction open func actionBtnTapped(_ cell: ViProductCollectionViewCell)
-
dismiss the similar controller that is being presented when user click on
Similar
button of a product cardDeclaration
Swift
open func dimissSimilarController()