Content Widget

ContentWidget

Content Widget is a feature in our Software Development Kit that allows you to embed an easily customizable view with various types of content in your application.

Declared In:
Headers/SNRContentWidget.h

Related To:
ContentWidgetOptions
ContentWidgetAppearance
ContentWidgetDelegate

Inherits From:
NSObject

Declaration:

class ContentWidget: NSObject

Properties:

Property Type Optional Description
options ContentWidgetOptions no Business configuration of the widget
appearance ContentWidgetAppearance no UI configuration of the widget
delegate ContentWidgetDelegate no Delegate of the widget

Initializers:

init(options: ContentWidgetOptions, appearance: ContentWidgetAppearance)

Methods:

Starts operation of fetching data and creates view structure of widget.

func load()


Checks whether widget is loaded with success.

func isLoaded() -> Bool


Gets root view of whole widget view structure.

func getView() -> UIView



ContentWidgetAppearance

The ContentWidgetAppearance class is responsible for defining the appearance of the widget.

Declared In:
Headers/SNRContentWidgetAppearance.h

Related To:
SNRContentWidget
SNRContentWidgetLayout
SNRContentWidgetHorizontalSliderLayout
SNRContentWidgetGridLayout
SNRContentWidgetItemLayout
SNRContentWidgetBasicProductItemLayout

Inherits From:
NSObject

Declaration:

class ContentWidgetAppearance: NSObject

Properties:

Property Type Optional Description
layout ContentWidgetLayout no UI configuration of the widget’s layout
itemLayout ContentWidgetItemLayout no UI configuration a single widget item

Initializers:

init(widgetLayout: ContentWidgetLayout, itemLayout: ContentWidgetItemLayout)



ContentWidgetOptions

Declared In:
Headers/SNRContentWidgetOptions.h

Related To:
SNRContentWidget

Inherits From:
NSObject

Declaration:

class ContentWidgetOptions: NSObject



ContentWidgetRecommendationsOptions

The ContentWidgetRecommendationsOptions class is responsible for defining the business logic options of the widget.

Declared In:
Headers/SNRContentWidgetOptions.h

Related To:
SNRContentWidget

Inherits From:
NSObject

Declaration:

class ContentWidgetRecommendationsOptions: NSObject

Properties:

Property Type Optional Description
slug String no Slug responsible for generating data
productID String yes Product identifier for generating data
mapping ((ContentWidgetRecommendationModel) -> (ContentWidgetRecommendationDataModel)) no Mapping block responsible for mapping data from the feed to a ContentWidgetRecommendationDataModel
recommendationEventType ContentWidgetRecommendationEventType - Recommendation event type.
  • .view sends all products in one event. We highly recommend using this type of event in content widget.
  • .seen sends each event as a separate event.

Initializers:

init()



ContentWidgetLayout

Main widget layout abstract class for inheriting classes.

Declared In:
Headers/SNRContentWidgetLayout.h

Related To:
SNRContentWidget

Inherits From:
NSObject

Declaration:

class ContentWidgetLayout: NSObject

Properties:

Property Type Optional Description
backgroundColor UIColor yes Background color of a widget
insets UIEdgeInsets yes Inner widget margins in pt
itemSize Size yes Size of a single item in pt
numberOfItems Int yes It returns the number of items after the widget is loaded
Important: numberOfItems property is read-only.


ContentWidgetHorizontalSliderLayout

This layout is intended to present recommendations in a fixed-hight horizontal scrollable slider.

Declared In: Headers/SNRContentWidgetHorizontalSliderLayout.h

Related To:
SNRContentWidget

Inherits From:
ContentWidgetLayout

Declaration:

class ContentWidgetHorizontalSliderLayout: ContentWidgetLayout

Properties:

Property Type Optional Description
itemSpacing Float yes Horizontal spacing between items in pt


ContentWidgetGridLayout

This layout presents recommendations in a vertical scrollable grid, with elements organized into columns and rows. You can create a full- or half-screen widget.

Declared In:
Headers/SNRContentWidgetGridLayout.h

Related To:
SNRContentWidget

Inherits From:
ContentWidgetLayout

Declaration:

class ContentWidgetGridLayout: ContentWidgetLayout

Properties:

