Define a constants instead of duplicating String literals

This commit is contained in:
davotoula
2026-03-03 09:54:54 +00:00
parent 0370e51e57
commit b1a1ccc145
6 changed files with 77 additions and 56 deletions
@@ -117,6 +117,8 @@ fun RenderContentAsMarkdown(
} }
} }
private const val PREVIEW_CALLBACK_URI = "nostr:something"
@Preview @Preview
@Composable @Composable
fun RenderContentAsMarkdownPreview() { fun RenderContentAsMarkdownPreview() {
@@ -162,7 +164,7 @@ fun RenderContentAsMarkdownPreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -212,7 +214,7 @@ fun RenderContentAsMarkdownListsPreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -266,7 +268,7 @@ fun RenderContentAsMarkdownCodePreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -306,7 +308,7 @@ fun RenderContentAsMarkdownTablesPreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -344,7 +346,7 @@ fun RenderContentAsMarkdownFootNotesPreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -405,7 +407,7 @@ fun RenderContentAsMarkdownUserPreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -455,7 +457,7 @@ fun RenderContentAsMarkdownNotePreview() {
remember { remember {
mutableStateOf(background) mutableStateOf(background)
}, },
callbackUri = "nostr:something", callbackUri = PREVIEW_CALLBACK_URI,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -51,6 +51,9 @@ import com.vitorpamplona.amethyst.ui.theme.Size55Modifier
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.quartz.utils.TimeUtils import com.vitorpamplona.quartz.utils.TimeUtils
private const val PREVIEW_AUTHOR = "This is my author"
private const val PREVIEW_MESSAGE = "This is a message from this person"
@Composable @Composable
@Preview @Preview
fun ChannelNamePreview() { fun ChannelNamePreview() {
@@ -65,11 +68,11 @@ fun ChannelNamePreview() {
) )
}, },
firstRow = { firstRow = {
Text("This is my author", Modifier.weight(1f)) Text(PREVIEW_AUTHOR, Modifier.weight(1f))
TimeAgo(TimeUtils.now()) TimeAgo(TimeUtils.now())
}, },
secondRow = { secondRow = {
Text("This is a message from this person", Modifier.weight(1f)) Text(PREVIEW_MESSAGE, Modifier.weight(1f))
Spacer(modifier = Height4dpModifier) Spacer(modifier = Height4dpModifier)
NewItemsBubble() NewItemsBubble()
}, },
@@ -81,13 +84,13 @@ fun ChannelNamePreview() {
ListItem( ListItem(
headlineContent = { headlineContent = {
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Text("This is my author", Modifier.weight(1f)) Text(PREVIEW_AUTHOR, Modifier.weight(1f))
TimeAgo(TimeUtils.now()) TimeAgo(TimeUtils.now())
} }
}, },
supportingContent = { supportingContent = {
Row { Row {
Text("This is a message from this person", Modifier.weight(1f)) Text(PREVIEW_MESSAGE, Modifier.weight(1f))
NewItemsBubble() NewItemsBubble()
} }
}, },
@@ -106,13 +109,13 @@ fun ChannelNamePreview() {
SlimListItem( SlimListItem(
headlineContent = { headlineContent = {
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Text("This is my author", Modifier.weight(1f)) Text(PREVIEW_AUTHOR, Modifier.weight(1f))
TimeAgo(TimeUtils.now()) TimeAgo(TimeUtils.now())
} }
}, },
supportingContent = { supportingContent = {
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Text("This is a message from this person", Modifier.weight(1f)) Text(PREVIEW_MESSAGE, Modifier.weight(1f))
NewItemsBubble() NewItemsBubble()
} }
}, },
@@ -80,6 +80,9 @@ import kotlin.math.max
* This is a copy of Material3's ListItemLayout.kt file, with the only change being the padding change from 16.dp to 10.dp * This is a copy of Material3's ListItemLayout.kt file, with the only change being the padding change from 16.dp to 10.dp
*/ */
private const val PREVIEW_AUTHOR = "This is my author"
private const val PREVIEW_MESSAGE = "This is a message from this person"
@Composable @Composable
@Preview @Preview
fun ChannelNamePreview() { fun ChannelNamePreview() {
@@ -94,11 +97,11 @@ fun ChannelNamePreview() {
) )
}, },
firstRow = { firstRow = {
Text("This is my author", Modifier.weight(1f)) Text(PREVIEW_AUTHOR, Modifier.weight(1f))
TimeAgo(TimeUtils.now()) TimeAgo(TimeUtils.now())
}, },
secondRow = { secondRow = {
Text("This is a message from this person", Modifier.weight(1f)) Text(PREVIEW_MESSAGE, Modifier.weight(1f))
NewItemsBubble() NewItemsBubble()
}, },
onClick = {}, onClick = {},
@@ -109,13 +112,13 @@ fun ChannelNamePreview() {
SlimListItem( SlimListItem(
headlineContent = { headlineContent = {
Row(verticalAlignment = CenterVertically) { Row(verticalAlignment = CenterVertically) {
Text("This is my author", Modifier.weight(1f)) Text(PREVIEW_AUTHOR, Modifier.weight(1f))
TimeAgo(TimeUtils.now()) TimeAgo(TimeUtils.now())
} }
}, },
supportingContent = { supportingContent = {
Row(verticalAlignment = CenterVertically) { Row(verticalAlignment = CenterVertically) {
Text("This is a message from this person", Modifier.weight(1f)) Text(PREVIEW_MESSAGE, Modifier.weight(1f))
Spacer(modifier = Height4dpModifier) Spacer(modifier = Height4dpModifier)
NewItemsBubble() NewItemsBubble()
} }
@@ -135,13 +138,13 @@ fun ChannelNamePreview() {
ListItem( ListItem(
headlineContent = { headlineContent = {
Row(verticalAlignment = CenterVertically) { Row(verticalAlignment = CenterVertically) {
Text("This is my author", Modifier.weight(1f)) Text(PREVIEW_AUTHOR, Modifier.weight(1f))
TimeAgo(TimeUtils.now()) TimeAgo(TimeUtils.now())
} }
}, },
supportingContent = { supportingContent = {
Row(verticalAlignment = CenterVertically) { Row(verticalAlignment = CenterVertically) {
Text("This is a message from this person", Modifier.weight(1f)) Text(PREVIEW_MESSAGE, Modifier.weight(1f))
Spacer(modifier = Height4dpModifier) Spacer(modifier = Height4dpModifier)
NewItemsBubble() NewItemsBubble()
} }
@@ -1542,33 +1542,38 @@ fun ReactionChoicePopupContent(
} }
} }
private const val EMOJI_ROCKET = "\uD83D\uDE80"
private const val EMOJI_THINKING = "\uD83E\uDD14"
private const val EMOJI_SCREAM = "\uD83D\uDE31"
private const val EMOJI_PARTY = "\uD83C\uDF89"
@Preview() @Preview()
@Composable @Composable
fun ReactionChoicePopupPeeview() { fun ReactionChoicePopupPeeview() {
ThemeComparisonColumn { ThemeComparisonColumn {
ReactionChoicePopupContent( ReactionChoicePopupContent(
persistentListOf( persistentListOf(
"\uD83D\uDE80", EMOJI_ROCKET,
"\uD83E\uDEC2", "\uD83E\uDEC2",
"\uD83D\uDC40", "\uD83D\uDC40",
"\uD83D\uDE02", "\uD83D\uDE02",
"\uD83C\uDF89", EMOJI_PARTY,
"\uD83E\uDD14", EMOJI_THINKING,
"\uD83D\uDE31", EMOJI_SCREAM,
"\uD83E\uDD14", EMOJI_THINKING,
"\uD83D\uDE31", EMOJI_SCREAM,
"+", "+",
"-", "-",
"\uD83C\uDF89", EMOJI_PARTY,
"\uD83E\uDD14", EMOJI_THINKING,
"\uD83D\uDE31", EMOJI_SCREAM,
"\uD83E\uDD14", EMOJI_THINKING,
"\uD83D\uDE31", EMOJI_SCREAM,
"\uD83D\uDE80\uDB40\uDD58\uDB40\uDD64\uDB40\uDD64\uDB40\uDD60\uDB40\uDD63\uDB40\uDD2A\uDB40\uDD1F\uDB40\uDD1F\uDB40\uDD53\uDB40\uDD54\uDB40\uDD5E\uDB40\uDD1E\uDB40\uDD63\uDB40\uDD51\uDB40\uDD64\uDB40\uDD55\uDB40\uDD5C\uDB40\uDD5C\uDB40\uDD59\uDB40\uDD64\uDB40\uDD55\uDB40\uDD1E\uDB40\uDD55\uDB40\uDD51\uDB40\uDD62\uDB40\uDD64\uDB40\uDD58\uDB40\uDD1F\uDB40\uDD29\uDB40\uDD24\uDB40\uDD27\uDB40\uDD55\uDB40\uDD24\uDB40\uDD51\uDB40\uDD52\uDB40\uDD22\uDB40\uDD54\uDB40\uDD23\uDB40\uDD21\uDB40\uDD21\uDB40\uDD25\uDB40\uDD52\uDB40\uDD55\uDB40\uDD25\uDB40\uDD26\uDB40\uDD25\uDB40\uDD51\uDB40\uDD24\uDB40\uDD29\uDB40\uDD53\uDB40\uDD56\uDB40\uDD25\uDB40\uDD54\uDB40\uDD52\uDB40\uDD20\uDB40\uDD22\uDB40\uDD25\uDB40\uDD25\uDB40\uDD29\uDB40\uDD56\uDB40\uDD23\uDB40\uDD21\uDB40\uDD20\uDB40\uDD53\uDB40\uDD51\uDB40\uDD20\uDB40\uDD51\uDB40\uDD26\uDB40\uDD54\uDB40\uDD54\uDB40\uDD56\uDB40\uDD54\uDB40\uDD54\uDB40\uDD52\uDB40\uDD54\uDB40\uDD24\uDB40\uDD52\uDB40\uDD54\uDB40\uDD28\uDB40\uDD53\uDB40\uDD52\uDB40\uDD55\uDB40\uDD53\uDB40\uDD24\uDB40\uDD24\uDB40\uDD29\uDB40\uDD29\uDB40\uDD25\uDB40\uDD53\uDB40\uDD22\uDB40\uDD55\uDB40\uDD27\uDB40\uDD1E\uDB40\uDD67\uDB40\uDD55\uDB40\uDD52\uDB40\uDD60", "\uD83D\uDE80\uDB40\uDD58\uDB40\uDD64\uDB40\uDD64\uDB40\uDD60\uDB40\uDD63\uDB40\uDD2A\uDB40\uDD1F\uDB40\uDD1F\uDB40\uDD53\uDB40\uDD54\uDB40\uDD5E\uDB40\uDD1E\uDB40\uDD63\uDB40\uDD51\uDB40\uDD64\uDB40\uDD55\uDB40\uDD5C\uDB40\uDD5C\uDB40\uDD59\uDB40\uDD64\uDB40\uDD55\uDB40\uDD1E\uDB40\uDD55\uDB40\uDD51\uDB40\uDD62\uDB40\uDD64\uDB40\uDD58\uDB40\uDD1F\uDB40\uDD29\uDB40\uDD24\uDB40\uDD27\uDB40\uDD55\uDB40\uDD24\uDB40\uDD51\uDB40\uDD52\uDB40\uDD22\uDB40\uDD54\uDB40\uDD23\uDB40\uDD21\uDB40\uDD21\uDB40\uDD25\uDB40\uDD52\uDB40\uDD55\uDB40\uDD25\uDB40\uDD26\uDB40\uDD25\uDB40\uDD51\uDB40\uDD24\uDB40\uDD29\uDB40\uDD53\uDB40\uDD56\uDB40\uDD25\uDB40\uDD54\uDB40\uDD52\uDB40\uDD20\uDB40\uDD22\uDB40\uDD25\uDB40\uDD25\uDB40\uDD29\uDB40\uDD56\uDB40\uDD23\uDB40\uDD21\uDB40\uDD20\uDB40\uDD53\uDB40\uDD51\uDB40\uDD20\uDB40\uDD51\uDB40\uDD26\uDB40\uDD54\uDB40\uDD54\uDB40\uDD56\uDB40\uDD54\uDB40\uDD54\uDB40\uDD52\uDB40\uDD54\uDB40\uDD24\uDB40\uDD52\uDB40\uDD54\uDB40\uDD28\uDB40\uDD53\uDB40\uDD52\uDB40\uDD55\uDB40\uDD53\uDB40\uDD24\uDB40\uDD24\uDB40\uDD29\uDB40\uDD29\uDB40\uDD25\uDB40\uDD53\uDB40\uDD22\uDB40\uDD55\uDB40\uDD27\uDB40\uDD1E\uDB40\uDD67\uDB40\uDD55\uDB40\uDD52\uDB40\uDD60",
), ),
onClick = {}, onClick = {},
onChangeAmount = {}, onChangeAmount = {},
toRemove = persistentSetOf("\uD83D\uDE80", "\uD83E\uDD14", "\uD83D\uDE31"), toRemove = persistentSetOf(EMOJI_ROCKET, EMOJI_THINKING, EMOJI_SCREAM),
) )
} }
} }
@@ -433,6 +433,10 @@ fun ObserveAndDrawInnerUserPicture(
) )
} }
private const val PREVIEW_USER_HEX = "989c3734c46abac7ce3ce229971581a5a6ee39cdd6aa7261a55823fa7f8c4799"
private const val PREVIEW_PICTURE_URL = "http://null"
private const val PREVIEW_USER_NAME = "vitor"
@Preview @Preview
@Composable @Composable
fun ScoreTag55Preview() { fun ScoreTag55Preview() {
@@ -442,9 +446,9 @@ fun ScoreTag55Preview() {
var size = 75.dp var size = 75.dp
Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) { Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) {
InnerUserPicture( InnerUserPicture(
userHex = "989c3734c46abac7ce3ce229971581a5a6ee39cdd6aa7261a55823fa7f8c4799", userHex = PREVIEW_USER_HEX,
userPicture = "http://null", userPicture = PREVIEW_PICTURE_URL,
userName = "vitor", userName = PREVIEW_USER_NAME,
size = size, size = size,
modifier = Modifier, modifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@@ -455,9 +459,9 @@ fun ScoreTag55Preview() {
size = 55.dp size = 55.dp
Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) { Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) {
InnerUserPicture( InnerUserPicture(
userHex = "989c3734c46abac7ce3ce229971581a5a6ee39cdd6aa7261a55823fa7f8c4799", userHex = PREVIEW_USER_HEX,
userPicture = "http://null", userPicture = PREVIEW_PICTURE_URL,
userName = "vitor", userName = PREVIEW_USER_NAME,
size = size, size = size,
modifier = Modifier, modifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@@ -468,9 +472,9 @@ fun ScoreTag55Preview() {
size = 35.dp size = 35.dp
Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) { Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) {
InnerUserPicture( InnerUserPicture(
userHex = "989c3734c46abac7ce3ce229971581a5a6ee39cdd6aa7261a55823fa7f8c4799", userHex = PREVIEW_USER_HEX,
userPicture = "http://null", userPicture = PREVIEW_PICTURE_URL,
userName = "vitor", userName = PREVIEW_USER_NAME,
size = size, size = size,
modifier = Modifier, modifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@@ -481,9 +485,9 @@ fun ScoreTag55Preview() {
size = 25.dp size = 25.dp
Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) { Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) {
InnerUserPicture( InnerUserPicture(
userHex = "989c3734c46abac7ce3ce229971581a5a6ee39cdd6aa7261a55823fa7f8c4799", userHex = PREVIEW_USER_HEX,
userPicture = "http://null", userPicture = PREVIEW_PICTURE_URL,
userName = "vitor", userName = PREVIEW_USER_NAME,
size = size, size = size,
modifier = Modifier, modifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@@ -495,8 +499,8 @@ fun ScoreTag55Preview() {
Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) { Box(Modifier.size(size), contentAlignment = Alignment.TopEnd) {
InnerUserPicture( InnerUserPicture(
userHex = "AABBCC", userHex = "AABBCC",
userPicture = "http://null", userPicture = PREVIEW_PICTURE_URL,
userName = "vitor", userName = PREVIEW_USER_NAME,
size = size, size = size,
modifier = Modifier, modifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@@ -71,6 +71,10 @@ import com.vitorpamplona.amethyst.ui.theme.SpacedBy2dp
import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
private const val PREVIEW_LIST_TITLE = "Sample List Title"
private const val PREVIEW_LIST_DESCRIPTION = "Sample List Description"
private const val PREVIEW_LIST_IMAGE = "http://some.com/image.png"
@Preview() @Preview()
@Composable @Composable
private fun PeopleListItemPreview() { private fun PeopleListItemPreview() {
@@ -82,8 +86,8 @@ private fun PeopleListItemPreview() {
PeopleList( PeopleList(
identifierTag = "00001-2222", identifierTag = "00001-2222",
title = "Sample List Title, Very long title, very very very long", title = "Sample List Title, Very long title, very very very long",
description = "Sample List Description", description = PREVIEW_LIST_DESCRIPTION,
image = "http://some.com/image.png", image = PREVIEW_LIST_IMAGE,
emptySet(), emptySet(),
emptySet(), emptySet(),
) )
@@ -91,9 +95,9 @@ private fun PeopleListItemPreview() {
val samplePeopleList2 = val samplePeopleList2 =
PeopleList( PeopleList(
identifierTag = "00001-2223", identifierTag = "00001-2223",
title = "Sample List Title", title = PREVIEW_LIST_TITLE,
description = "Sample List Description", description = PREVIEW_LIST_DESCRIPTION,
image = "http://some.com/image.png", image = PREVIEW_LIST_IMAGE,
setOf(user1, user3), setOf(user1, user3),
emptySet(), emptySet(),
) )
@@ -101,9 +105,9 @@ private fun PeopleListItemPreview() {
val samplePeopleList3 = val samplePeopleList3 =
PeopleList( PeopleList(
identifierTag = "00001-2224", identifierTag = "00001-2224",
title = "Sample List Title", title = PREVIEW_LIST_TITLE,
description = "Sample List Description", description = PREVIEW_LIST_DESCRIPTION,
image = "http://some.com/image.png", image = PREVIEW_LIST_IMAGE,
emptySet(), emptySet(),
setOf(user1, user3), setOf(user1, user3),
) )
@@ -111,9 +115,9 @@ private fun PeopleListItemPreview() {
val samplePeopleList4 = val samplePeopleList4 =
PeopleList( PeopleList(
identifierTag = "00001-2225", identifierTag = "00001-2225",
title = "Sample List Title", title = PREVIEW_LIST_TITLE,
description = "Sample List Description", description = PREVIEW_LIST_DESCRIPTION,
image = "http://some.com/image.png", image = PREVIEW_LIST_IMAGE,
setOf(user3), setOf(user3),
setOf(user1, user2, user3), setOf(user1, user2, user3),
) )