ViProductCardLayout

open class ViProductCardLayout: StackLayout<UIView>

Layout for a single product card The layout is dynamic depending on various configurations e.g. label/action button can be optional

  • Undocumented

    Declaration

    Swift

    open class ViProductCardLayout: StackLayout<UIView>
  • Constructor for layout

    • Parameters:
      • imgUrl: product image url
      • imageConfig: product image configuration
      • heading: heading e.g. product title
      • headingConfig: heading configuration
      • label: label e.g. brand
      • labelConfig: label configuration
      • price: product price
      • priceConfig: price configuration
      • discountPrice: discount price
      • discountPriceConfig: discount price configuration
      • hasSimilarBtn: availablity of similar button (at bottom right of product car)
      • similarBtnConfig: similar button configuration if hasSimilarBtn is true
      • hasActionBtn: availablity of action button
      • actionBtnConfig: action button configuration if hasActionBtn is true
      • pricesHorizontalSpacing: spacing between price and discount price labels
      • labelLeftPadding: leading padding from supper view for various labels on the left

    Declaration

    Swift

    public convenience init(
            imgUrl: URL?, imageConfig: ViImageConfig,
            heading: String? , headingConfig: ViLabelConfig = ViLabelConfig(),
            label: String? = nil, labelConfig: ViLabelConfig = ViLabelConfig.default_label_config,
            price: Float?, priceConfig: ViLabelConfig = ViLabelConfig.default_price_config,
            discountPrice : Float?,
            discountPriceConfig: ViLabelConfig = ViLabelConfig.default_discount_price_config,
            hasSimilarBtn: Bool = true,
            similarBtnConfig: ViButtonConfig = ViButtonConfig.default_similar_btn_config ,
            hasActionBtn: Bool = true,
            actionBtnConfig: ViButtonConfig = ViButtonConfig.default_action_btn_config ,
            pricesHorizontalSpacing: CGFloat = ViProductCardLayout.default_spacing,
            labelLeftPadding: CGFloat = ViProductCardLayout.default_spacing
            )

    Parameters

    imgUrl

    product image url

    imageConfig

    product image configuration

    heading

    heading e.g. product title

    headingConfig

    heading configuration

    label

    label e.g. brand

    labelConfig

    label configuration

    price

    product price

    priceConfig

    price configuration

    discountPrice

    discount price

    discountPriceConfig

    discount price configuration

    hasSimilarBtn

    availablity of similar button (at bottom right of product car)

    similarBtnConfig

    similar button configuration if hasSimilarBtn is true

    hasActionBtn

    availablity of action button

    actionBtnConfig

    action button configuration if hasActionBtn is true

    pricesHorizontalSpacing

    spacing between price and discount price labels

    labelLeftPadding

    leading padding from supper view for various labels on the left

  • Constructor for productCard

    • Parameters:
      • img_url: product image url
      • img_size: product image size
      • img_contentMode: contentMode for ImageView
      • loading_img: loading/placeholder image
      • err_img: error image (when fail to download)
      • label: label text e.g. to display product brand
      • label_font: label font, default to Roboto Bold
      • label_text_color: label text color, default to black
      • label_num_of_lines: number of lines for label, default 1 line
      • heading: heading text e.g. to display product name or title
      • heading_font: heading font , default to Roboto Regular
      • heading_text_color: heading text color, default to black
      • heading_num_of_lines: number of lines for heading label, default 1 line
      • price: product price
      • price_font: product price font, default to Roboto Regular
      • price_text_color: product price label text color, default to red color
      • price_string_format: string format to display price, must include .f specifier e.g. %.2f
      • price_strike_through: whether to strike through the price e.g. during discount, default to no
      • discounted_price: discounted product price
      • discounted_price_font: discounted price label font , default to Roboto Regular
      • discounted_price_text_color: discounted price label text color , default to gray color and strike through
      • discounted_price_string_format: string format to display discounted price, must include .f specifier e.g. %.2f
      • discounted_price_strike_through: whether to strike through discounted price label, default to no
      • has_similar_btn: whether to display similar button
      • similar_btn_txt: text for similar button, default to empty
      • similar_btn_icon: icon for similar button
      • similar_btn_font: font for similar button title text
      • similar_btn_size: size for similar button
      • similar_btn_background_color: background color for similar button
      • similar_btn_tint_color: tint color for similar button i.e. text color and image color
      • has_action_btn: whether to display action button
      • action_btn_txt: text for action button, default to empty
      • action_btn_icon: icon for action button
      • action_btn_font: font for action button title text
      • action_btn_size: size for action button
      • action_btn_background_color: background color for action button
      • action_btn_tint_color: tint color for action button i.e. text color and image color
      • prices_horizontal_spacing: spacing between price and discounted price label
      • label_left_padding: padding of labels from parent left

    Declaration

    Swift

    public init(
                        // image settings
                        img_url: URL?,
                        img_size: CGSize,
                        img_contentMode: UIViewContentMode = ViImageConfig.default_content_mode,
                        loading_img: UIImage? = nil,
                        err_img: UIImage? = nil,
                        
                        // label
                        label: String? = nil,
                        label_font: UIFont = ViTheme.sharedInstance.default_bold_font,
                        label_text_color: UIColor = ViTheme.sharedInstance.default_txt_color,
                        label_num_of_lines: Int = 1,
                        
                        // heading
                        heading: String? = nil,
                        heading_font: UIFont = ViTheme.sharedInstance.default_font,
                        heading_text_color: UIColor = ViTheme.sharedInstance.default_txt_color,
                        heading_num_of_lines: Int = 1,
                        
                        
                        // price
                        price: Float?,
                        price_font : UIFont = ViTheme.sharedInstance.default_font,
                        price_text_color: UIColor = ViTheme.sharedInstance.default_txt_color,
                        price_string_format: String = ViTheme.sharedInstance.default_price_format,
                        price_strike_through: Bool = false,
                        
                        // discount price
                        discounted_price : Float?,
                        discounted_price_font : UIFont = ViTheme.sharedInstance.default_font,
                        discounted_price_text_color: UIColor = ViTheme.sharedInstance.default_discounted_price_text_color,
                        discounted_price_string_format: String = ViTheme.sharedInstance.default_discount_price_format,
                        discounted_price_strike_through: Bool = false,
                        
                        // similar button configuration
                        has_similar_btn: Bool = true,
                        similar_btn_icon: UIImage? = ViButtonConfig.default_similar_btn_config.icon,
                        similar_btn_txt: String = ViButtonConfig.default_similar_btn_config.text , // default to empty
                        similar_btn_font: UIFont = ViButtonConfig.default_similar_btn_config.font,
                        similar_btn_size: CGSize = ViButtonConfig.default_similar_btn_config.size,
                        similar_btn_background_color: UIColor = ViButtonConfig.default_similar_btn_config.backgroundColor,
                        similar_btn_tint_color: UIColor = ViButtonConfig.default_similar_btn_config.tintColor,
                        
                        // action button configuration e.g. like icon
                        has_action_btn: Bool = true,
                        action_btn_icon: UIImage? = ViButtonConfig.default_action_btn_config.icon,
                        action_btn_txt: String =  ViButtonConfig.default_action_btn_config.text , // default to empty
                        action_btn_font: UIFont = ViButtonConfig.default_action_btn_config.font,
                        action_btn_size: CGSize = ViButtonConfig.default_action_btn_config.size,
                        action_btn_background_color: UIColor = ViButtonConfig.default_action_btn_config.backgroundColor,
                        action_btn_tint_color: UIColor = ViButtonConfig.default_action_btn_config.tintColor,
            
                        // spacing
                        prices_horizontal_spacing: CGFloat = default_spacing,
                        label_left_padding: CGFloat = default_spacing
                        
            )

    Parameters

    img

    _url: product image url

    img

    _size: product image size

    img

    _contentMode: contentMode for ImageView

    loading

    _img: loading/placeholder image

    err

    _img: error image (when fail to download)

    label

    label text e.g. to display product brand

    label

    _font: label font, default to Roboto Bold

    label

    _text_color: label text color, default to black

    label

    _num_of_lines: number of lines for label, default 1 line

    heading

    heading text e.g. to display product name or title

    heading

    _font: heading font , default to Roboto Regular

    heading

    _text_color: heading text color, default to black

    heading

    _num_of_lines: number of lines for heading label, default 1 line

    price

    product price

    price

    _font: product price font, default to Roboto Regular

    price

    _text_color: product price label text color, default to red color

    price

    _string_format: string format to display price, must include .f specifier e.g. %.2f

    price

    _strike_through: whether to strike through the price e.g. during discount, default to no

    discounted

    _price: discounted product price

    discounted

    _price_font: discounted price label font , default to Roboto Regular

    discounted

    _price_text_color: discounted price label text color , default to gray color and strike through

    discounted

    _price_string_format: string format to display discounted price, must include .f specifier e.g. %.2f

    discounted

    _price_strike_through: whether to strike through discounted price label, default to no

    has

    _similar_btn: whether to display similar button

    similar

    _btn_txt: text for similar button, default to empty

    similar

    _btn_icon: icon for similar button

    similar

    _btn_font: font for similar button title text

    similar

    _btn_size: size for similar button

    similar

    _btn_background_color: background color for similar button

    similar

    _btn_tint_color: tint color for similar button i.e. text color and image color

    has

    _action_btn: whether to display action button

    action

    _btn_txt: text for action button, default to empty

    action

    _btn_icon: icon for action button

    action

    _btn_font: font for action button title text

    action

    _btn_size: size for action button

    action

    _btn_background_color: background color for action button

    action

    _btn_tint_color: tint color for action button i.e. text color and image color

    prices

    _horizontal_spacing: spacing between price and discounted price label

    label

    _left_padding: padding of labels from parent left