Property Type Optional Description
itemHorizontalSpacing Float yes Horizontal spacing between items in pt
itemVerticalSpacing Float yes Vertical spacing between items in pt


ContentWidgetItemLayout

Main widget layout item abstract class for inheriting classes.

Declared In:
Headers/SNRContentWidgetItemLayout.h

Related To:
ContentWidget
ContentWidgetAppearance

Inherits From:
NSObject

Declaration:

class ContentWidgetItemLayout: NSObject

Properties:

Property Type Optional Description
backgroundColor UIColor no Background color of an item
cornerRadius Float no Radius of the item corners
borderWidth Float no Width of the item’s border
borderColor UIColor no Color of the item’s border
shadowColor UIColor no Color of the item’s shadow


ContentWidgetBasicProductItemLayout

This is the basic layout for items. It contains: the image, the title, and the price from the uploaded data.

Declared In:
Headers/SNRContentWidgetBasicProductItemLayout.h

Related To:
ContentWidget
ContentWidgetAppearance

Inherits From:
ContentWidgetItemLayout

Declaration:

class ContentWidgetBasicProductItemLayout: ContentWidgetItemLayout

Properties:

Property Type Optional Description
imageWidthRatio Float no Image width. A ratio of 1.0 means that the image width equals to 100% of the entire height of the item
imageHeightRatio Float no Image height. A ratio of 0.3 means that image height equals to 30% of the entire height of the item
imageBackground UIColor no Background color of the image
titleInsets UIEdgeInsets no Inner margins of the title label
titleFont UIFont no Font of the item title label
titleFontColor UIColor no Color of the title label
titleAlignment NSTextAlignment no Alignment of the title label
priceInsets UIEdgeInsets no Inner margins of the price label
priceFont UIFont no Font of the price label
priceFontColor UIColor no Color of the price label
priceAlignment NSTextAlignment no Alignment of the price label
priceGroupSeparator String no Separator of price group
priceDecimalSeparator String no Separator of price decimal
isSalePriceVisible Bool no Flag determining whether to show the sale price label or not
salePriceOrientation UILayoutConstraintAxis no Orientation of the sale price label
salePriceMargin Float no Margin between the price label and the sale price label
regularPriceFont UIFont no Font of the regular price label
regularPriceFontColor UIColor no Color of the regular price label
salePriceFont UIFont no Font of the sale price label
salePriceFontColor UIColor no Color of the sale price label
actionButton ContentWidgetImageButtonCustomAction no Optional button for your own custom action
actionButtonPosition CGPoint no Position of the action button


ContentWidgetBaseCustomAction

Main widget custom action abstract class for inheriting classes.

Declared In:
Headers/SNRContentWidgetItemLayout.h

Related To:
ContentWidget
ContentWidgetAppearance

Inherits From:
NSObject

Declaration:

class ContentWidgetBaseCustomAction: NSObject

Properties:

Property Type Optional Description
predefinedActionType ContentWidgetBaseCustomActionPredefiniedActionType no It determines which event is on click


ContentWidgetImageButtonCustomAction

ContentWidgetImageButtonCustomAction is used to add an image button to your widget (only if the item layout allows). You can add a button with a single state or make it selectable.

Declared In:
Headers/SNRContentWidgetImageButtonCustomAction.h

Related To:
ContentWidget
ContentWidgetAppearance

Inherits From:
ContentWidgetBaseCustomAction

Declaration:

class ContentWidgetImageButtonCustomAction: NSObject

Properties:

Property Type Optional Description
size Size yes Button size
backgroundColor UIColor yes Background color of the button
tintColor UIColor yes Fill color of the button’s image, if an asset supports it
image UIImage yes Button image
isSelectable Bool yes Flag determining whether the button is selectable
selectedImage UIImage yes Image of the button when the button is selected
isSelected ContentWidgetImageButtonCustomActionIsSelectedBlock yes Block/closure to be executed when the widget needs to determine the state of a button in the cell
onReceiveClick ContentWidgetImageButtonCustomActionReceiveClickBlock yes Block/closure to be executed when the button is clicked


ContentWidgetBaseCustomActionPredefiniedActionType

Declared In:
Headers/SNRContentWidgetBaseCustomAction.h

Declaration:

enum ContentWidgetBaseCustomActionPredefiniedActionType: Int {
	none,
	sendLikeEvent
}

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker