extract duplicated string literals into named constants
This commit is contained in:
@@ -48,6 +48,9 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.Icon
|
||||
import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols
|
||||
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
|
||||
|
||||
private const val LABEL_HANG_UP = "Hang up"
|
||||
private const val LABEL_CALLING = "Calling…"
|
||||
|
||||
// ---- Shared building blocks for previews ----
|
||||
|
||||
@Composable
|
||||
@@ -172,7 +175,7 @@ private fun PreviewCallControls(
|
||||
shape = CircleShape,
|
||||
modifier = Modifier.size(64.dp),
|
||||
) {
|
||||
Icon(MaterialSymbols.CallEnd, "Hang up", tint = Color.White, modifier = Modifier.size(32.dp))
|
||||
Icon(MaterialSymbols.CallEnd, LABEL_HANG_UP, tint = Color.White, modifier = Modifier.size(32.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +210,7 @@ private fun PreviewCallInProgress(
|
||||
shape = CircleShape,
|
||||
modifier = Modifier.size(64.dp),
|
||||
) {
|
||||
Icon(MaterialSymbols.CallEnd, "Hang up", tint = Color.White, modifier = Modifier.size(32.dp))
|
||||
Icon(MaterialSymbols.CallEnd, LABEL_HANG_UP, tint = Color.White, modifier = Modifier.size(32.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,7 +220,7 @@ private fun PreviewCallInProgress(
|
||||
@Composable
|
||||
fun PreviewCallingScreen() {
|
||||
ThemeComparisonColumn {
|
||||
PreviewCallInProgress("Alice", "Calling\u2026")
|
||||
PreviewCallInProgress("Alice", LABEL_CALLING)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +245,7 @@ fun PreviewCallingGroupScreen() {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text("Alice, Bob +1", fontWeight = FontWeight.Bold, fontSize = 20.sp)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text("Calling\u2026", color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 16.sp)
|
||||
Text(LABEL_CALLING, color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 16.sp)
|
||||
Spacer(modifier = Modifier.height(48.dp))
|
||||
FloatingActionButton(
|
||||
onClick = {},
|
||||
@@ -250,7 +253,7 @@ fun PreviewCallingGroupScreen() {
|
||||
shape = CircleShape,
|
||||
modifier = Modifier.size(64.dp),
|
||||
) {
|
||||
Icon(MaterialSymbols.CallEnd, "Hang up", tint = Color.White, modifier = Modifier.size(32.dp))
|
||||
Icon(MaterialSymbols.CallEnd, LABEL_HANG_UP, tint = Color.White, modifier = Modifier.size(32.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -580,7 +583,7 @@ fun PreviewPipCallUI() {
|
||||
) {
|
||||
Icon(MaterialSymbols.Person, contentDescription = null, modifier = Modifier.size(48.dp))
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text("Calling\u2026", fontSize = 10.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Text(LABEL_CALLING, fontSize = 10.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-7
@@ -39,6 +39,8 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
private const val NOSTR_URI_PREFIX = "nostr:"
|
||||
|
||||
/**
|
||||
* INav for screens that live inside a free-standing Activity (no Compose
|
||||
* NavHost in scope) and need to dispatch navigation requests back to
|
||||
@@ -127,31 +129,31 @@ class BouncingIntentNav(
|
||||
private fun routeToBouncingUri(route: Route): String? =
|
||||
when (route) {
|
||||
is Route.Profile -> {
|
||||
"nostr:" + NPub.create(route.id)
|
||||
NOSTR_URI_PREFIX + NPub.create(route.id)
|
||||
}
|
||||
|
||||
is Route.Note -> {
|
||||
"nostr:" + NEvent.create(route.id, null, null, null)
|
||||
NOSTR_URI_PREFIX + NEvent.create(route.id, null, null, null)
|
||||
}
|
||||
|
||||
is Route.EventRedirect -> {
|
||||
"nostr:" + NEvent.create(route.id, null, null, null)
|
||||
NOSTR_URI_PREFIX + NEvent.create(route.id, null, null, null)
|
||||
}
|
||||
|
||||
is Route.Hashtag -> {
|
||||
"nostr:hashtag?id=" + route.hashtag
|
||||
NOSTR_URI_PREFIX + "hashtag?id=" + route.hashtag
|
||||
}
|
||||
|
||||
is Route.LiveActivityChannel -> {
|
||||
"nostr:" + NAddress.create(route.kind, route.pubKeyHex, route.dTag, null)
|
||||
NOSTR_URI_PREFIX + NAddress.create(route.kind, route.pubKeyHex, route.dTag, null)
|
||||
}
|
||||
|
||||
is Route.Community -> {
|
||||
"nostr:" + NAddress.create(route.kind, route.pubKeyHex, route.dTag, null)
|
||||
NOSTR_URI_PREFIX + NAddress.create(route.kind, route.pubKeyHex, route.dTag, null)
|
||||
}
|
||||
|
||||
is Route.PublicChatChannel -> {
|
||||
"nostr:" + NEvent.create(route.id, null, ChannelCreateEvent.KIND, null)
|
||||
NOSTR_URI_PREFIX + NEvent.create(route.id, null, ChannelCreateEvent.KIND, null)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
+11
-6
@@ -44,11 +44,16 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
private const val SAMPLE_PUBKEY_FRAGMENT =
|
||||
"\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\","
|
||||
|
||||
private const val SAMPLE_KIND_20_FRAGMENT = "\"kind\":20,"
|
||||
|
||||
private const val SAMPLE_PICTURE_EVENT_JSON =
|
||||
"{\"id\":\"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2\"," +
|
||||
"\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\"," +
|
||||
SAMPLE_PUBKEY_FRAGMENT +
|
||||
"\"created_at\":1708695717," +
|
||||
"\"kind\":20," +
|
||||
SAMPLE_KIND_20_FRAGMENT +
|
||||
"\"tags\":[[\"title\",\"Sunset at the Beach\"]," +
|
||||
"[\"imeta\",\"url https://image.nostr.build/sample-sunset.jpg\"," +
|
||||
"\"m image/jpeg\",\"dim 1200x800\",\"alt A beautiful sunset over the ocean\"," +
|
||||
@@ -58,9 +63,9 @@ private const val SAMPLE_PICTURE_EVENT_JSON =
|
||||
|
||||
private const val SAMPLE_PICTURE_EVENT_NO_TITLE_JSON =
|
||||
"{\"id\":\"b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\"," +
|
||||
"\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\"," +
|
||||
SAMPLE_PUBKEY_FRAGMENT +
|
||||
"\"created_at\":1708695000," +
|
||||
"\"kind\":20," +
|
||||
SAMPLE_KIND_20_FRAGMENT +
|
||||
"\"tags\":[[\"imeta\",\"url https://image.nostr.build/sample-mountain.jpg\"," +
|
||||
"\"m image/jpeg\",\"dim 1080x1080\",\"alt Mountain landscape\"]]," +
|
||||
"\"content\":\"Mountain vibes today. Fresh air and clear skies.\"," +
|
||||
@@ -68,9 +73,9 @@ private const val SAMPLE_PICTURE_EVENT_NO_TITLE_JSON =
|
||||
|
||||
private const val SAMPLE_MULTI_IMAGE_EVENT_JSON =
|
||||
"{\"id\":\"c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"," +
|
||||
"\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\"," +
|
||||
SAMPLE_PUBKEY_FRAGMENT +
|
||||
"\"created_at\":1708694000," +
|
||||
"\"kind\":20," +
|
||||
SAMPLE_KIND_20_FRAGMENT +
|
||||
"\"tags\":[[\"title\",\"Travel Photos\"]," +
|
||||
"[\"imeta\",\"url https://image.nostr.build/sample-travel1.jpg\"," +
|
||||
"\"m image/jpeg\",\"dim 800x600\",\"alt City street\"]," +
|
||||
|
||||
Reference in New Issue
Block a user