Moving preview EmptyNav to a class to avoid Nav auto-imports in production code.

This commit is contained in:
Vitor Pamplona
2025-11-10 11:17:04 -05:00
parent 948180157f
commit 011aebfc27
25 changed files with 39 additions and 42 deletions
@@ -64,7 +64,7 @@ fun RenderHashTagIconsPreview() {
) { paragraph, state, spaceWidth, modifier ->
RenderTextParagraph(paragraph, spaceWidth, modifier) { word ->
when (word) {
is HashTagSegment -> HashTag(word, EmptyNav)
is HashTagSegment -> HashTag(word, EmptyNav())
is RegularTextSegment -> Text(word.segmentText)
}
}
@@ -192,11 +192,11 @@ fun RenderRegularPreview() {
"",
1,
route = Route.EventRedirect(word.segmentText),
nav = EmptyNav,
nav = EmptyNav(),
)
}
is HashTagSegment -> HashTag(word, EmptyNav)
is HashTagSegment -> HashTag(word, EmptyNav())
// is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
// is HashIndexEventSegment -> TagLink(word, true, backgroundColorState, accountViewModel, nav)
is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
@@ -225,7 +225,7 @@ fun RenderRegularPreview2() {
is EmailSegment -> ClickableEmail(word.segmentText)
is PhoneSegment -> ClickablePhone(word.segmentText)
// is BechSegment -> BechLink(word.segmentText, true, backgroundColor, accountViewModel, nav)
is HashTagSegment -> HashTag(word, EmptyNav)
is HashTagSegment -> HashTag(word, EmptyNav())
// is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
// is HashIndexEventSegment -> TagLink(word, true, backgroundColorState, accountViewModel, nav)
is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
@@ -267,7 +267,7 @@ fun RenderRegularPreview3() {
is EmailSegment -> ClickableEmail(word.segmentText)
is PhoneSegment -> ClickablePhone(word.segmentText)
// is BechSegment -> BechLink(word.segmentText, true, backgroundColor, accountViewModel, nav)
is HashTagSegment -> HashTag(word, EmptyNav)
is HashTagSegment -> HashTag(word, EmptyNav())
// is HashIndexUserSegment -> TagLink(word, accountViewModel, nav)
// is HashIndexEventSegment -> TagLink(word, true, backgroundColorState, accountViewModel, nav)
is SchemelessUrlSegment -> NoProtocolUrlRenderer(word)
@@ -122,7 +122,7 @@ fun RenderContentAsMarkdown(
fun RenderContentAsMarkdownPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonRow {
val background = MaterialTheme.colorScheme.background
@@ -174,7 +174,7 @@ fun RenderContentAsMarkdownPreview() {
fun RenderContentAsMarkdownListsPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonRow {
val background = MaterialTheme.colorScheme.background
@@ -224,7 +224,7 @@ fun RenderContentAsMarkdownListsPreview() {
fun RenderContentAsMarkdownCodePreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonRow {
val background = MaterialTheme.colorScheme.background
@@ -278,7 +278,7 @@ fun RenderContentAsMarkdownCodePreview() {
fun RenderContentAsMarkdownTablesPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonRow {
val background = MaterialTheme.colorScheme.background
@@ -319,7 +319,7 @@ fun RenderContentAsMarkdownTablesPreview() {
fun RenderContentAsMarkdownFootNotesPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonRow {
val background = MaterialTheme.colorScheme.background
@@ -356,7 +356,7 @@ fun RenderContentAsMarkdownFootNotesPreview() {
fun RenderContentAsMarkdownUserPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
runBlocking {
withContext(Dispatchers.IO) {
@@ -418,7 +418,7 @@ fun RenderContentAsMarkdownUserPreview() {
fun RenderContentAsMarkdownNotePreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
runBlocking {
withContext(Dispatchers.IO) {
@@ -90,7 +90,7 @@ fun ErrorListPreview() {
ErrorList(
model = model,
accountViewModel = accountViewModel,
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -49,7 +49,7 @@ import kotlinx.coroutines.withContext
@Preview
fun MultiUserErrorMessageContentPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
var user1: User? = null
var user2: User? = null
@@ -29,7 +29,7 @@ import kotlinx.coroutines.runBlocking
import kotlin.reflect.KClass
@Stable
object EmptyNav : INav {
class EmptyNav : INav {
override val navigationScope: CoroutineScope get() = TODO("Not yet implemented")
override val drawerState = DrawerState(DrawerValue.Closed)
@@ -95,16 +95,13 @@ fun BlankNote(
@Composable
@Preview
fun HiddenNotePreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
ThemeComparisonColumn(
toPreview = {
HiddenNote(
reports = persistentSetOf<Note>(),
isHiddenAuthor = true,
accountViewModel = accountViewModel,
nav = nav,
accountViewModel = mockAccountViewModel(),
nav = EmptyNav(),
) {}
},
)
@@ -151,7 +151,7 @@ fun PollNotePreview() {
)
val accountViewModel = mockVitorAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
val baseNote: Note?
runBlocking {
@@ -205,7 +205,7 @@ fun PollNotePreview2() {
)
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
val baseNote: Note?
runBlocking {
@@ -46,7 +46,6 @@ import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNo
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAboutMe
import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem
import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav
import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav.nav
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -104,7 +103,7 @@ fun RenderZapNotePreview() {
user1,
note1,
accountViewModel,
EmptyNav,
EmptyNav(),
)
}
}
@@ -122,7 +121,7 @@ fun RenderZapNoteSlimPreview() {
user1,
note1,
accountViewModel,
EmptyNav,
EmptyNav(),
)
}
}
@@ -60,7 +60,7 @@ fun AddInboxRelayForDMCardPreview() {
ThemeComparisonColumn {
AddInboxRelayForDMCard(
accountViewModel = mockAccountViewModel(),
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -89,7 +89,7 @@ import java.util.Locale
fun RenderLiveActivityEventPreview() {
val event = Event.fromJson("{\"id\":\"19406ad34ce3c653d62eb73c1816ac27dcf473c2ccdccf5af7d90d2633c62561\",\"pubkey\":\"6b66886b3add72c779d205be574ec2d7cec619061ac3e75717389b26445989e4\",\"created_at\":1719084750,\"kind\":30311,\"tags\":[[\"r\",\"podcast:guid:72d5e069-f907-5ee7-b0d7-45404f4f0aa5\"],[\"r\",\"podcast:item:guid:bfc33d6e-e00f-4f11-a2ff-94865b7867aa\"],[\"d\",\"bfc33d6e-e00f-4f11-a2ff-94865b7867aa\"],[\"title\",\"The Online Identity Time Bomb\"],[\"summary\",\"Online identity is a ticking time bomb. But are trustworthy, open-source solutions ready to disarm it, or will we be stuck with lackluster, proprietary systems?\\n Live chat: https:/jblive.tv\"],[\"streaming\",\"https://jblive.fm\"],[\"starts\",\"1719167400\"],[\"status\",\"planned\"],[\"image\",\"https://station.us-iad-1.linodeobjects.com/art/lup-mp3.jpg\"]],\"content\":\"\",\"sig\":\"2ce3fae9ad4512541aaae4dbd9484f50df62ab95ba935d7512b736f087f151c1d15ec2bf62d3135474f16c3e070f335b24349c5493461873ddca3051804ca944\"}") as LiveActivitiesEvent
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
val baseNote: Note?
runBlocking {
@@ -76,7 +76,7 @@ import kotlin.coroutines.cancellation.CancellationException
@Composable
fun TorrentPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
val torrent =
runBlocking {
@@ -69,7 +69,7 @@ import kotlinx.coroutines.withContext
@Composable
fun TorrentCommentPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
val comment =
runBlocking {
@@ -117,7 +117,7 @@ fun RenderChannelDataPreview() {
tags = EmptyTagList,
bgColor = remember { mutableStateOf(Color.Transparent) },
accountViewModel = mockAccountViewModel(),
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -72,7 +72,7 @@ fun PrivateMessageEditFieldRowPreview() {
channelScreenModel = channelScreenModel,
accountViewModel = accountViewModel,
onSendNewMessage = {},
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -81,7 +81,7 @@ private fun DialogContentPreview() {
ChannelMetadataScaffold(
postViewModel = postViewModel,
accountViewModel = accountViewModel,
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -111,7 +111,7 @@ private fun DialogContentPreview() {
ChannelMetadataScaffold(
postViewModel = postViewModel,
accountViewModel = accountViewModel,
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -108,7 +108,7 @@ fun RenderFollowSetThumb(
@Composable
fun RenderFollowSetThumbPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonColumn(
toPreview = {
@@ -57,7 +57,7 @@ fun AddOutboxRelayCardPreview() {
ThemeComparisonColumn {
AddInboxRelayCard(
accountViewModel = mockAccountViewModel(),
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -378,7 +378,7 @@ fun FollowSetListViewPreview() {
memberList = persistentListOf(user1, user2, user3),
onDeleteUser = { user -> },
accountViewModel = accountViewModel,
nav = EmptyNav,
nav = EmptyNav(),
)
Spacer(HalfVertSpacer)
@@ -56,7 +56,7 @@ fun AddInboxRelayCardPreview() {
ThemeComparisonColumn {
AddInboxRelayCard(
accountViewModel = mockAccountViewModel(),
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -109,7 +109,7 @@ fun ZapTheDevsCardPreview() {
ZapTheDevsCard(
releaseNote,
accountViewModel,
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -56,7 +56,7 @@ fun AddInboxRelayForSearchCardPreview() {
ThemeComparisonColumn {
AddInboxRelayForSearchCard(
accountViewModel = mockAccountViewModel(),
nav = EmptyNav,
nav = EmptyNav(),
)
}
}
@@ -63,7 +63,7 @@ import java.util.Locale as JavaLocale
@Composable
fun UserSettingsScreenPreview() {
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val nav = EmptyNav()
ThemeComparisonRow {
UserSettingsScreen(accountViewModel, nav)
}
@@ -578,7 +578,7 @@ private fun FullBleedNoteCompose(
} else if (noteEvent is PeopleListEvent) {
DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
} else if (noteEvent is FollowListEvent) {
DisplayFollowList(baseNote, backgroundColor, accountViewModel, nav)
DisplayFollowList(baseNote, accountViewModel, nav)
} else if (noteEvent is AudioTrackEvent) {
AudioTrackHeader(noteEvent, baseNote, ContentScale.FillWidth, accountViewModel, nav)
} else if (noteEvent is AudioHeaderEvent) {
@@ -1059,7 +1059,6 @@ private fun RenderLongFormHeaderForThread(
private fun RenderWikiHeaderForThreadPreview() {
val event = Event.fromJson("{\"id\":\"277f982a4cd3f67cc47ad9282176acabee1713848f547d6021e0c155572078e1\",\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\",\"created_at\":1708695717,\"kind\":30818,\"tags\":[[\"d\",\"amethyst\"],[\"a\",\"30818:f03e7c5262648e0b7823dfb49f8f17309cfec9cb14711413dcabdf3d7fc6369a:amethyst\",\"wss://relay.nostr.band\",\"fork\"],[\"e\",\"ceabc60c8022c472c727aa25ae7691885964366386ce265c47e5a78be6cb00be\",\"wss://relay.nostr.band\",\"fork\"],[\"title\",\"Amethyst\"],[\"published_at\",\"1708707133\"]],\"content\":\"An Android-only app written in Kotlin with support for over 90 event kinds. \\n\\n![](https://play-lh.googleusercontent.com/lvZlAm9dBrpHeOo7sIPKCsiKOLYLhR2b0FiOT4tyiwWO2dvsR2gDS0xk9tOOr9U-6uM=w240-h480-rw)\\n\",\"sig\":\"6748126a909a20dbdb67947a09d64e41d7140a79335a4ad675c6173d7dd5dbcab9c360dec617bd67bbbc20dfad416b15056eda2e20716cd6c425a84301a125a0\"}") as WikiNoteEvent
val accountViewModel = mockAccountViewModel()
val nav = EmptyNav
val editState =
remember {
@@ -1072,6 +1071,8 @@ private fun RenderWikiHeaderForThreadPreview() {
}
}
val nav = EmptyNav()
LoadNote(baseNoteHex = "277f982a4cd3f67cc47ad9282176acabee1713848f547d6021e0c155572078e1", accountViewModel = accountViewModel) { baseNote ->
ThemeComparisonColumn {
val bg = MaterialTheme.colorScheme.background