Fix demo app.

This commit is contained in:
Alex Hart
2026-09-23 16:12:22 -04:00
committed by Michelle Tang
parent 8668d5bc70
commit 248e1894e1
2 changed files with 12 additions and 2 deletions
@@ -81,12 +81,18 @@ class DemoStickerKeyboardRepository(private val context: Context) : StickerKeybo
packsFlow.value = buildPacks()
}
override fun clearRecentStickers() {
recents.clear()
packsFlow.value = buildPacks()
}
private fun buildPacks(): List<KeyboardStickerPack> {
return buildList {
if (recents.isNotEmpty()) {
add(
KeyboardStickerPack(
id = StickerKeyboardRepository.RECENT_PACK_ID,
packKey = null,
title = null,
cover = null,
stickers = recents.toList()
@@ -102,6 +108,7 @@ class DemoStickerKeyboardRepository(private val context: Context) : StickerKeybo
private fun pack(id: String, title: String, @DrawableRes cover: Int): KeyboardStickerPack {
return KeyboardStickerPack(
id = id,
packKey = "$id-key",
title = title,
cover = rasterize(cover),
stickers = demoStickers.filter { it.packId == id }.map { stickersByName.getValue(it.name) }
@@ -66,12 +66,15 @@ fun MainScreen(
MediaKeyboardAction.Backspace -> onEvent(MainScreenEvents.BackspacePressed)
is MediaKeyboardAction.StickerSelected -> onEvent(MainScreenEvents.StickerSelected(action.sticker))
is MediaKeyboardAction.GifSelected -> onEvent(MainScreenEvents.GifSelected(action.gif))
// Nothing to remember the tab for, and no sticker packs to manage, view, or search.
// Nothing to remember the tab for, and no sticker packs to manage, view, search, send or
// remove.
is MediaKeyboardAction.TabSelected,
MediaKeyboardAction.StickerManagementClicked,
MediaKeyboardAction.StickerSearchClicked,
MediaKeyboardAction.GifSearchClicked,
is MediaKeyboardAction.ViewStickerPackClicked -> Unit
is MediaKeyboardAction.ViewStickerPackClicked,
is MediaKeyboardAction.SendStickerPackClicked,
is MediaKeyboardAction.RemoveStickerPackClicked -> Unit
}
}
}