Skip to content

Commit

Permalink
feat(updater): add helper method String.fromGitmoji() to parse Gitmoj…
Browse files Browse the repository at this point in the history
…i on release notes
  • Loading branch information
rhenwinch committed Jun 14, 2024
1 parent 8c91f7f commit dba98f3
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import com.flixclusive.core.theme.FlixclusiveTheme
import com.flixclusive.core.ui.common.navigation.StartHomeScreenAction
import com.flixclusive.core.ui.common.util.onMediumEmphasis
import com.flixclusive.core.util.android.installApkActivity
import com.flixclusive.feature.mobile.update.util.fromGitmoji
import com.flixclusive.service.update.AppUpdaterService
import com.flixclusive.service.update.AppUpdaterService.Companion.startAppUpdater
import com.ramcosta.composedestinations.annotation.Destination
Expand Down Expand Up @@ -153,7 +154,7 @@ fun UpdateScreen(
)

MarkdownText(
markdown = args.updateInfo ?: stringResource(id = UtilR.string.default_update_info_message),
markdown = args.updateInfo?.fromGitmoji() ?: stringResource(id = UtilR.string.default_update_info_message),
isTextSelectable = true,
linkColor = Color(0xFF5890FF),
fontResource = com.flixclusive.core.theme.R.font.space_grotesk_medium,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.flixclusive.feature.mobile.update.util

private val GITMOJIS: Map<String, String> = mapOf(
":art:" to "🎨",
":zap:" to "⚡️",
":fire:" to "🔥",
":bug:" to "🐛",
":ambulance:" to "🚑️",
":sparkles:" to "",
":memo:" to "📝",
":rocket:" to "🚀",
":lipstick:" to "💄",
":tada:" to "🎉",
":white_check_mark:" to "",
":lock:" to "🔒️",
":closed_lock_with_key:" to "🔐",
":bookmark:" to "🔖",
":rotating_light:" to "🚨",
":construction:" to "🚧",
":green_heart:" to "💚",
":arrow_down:" to "⬇️",
":arrow_up:" to "⬆️",
":pushpin:" to "📌",
":construction_worker:" to "👷",
":chart_with_upwards_trend:" to "📈",
":recycle:" to "♻️",
":heavy_plus_sign:" to "",
":heavy_minus_sign:" to "",
":wrench:" to "🔧",
":hammer:" to "🔨",
":globe_with_meridians:" to "🌐",
":pencil2:" to "✏️",
":pencil:" to "✏️",
":poop:" to "💩",
":rewind:" to "⏪️",
":twisted_rightwards_arrows:" to "🔀",
":package:" to "📦️",
":alien:" to "👽️",
":truck:" to "🚚",
":page_facing_up:" to "📄",
":boom:" to "💥",
":bento:" to "🍱",
":wheelchair:" to "♿️",
":bulb:" to "💡",
":beers:" to "🍻",
":speech_balloon:" to "💬",
":card_file_box:" to "🗃️",
":loud_sound:" to "🔊",
":mute:" to "🔇",
":busts_in_silhouette:" to "👥",
":children_crossing:" to "🚸",
":building_construction:" to "🏗️",
":iphone:" to "📱",
":clown_face:" to "🤡",
":egg:" to "🥚",
":see_no_evil:" to "🙈",
":camera_flash:" to "📸",
":alembic:" to "⚗️",
":mag:" to "🔍️",
":label:" to "🏷️",
":seedling:" to "🌱",
":triangular_flag_on_post:" to "🚩",
":goal_net:" to "🥅",
":dizzy:" to "💫",
":wastebasket:" to "🗑️",
":passport_control:" to "🛂",
":adhesive_bandage:" to "🩹",
":monocle_face:" to "🧐",
":coffin:" to "⚰️",
":test_tube:" to "🧪",
":necktie:" to "👔",
":stethoscope:" to "🩺",
":bricks:" to "🧱",
":technologist:" to "🧑‍💻",
":money_with_wings:" to "💸",
":thread:" to "🧵",
":safety_vest:" to "🦺"
)

internal fun String.fromGitmoji(): String {
val re = Regex(GITMOJIS.keys.joinToString("|"), RegexOption.IGNORE_CASE)
return re.replace(this) { matchResult ->
GITMOJIS[matchResult.value.lowercase()] ?: ""
}.trim()
}

0 comments on commit dba98f3

Please sign in to comment.