Note: All of the example code snippets are using the
StorytellerRowView
type, however, if you are usingStorytellerGridView
they will work in exactly the same way.
The StorytellerRowView
(see StorytellerRowView) and StorytellerGridView
(see StorytellerGridView) can be customized using these attributes,
cellType
: the style of cell, it can be either round
or square
, default value is square
delegate
: the StorytellerListViewDelegate
instance for StorytellerListView
callbacks (see Implementing StorytellerListViewDelegate methods)categories
: assigns list of story categories to be displayed inside row.theme
: theming style used to render story items in list and activities launched from this list. If theme is not set by user then Storyteller.theme
global attribute is used (see here for more details Theme)uiStyle
sets whether it should be rendered in light or dark mode, it can be auto
, light
, or dark
, the default value is auto
.The StorytellerListViewCellType
enum can be used to set the cellType
property in a StorytellerRowView
or StorytellerGridView
, the property can also be set as a plain string matching the values round
or square
let storytellerRow = StorytellerRowView()
storytellerRow.cellType = StorytellerListViewCellType.round.rawValue
The uiStyle
property can be used to set the overall color schemes, suitable for dark or light modes. This is optional and can be adjusted for additional UI mode control.
StorytellerListViewStyle.auto
- default value, the SDK will adjust its color scheme automatically according to the current system UI modeStorytellerListViewStyle.light
- force the SDK to use the light themeStorytellerListViewStyle.dark
- force the SDK to use the dark themeIf you are using in StorytellerRowView
or StorytellerGridView
remember to attach prepareForReuse
to UITableViewCell
lifecycle
override func prepareForReuse() {
super.prepareForReuse()
storytellerRow.prepareForReuse()
}
The categories
property assigns list of categories to be displayed inside row/grid.
let storytellerRow = StorytellerRowView()
storytellerRow.categories = ["<category-id-1>", "<category-id-2>"]
dismissStoryView(animated: Bool, dismissReason: String? = nil, onComplete: (() -> Void)? = nil)
This method has been deprecated. Please use Storyteller.dismissStoryView(animated:dismissReason:onComplete)
instead. See Additional Methods for more details.
reloadData()
The reloadData
method starts loading fresh data for all stories from the API. On completion, it updates the story data, starts prefetching content and updates the read status of the stories. The onDataLoadStarted
and onDataLoadComplete
methods on the StorytellerListViewDelegate are called accordingly (the latter with appropriate data depending on the result of the API requests).
let storytellerRow = StorytellerRowView()
storytellerRow.reloadData()
openStory(id: String = "", animated: Bool = true, onError: ((StorytellerListViewError) -> ())? = nil)
The openStory
method opens a specific story by its id
parameter, a UUID identifier returned from the API.
If story with id
will not be found then the row will reload itself and try to find it again. If it fails then custom onError
callback is called.
animated
specifies whether or not a scrolling animation will be played if a story is not currently visible inside the row.
onError
is called if this an error opening the requested story - including if the story is not currently available. The StorytellerListViewError
will contain information on the error which occurred.
let storytellerRow = StorytellerRowView()
storytellerRow.openStory() //Opens the first story
storytellerRow.openStory(id: "") //Opens the first story
storytellerRow.openStory(id: <story-id>) //Opens the story with id <story-id>, if that doesn't exist it then opens the first story
openPage(id: String = "", animated: Bool = true, onError: ((StorytellerListViewError) -> ())? = nil)
The openPage
method opens a specific page by its id
parameter, a UUID identifier returned from the API.
If page with id
will not be found then the row will reload itself and try to find the page again. If it fails then custom onError
callback is called.
animated
specifies whether or not a scrolling animation will be played if a story is not currently visible inside the row.
onError
is called if this an error opening the requested page - including if the page is not currently available. The StorytellerListViewError
will contain information on the error which occurred.
let storytellerRow = StorytellerRowView()
storytellerRow.openPage() // Error message displayed to the user
storytellerRow.openPage(id: "") // Error message displayed to the user
storytellerRow.openPage(id: <page-id>) // Opens the page with id <page-id>
openDeeplink(url: URL, onError: ((StorytellerListViewError) -> ())? = nil)
The openDeeplink
method opens a specific page and story using id
parameters extracted from url.
If story withn url
will not be found then the row will reload itself and try to find it again. If it fails then custom onError
callback is called.
onError
is called if this an error opening the requested page - including situation when the page is not currently available. The StorytellerListViewError
will contain information on the error which occurred.
let storytellerRow = StorytellerRowView()
storytellerRow.openDeeplink(url: URL(<deeplink-url>)!) // Opens proper story and page