Miscellaneous
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
SNRContentWidget.h
Related To
ContentWidgetOptions
ContentWidgetAppearance
ContentWidgetDelegate
Inherits From
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
SNRContentWidgetAppearance.h
Related To
SNRContentWidget
SNRContentWidgetLayout
SNRContentWidgetHorizontalSliderLayout
SNRContentWidgetGridLayout
SNRContentWidgetItemLayout
SNRContentWidgetBasicProductItemLayout
Inherits From
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
SNRContentWidgetOptions.h
Related To
Inherits From
Declaration
class ContentWidgetOptions: NSObject
ContentWidgetRecommendationsOptions
The ContentWidgetRecommendationsOptions
class is responsible for defining the business logic options of the widget.
Declared In
SNRContentWidgetOptions.h
Related To
Inherits From
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 |
Initializers
init()
ContentWidgetLayout
Main widget layout abstract class for inheriting classes.
Declared In
SNRContentWidgetLayout.h
Related To
Inherits From
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 |
numberOfItems
property is readonly.ContentWidgetHorizontalSliderLayout
This layout is intended to present recommendations in a fixed-hight horizontal scrollable slider.
Declared In
SNRContentWidgetHorizontalSliderLayout.h
Related To
Inherits From
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
SNRContentWidgetGridLayout.h
Related To
Inherits From
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
SNRContentWidgetItemLayout.h
Related To
ContentWidget
ContentWidgetAppearance
Inherits From
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
SNRContentWidgetBasicProductItemLayout.h
Related To
ContentWidget
ContentWidgetAppearance
Inherits From
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 35% 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 regulat 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
SNRContentWidgetItemLayout.h
Related To
ContentWidget
ContentWidgetAppearance
Inherits From
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
SNRContentWidgetImageButtonCustomAction.h
Related To
ContentWidget
ContentWidgetAppearance
Inherits From
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
SNRContentWidgetBaseCustomAction.h
Declaration
enum ContentWidgetBaseCustomActionPredefiniedActionType: Int {
none,
sendLikeEvent
}
CacheManager
Declared In
SNRCacheManager.h
Declaration
class CacheManager: NSObject
Methods
static func get(_: AnyClass) -> AnyObject
SNRError
SNRErrorDomain
.Declared In
SNRError.h
Inherits From
Conforms To
Declaration
class SNRError: NSError
There are global string constants that can be used to get specific information from the userInfo
property:
SNRErrorUserInfoCodeKey
SNRErrorUserInfoTitleKey
SNRErrorUserInfoMessageKey
SNRErrorUserInfoFieldKey
SNRErrorUserInfoPathKey
SNRErrorUserInfoRejectedValueKey
SNRErrorUserInfoErrorsKey
SNRApiError
Overview
SNRErrorDomain
global constant.Declared In
SNRApiError.h
Inherits From
Conforms To
Declaration
class SNRApiError: SNRError
Properties
Property | Type | Optional | Description |
---|---|---|---|
errors | [SNRError] |
yes | List of error items |
Initializers
init(domain: String, code: Int, userInfo: [String: Any]?, errors: [SNRError]?)
Methods
Gets the type of an error (SNRApiErrorType
).
func getType() -> SNRApiErrorType
Gets the HTTP code of an error.
func getHttpCode() -> Int
Gets the internal code of an error.
func getErrorCode() -> String?
Gets the description of an error.
func getBody() -> String?
SNRApiErrorType
Declared In
SNRApiError.h
Declaration
enum SNRApiErrorType: Int {
unknown,
network,
unauthorizedSession,
http
}
SNRException
Declared In
SNRException.h
Inherits From
Conforms To
Declaration
class SNRException: NSException
Properties
Property | Type | Optional | Description |
---|---|---|---|
error | SNRError |
no | Error provided for Swift compatibility |
Methods
Throws an exception.
static func throwException(exceptionName: NSExceptionName, reason: String)
SNRInvalidArgumentException
Declared In
SNRInvalidArgumentException.h
Inherits From
Conforms To
Declaration
class SNRInvalidArgumentException: NSException