Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Sep 15, 2024
1 parent 4e6f7ff commit b5004c3
Show file tree
Hide file tree
Showing 205 changed files with 3,637 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ import org.michaelbel.mobiledevemoji.data.Emoji
import org.michaelbel.mobiledevemoji.data.EmojiResponse
import org.michaelbel.mobiledevemoji.data.PACK_1_SIZE
import org.michaelbel.mobiledevemoji.data.PACK_2_SIZE
import org.michaelbel.mobiledevemoji.data.PACK_3_SIZE
import org.michaelbel.mobiledevemoji.data.TELEGRAM_PACK_1
import org.michaelbel.mobiledevemoji.data.TELEGRAM_PACK_2
import org.michaelbel.mobiledevemoji.data.TELEGRAM_PACK_3
import org.michaelbel.mobiledevemoji.ktx.decodeJsonToString
import org.michaelbel.mobiledevemoji.ktx.emojiPainter
import org.michaelbel.mobiledevemoji.ui.EmojiIcon
Expand Down Expand Up @@ -73,6 +75,15 @@ fun MainContent() {
emojiSnapshotStateList[index.plus(position)] = currentEmoji.copy(emojiResponse = emojiResponse, painter = emojiPainter)
emojiList = emojiSnapshotStateList.toList()
}

val emojiResponseList3 = json.decodeFromString<List<EmojiResponse>>("icons-pack3.json".decodeJsonToString())
val position2 = PACK_1_SIZE + PACK_2_SIZE
emojiResponseList3.forEachIndexed { index, emojiResponse ->
val emojiPainter = "pack3/${emojiResponse.id}.svg".emojiPainter()
val currentEmoji = emojiSnapshotStateList[index.plus(position2)]
emojiSnapshotStateList[index.plus(position2)] = currentEmoji.copy(emojiResponse = emojiResponse, painter = emojiPainter)
emojiList = emojiSnapshotStateList.toList()
}
}

Scaffold(
Expand Down Expand Up @@ -138,7 +149,29 @@ fun MainContent() {
)
}

items(emojiList.takeLast(PACK_2_SIZE)) { emoji ->
items(emojiList.subList(PACK_1_SIZE, PACK_1_SIZE.plus(PACK_2_SIZE))) { emoji ->
EmojiIcon(
emoji = emoji,
onClick = { emojiId ->
emojiPreviewVisible = when {
emojiId == emojiPreviewVisible -> null
else -> emojiId
}
}
)
}

item(
span = { GridItemSpan(maxLineSpan) }
) {
PackHeader(
packName = "Pack 3",
packUrl = TELEGRAM_PACK_3,
modifier = Modifier.padding(top = 32.dp)
)
}

items(emojiList.takeLast(PACK_3_SIZE)) { emoji ->
EmojiIcon(
emoji = emoji,
onClick = { emojiId ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class Emoji(

companion object {
val Empty: Emoji = Emoji(EmojiResponse.Empty, null)
val EmptyList: MutableList<Emoji> = MutableList(size = PACK_1_SIZE + PACK_2_SIZE) {
val EmptyList: MutableList<Emoji> = MutableList(size = PACKS_SIZE) {
Emoji(EmojiResponse.Empty, null)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const val APP_NAME = "MobileDevEmoji"
const val TELEGRAM_URL = "https://t.me/foundout"
const val TELEGRAM_PACK_1 = "https://t.me/addstickers/MobileDevEmojiTgs"
const val TELEGRAM_PACK_2 = "https://t.me/addstickers/MobileDevEmojiTgs2"
const val TELEGRAM_PACK_3 = "https://t.me/addstickers/MobileDevEmojiTgs3"
const val FIGMA_URL = "https://www.figma.com/community/file/1385339470177359146"
const val PACK_1_SIZE = 200
const val PACK_2_SIZE = 200
const val PACK_2_SIZE = 200
const val PACK_3_SIZE = 200
const val PACKS_SIZE = PACK_1_SIZE + PACK_2_SIZE + PACK_3_SIZE
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
package org.michaelbel.mobiledevemoji.svg

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.painter.Painter
import org.jetbrains.skia.Data
import org.jetbrains.skia.svg.SVGDOM

@Composable
fun loadSvgPainterFromBytes(
bytes: ByteArray
): Painter {
return remember {
val svg = try {
SVGDOM(Data.makeFromBytes(bytes))
} catch (e: Exception) {
e.printStackTrace()
null
}
SvgPainter(svg)
}
}

val ByteArray.svgPainter: Painter
get() {
val svg = try {
Expand Down
Loading

0 comments on commit b5004c3

Please sign in to comment.