Skip to content

Commit

Permalink
Merge pull request #28 from rees46/feat/stories-by-id-kotlin
Browse files Browse the repository at this point in the history
docs(stories): stories by id initialization
  • Loading branch information
TorinAsakura authored Jun 18, 2024
2 parents eeea2e6 + 1bd4570 commit 280cb11
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions source/includes/_stories.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,48 @@ let product: StoriesPromoCodeElement?
```

```kotlin

// Initialization by adding code into layout
<com.personalizatio.stories.views.StoriesView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:code="STORY BLOCK CODE" />

val storiesView = findViewById<StoriesView>(R.id.stories_view)
sdk.initializeStoriesView(storiesView)

// Programmatic initialization
val storiesView = StoriesView(this, "STORY BLOCK CODE")
findViewById<ViewGroup>(R.id.stories).addView(storiesView)
sdk.initializeStoriesView(storiesView)

//Font setup
val stories = findViewById<StoriesView>(R.id.story_view)
stories.settings.apply {
label_font_size = 16
label_font_family = Typeface.SERIF
button_font_family = Typeface.MONOSPACE
products_button_font_family = Typeface.DEFAULT_BOLD
}
```
```

// Set item click listener:
val storiesView = findViewById<StoriesView>(R.id.stories_view)
storiesView.itemClickListener = object : OnLinkClickListener {
override fun onClick(url: String): Boolean {
// return true if need to opening using the SDK
return false
}

override fun onClick(product: Product): Boolean {
// return true if need to opening using the SDK
return false
}
}

// Show story by id:

sdk.showStory(STORY_ID)


// TextBlock

Expand Down

0 comments on commit 280cb11

Please sign in to comment.