diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/HashtagIcon.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/HashtagIcon.kt index f3da2c1f1..4779fbbe2 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/model/HashtagIcon.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/HashtagIcon.kt @@ -21,162 +21,74 @@ package com.vitorpamplona.amethyst.model import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.commons.HashTagSegment +import com.vitorpamplona.amethyst.commons.RegularTextSegment +import com.vitorpamplona.amethyst.ui.components.HashTag +import com.vitorpamplona.amethyst.ui.components.RenderRegular +import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn +import com.vitorpamplona.quartz.events.EmptyTagList -fun checkForHashtagWithIcon( - tag: String, - primary: Color, -): HashtagIcon? { +@Preview +@Composable +fun RenderHashTagIcons() { + val nav: (String) -> Unit = {} + + ThemeComparisonColumn { + RenderRegular( + "Testing rendering of hashtags: #Bitcoin, #nostr, #lightning, #zap, #amethyst, #cashu, #plebs, #coffee, #skullofsatoshi, #grownostr, #footstr, #tunestr, #weed", + EmptyTagList, + ) { word, state -> + when (word) { + is HashTagSegment -> HashTag(word, nav) + is RegularTextSegment -> Text(word.segmentText) + } + } + } +} + +fun checkForHashtagWithIcon(tag: String): HashtagIcon? { return when (tag.lowercase()) { - "₿itcoin", - "bitcoin", - "btc", - "timechain", - "bitcoiner", - "bitcoiners", - -> - HashtagIcon( - R.drawable.ht_btc, - "Bitcoin", - Color.Unspecified, - Modifier.padding(2.dp, 2.dp, 0.dp, 0.dp), - ) - "nostr", - "nostrich", - "nostriches", - "thenostr", - -> - HashtagIcon( - R.drawable.ht_nostr, - "Nostr", - Color.Unspecified, - Modifier.padding(1.dp, 2.dp, 0.dp, 0.dp), - ) - "lightning", - "lightningnetwork", - -> - HashtagIcon( - R.drawable.ht_lightning, - "Lightning", - Color.Unspecified, - Modifier.padding(1.dp, 3.dp, 0.dp, 0.dp), - ) - "zap", - "zaps", - "zapper", - "zappers", - "zapping", - "zapped", - "zapathon", - "zapraiser", - "zaplife", - "zapchain", - -> - HashtagIcon( - R.drawable.zap, - "Zap", - Color.Unspecified, - Modifier.padding(1.dp, 3.dp, 0.dp, 0.dp), - ) - "amethyst" -> - HashtagIcon( - R.drawable.amethyst, - "Amethyst", - Color.Unspecified, - Modifier.padding(3.dp, 2.dp, 0.dp, 0.dp), - ) - "onyx" -> - HashtagIcon( - R.drawable.black_heart, - "Onyx", - Color.Unspecified, - Modifier.padding(1.dp, 3.dp, 0.dp, 0.dp), - ) - "cashu", - "ecash", - "nut", - "nuts", - "deeznuts", - -> - HashtagIcon( - R.drawable.cashu, - "Cashu", - Color.Unspecified, - Modifier.padding(1.dp, 3.dp, 0.dp, 0.dp), - ) - "plebs", - "pleb", - "plebchain", - -> - HashtagIcon( - R.drawable.plebs, - "Pleb", - Color.Unspecified, - Modifier.padding(2.dp, 2.dp, 0.dp, 1.dp), - ) - "coffee", - "coffeechain", - "cafe", - -> - HashtagIcon( - R.drawable.coffee, - "Coffee", - Color.Unspecified, - Modifier.padding(2.dp, 2.dp, 0.dp, 0.dp), - ) - "skullofsatoshi" -> - HashtagIcon( - R.drawable.skull, - "SkullofSatoshi", - Color.Unspecified, - Modifier.padding(2.dp, 1.dp, 0.dp, 0.dp), - ) - "grownostr", - "gardening", - "garden", - -> - HashtagIcon( - R.drawable.grownostr, - "GrowNostr", - Color.Unspecified, - Modifier.padding(0.dp, 1.dp, 0.dp, 1.dp), - ) - "footstr" -> - HashtagIcon( - R.drawable.footstr, - "Footstr", - Color.Unspecified, - Modifier.padding(1.dp, 1.dp, 0.dp, 0.dp), - ) - "tunestr", - "music", - "nowplaying", - -> - HashtagIcon(R.drawable.tunestr, "Tunestr", primary, Modifier.padding(0.dp, 3.dp, 0.dp, 1.dp)) - "weed", - "weedstr", - "420", - "cannabis", - "marijuana", - -> - HashtagIcon( - R.drawable.weed, - "Weed", - Color.Unspecified, - Modifier.padding(0.dp, 0.dp, 0.dp, 0.dp), - ) + "₿itcoin", "bitcoin", "btc", "timechain", "bitcoiner", "bitcoiners" -> bitcoin + "nostr", "nostrich", "nostriches", "thenostr" -> nostr + "lightning", "lightningnetwork" -> lightning + "zap", "zaps", "zapper", "zappers", "zapping", "zapped", "zapathon", "zapraiser", "zaplife", "zapchain" -> zap + "amethyst" -> amethyst + "cashu", "ecash", "nut", "nuts", "deeznuts" -> cashu + "plebs", "pleb", "plebchain" -> plebs + "coffee", "coffeechain", "cafe" -> coffee + "skullofsatoshi" -> skull + "grownostr", "gardening", "garden" -> growstr + "footstr" -> footstr + "tunestr", "music", "nowplaying" -> tunestr + "weed", "weedstr", "420", "cannabis", "marijuana" -> weed else -> null } } +val bitcoin = HashtagIcon(R.drawable.ht_btc, "Bitcoin", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val nostr = HashtagIcon(R.drawable.ht_nostr, "Nostr", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val lightning = HashtagIcon(R.drawable.lightning, "Lightning", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val zap = HashtagIcon(R.drawable.zap, "Zap", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val amethyst = HashtagIcon(R.drawable.amethyst, "Amethyst", Modifier.padding(start = 2.dp, bottom = 1.dp, top = 1.dp)) +val cashu = HashtagIcon(R.drawable.cashu, "Cashu", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val plebs = HashtagIcon(R.drawable.plebs, "Pleb", Modifier.padding(start = 2.dp, bottom = 1.dp, top = 1.dp)) +val coffee = HashtagIcon(R.drawable.coffee, "Coffee", Modifier.padding(start = 3.dp, bottom = 1.dp, top = 1.dp)) +val skull = HashtagIcon(R.drawable.skull, "SkullofSatoshi", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val growstr = HashtagIcon(R.drawable.grownostr, "GrowNostr", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val footstr = HashtagIcon(R.drawable.footstr, "Footstr", Modifier.padding(start = 2.dp, bottom = 1.dp, top = 1.dp)) +val tunestr = HashtagIcon(R.drawable.tunestr, "Tunestr", Modifier.padding(start = 1.dp, bottom = 1.dp, top = 1.dp)) +val weed = HashtagIcon(R.drawable.weed, "Weed", Modifier.padding(start = 1.dp, bottom = 0.dp, top = 0.dp)) + @Immutable class HashtagIcon( val icon: Int, val description: String, - val color: Color, - val modifier: Modifier, + val modifier: Modifier = Modifier, ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt index 97f90b808..4d8a325db 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt @@ -304,7 +304,7 @@ private fun RenderRegular( @OptIn(ExperimentalLayoutApi::class) @Composable -private fun RenderRegular( +fun RenderRegular( content: String, tags: ImmutableListOfLists, wordRenderer: @Composable (Segment, RichTextViewerState) -> Unit, @@ -713,45 +713,38 @@ fun HashTag( val primary = MaterialTheme.colorScheme.primary val background = MaterialTheme.colorScheme.onBackground val hashtagIcon: HashtagIcon? = - remember(segment.segmentText) { checkForHashtagWithIcon(segment.hashtag, primary) } - - val regularText = remember { SpanStyle(color = background) } - val clickableTextStyle = remember { SpanStyle(color = primary) } + remember(segment.segmentText) { checkForHashtagWithIcon(segment.hashtag) } val annotatedTermsString = remember(segment.segmentText) { buildAnnotatedString { - withStyle(clickableTextStyle) { + withStyle(SpanStyle(color = primary)) { pushStringAnnotation("routeToHashtag", "") append("#${segment.hashtag}") pop() } if (hashtagIcon != null) { - withStyle(clickableTextStyle) { + withStyle(SpanStyle(color = primary)) { pushStringAnnotation("routeToHashtag", "") appendInlineContent("inlineContent", "[icon]") pop() } } - segment.extras?.let { withStyle(regularText) { append(it) } } + segment.extras?.let { withStyle(SpanStyle(color = background)) { append(it) } } } } - val inlineContent = - if (hashtagIcon != null) { - mapOf("inlineContent" to InlineIcon(hashtagIcon)) - } else { - emptyMap() - } - - val pressIndicator = remember { Modifier.clickable { nav("Hashtag/${segment.hashtag}") } } - Text( text = annotatedTermsString, - modifier = pressIndicator, - inlineContent = inlineContent, + modifier = remember { Modifier.clickable { nav("Hashtag/${segment.hashtag}") } }, + inlineContent = + if (hashtagIcon != null) { + mapOf("inlineContent" to InlineIcon(hashtagIcon)) + } else { + emptyMap() + }, ) } @@ -767,7 +760,7 @@ private fun InlineIcon(hashtagIcon: HashtagIcon) = Icon( painter = painterResource(hashtagIcon.icon), contentDescription = hashtagIcon.description, - tint = hashtagIcon.color, + tint = Color.Unspecified, modifier = hashtagIcon.modifier, ) } diff --git a/app/src/main/res/drawable-xxxhdpi/footstr.xml b/app/src/main/res/drawable-xxxhdpi/footstr.xml deleted file mode 100644 index 581eafc70..000000000 --- a/app/src/main/res/drawable-xxxhdpi/footstr.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable-xxxhdpi/grownostr.xml b/app/src/main/res/drawable-xxxhdpi/grownostr.xml deleted file mode 100644 index 83dcb6f98..000000000 --- a/app/src/main/res/drawable-xxxhdpi/grownostr.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/cashu.xml b/app/src/main/res/drawable/cashu.xml index 46f884c4f..17cbf26a2 100644 --- a/app/src/main/res/drawable/cashu.xml +++ b/app/src/main/res/drawable/cashu.xml @@ -1,28 +1,11 @@ - - - - - - - - \ No newline at end of file + + + + + + + + + + + diff --git a/app/src/main/res/drawable/coffee.xml b/app/src/main/res/drawable/coffee.xml index 61cf17545..9ca63366e 100644 --- a/app/src/main/res/drawable/coffee.xml +++ b/app/src/main/res/drawable/coffee.xml @@ -1,1183 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/footstr.xml b/app/src/main/res/drawable/footstr.xml new file mode 100644 index 000000000..fdfb5f2c6 --- /dev/null +++ b/app/src/main/res/drawable/footstr.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/grownostr.xml b/app/src/main/res/drawable/grownostr.xml new file mode 100644 index 000000000..65d5dd944 --- /dev/null +++ b/app/src/main/res/drawable/grownostr.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ht_lightning.xml b/app/src/main/res/drawable/ht_lightning.xml deleted file mode 100644 index cb20a135b..000000000 --- a/app/src/main/res/drawable/ht_lightning.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/lightning.xml b/app/src/main/res/drawable/lightning.xml index 4c0d3a694..ec5db36fe 100644 --- a/app/src/main/res/drawable/lightning.xml +++ b/app/src/main/res/drawable/lightning.xml @@ -1,12 +1,15 @@ - - - + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/plebs.xml b/app/src/main/res/drawable/plebs.xml index 62c67abc0..c7e77854a 100644 --- a/app/src/main/res/drawable/plebs.xml +++ b/app/src/main/res/drawable/plebs.xml @@ -1,260 +1,11 @@ - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + diff --git a/app/src/main/res/drawable/skull.xml b/app/src/main/res/drawable/skull.xml index 0a0724a74..87decd067 100644 --- a/app/src/main/res/drawable/skull.xml +++ b/app/src/main/res/drawable/skull.xml @@ -1,4788 +1,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/tunestr.xml b/app/src/main/res/drawable/tunestr.xml index 7a352ffea..ccfb57be0 100644 --- a/app/src/main/res/drawable/tunestr.xml +++ b/app/src/main/res/drawable/tunestr.xml @@ -5,27 +5,27 @@ android:viewportHeight="600"> diff --git a/app/src/main/res/drawable/weed.xml b/app/src/main/res/drawable/weed.xml index 8453abdc4..ff4df15c1 100644 --- a/app/src/main/res/drawable/weed.xml +++ b/app/src/main/res/drawable/weed.xml @@ -1,140 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/app/src/main/res/drawable/zap.xml b/app/src/main/res/drawable/zap.xml index dfa2a311b..d0eea7a74 100644 --- a/app/src/main/res/drawable/zap.xml +++ b/app/src/main/res/drawable/zap.xml @@ -1,32 +1,9 @@ - - - - - - - - - - \ No newline at end of file + + + + + + + + +