From ad9cb0615b04e553872eec07b8493e946a7b1300 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Tue, 31 Mar 2026 23:58:34 +0200 Subject: [PATCH] Add NostrEventDetailRoute.kt and SearchRoute.kt and manage routes --- .../ui/composable/NostrEventDetailScreen.kt | 48 +++++++++++++++++++ .../aux/compose/ui/composable/SearchScreen.kt | 48 +++++++++++++++++++ .../ui/composable/UnannouncedProfileScreen.kt | 15 +----- .../ui/composable/UnsignedProfileScreen.kt | 24 ++-------- .../ui/composable/navigation/AuxNavHost.kt | 23 ++++++--- .../navigation/routes/CreateProfileRoute.kt | 12 ----- .../routes/NostrEventDetailRoute.kt | 12 +++++ .../navigation/routes/SearchRoute.kt | 6 +++ .../routes/UnannouncedProfileRoute.kt | 11 +---- .../navigation/routes/UnsignedProfileRoute.kt | 10 +--- 10 files changed, 137 insertions(+), 72 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/NostrEventDetailScreen.kt create mode 100644 composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/SearchScreen.kt create mode 100755 composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/NostrEventDetailRoute.kt create mode 100755 composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/SearchRoute.kt diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/NostrEventDetailScreen.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/NostrEventDetailScreen.kt new file mode 100644 index 00000000..d3e76e6f --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/NostrEventDetailScreen.kt @@ -0,0 +1,48 @@ +package ac.aux.compose.ui.composable + +import ac.aux.compose.ui.theme.AuxTheme +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp + +@Composable +fun NostrEventDetailScreen() { + + Scaffold { innerPadding -> + Column( + modifier = Modifier.padding(innerPadding).fillMaxSize() + ) { + Column( + modifier = Modifier.padding(20.dp).fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text( + "\"Nostr Event Detail\" functionality coming soon", + + ) + } + } + } +} + +@Preview +@Composable +private fun NostrEventDetailScreenPreview() { + AuxTheme { + Surface( + modifier = Modifier.padding(20.dp) + ) { + NostrEventDetailScreen() + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/SearchScreen.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/SearchScreen.kt new file mode 100644 index 00000000..70ebb154 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/SearchScreen.kt @@ -0,0 +1,48 @@ +package ac.aux.compose.ui.composable + +import ac.aux.compose.ui.theme.AuxTheme +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp + +@Composable +fun SearchScreen() { + + Scaffold { innerPadding -> + Column( + modifier = Modifier.padding(innerPadding).fillMaxSize() + ) { + Column( + modifier = Modifier.padding(20.dp).fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text( + "\"Search\" functionality coming soon", + + ) + } + } + } +} + +@Preview +@Composable +private fun SearchScreenPreview() { + AuxTheme { + Surface( + modifier = Modifier.padding(20.dp) + ) { + SearchScreen() + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnannouncedProfileScreen.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnannouncedProfileScreen.kt index 472e19a0..7e50ebf9 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnannouncedProfileScreen.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnannouncedProfileScreen.kt @@ -43,9 +43,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun UnannouncedProfileScreen( - nostrEvent: NostrEvent, -) { +fun UnannouncedProfileScreen() { Scaffold { innerPadding -> Column( modifier = Modifier.padding(innerPadding) @@ -99,16 +97,7 @@ private fun UnannouncedProfileScreenPreview() { Surface( modifier = Modifier.fillMaxSize() ) { - UnannouncedProfileScreen( - nostrEvent = NostrEvent( - id = "", - pubKey = "", - kind = 0, - content = "Something here", - tags = emptyArray(), - sig = "" - ), - ) + UnannouncedProfileScreen() } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnsignedProfileScreen.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnsignedProfileScreen.kt index 15e35244..d386c78d 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnsignedProfileScreen.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/UnsignedProfileScreen.kt @@ -45,18 +45,7 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun UnsignedProfileScreen( - unsignedNostrEvent: UnsignedNostrEvent -) { - val metadataEvent = MetadataEvent( - id = unsignedNostrEvent.id.toString(), - pubKey = unsignedNostrEvent.pubKey, - createdAt = unsignedNostrEvent.createdAt.epochSeconds, - tags = unsignedNostrEvent.tags, - content = unsignedNostrEvent.content, - sig = "" - ) - +fun UnsignedProfileScreen() { Scaffold { innerPadding -> Column( modifier = Modifier.padding(innerPadding) @@ -80,7 +69,7 @@ fun UnsignedProfileScreen( ) Text( - text = "As long as you control your keys there can be no dispute about who ${metadataEvent.contactMetaData()?.displayName ?: "YOU"} actually is.", + text = "As long as you control your keys there can be no dispute about who YOU actually is.", style = MaterialTheme.typography.bodySmall, textAlign = TextAlign.Center ) @@ -104,14 +93,7 @@ private fun UnsignedProfileScreenPreview() { Surface( modifier = Modifier.fillMaxSize() ) { - UnsignedProfileScreen( - unsignedNostrEvent = UnsignedNostrEvent( - pubKey = "", - kind = 0, - content = "Something here", - tags = emptyArray(), - ) - ) + UnsignedProfileScreen() } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/AuxNavHost.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/AuxNavHost.kt index c1481843..8f50d911 100644 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/AuxNavHost.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/AuxNavHost.kt @@ -8,6 +8,8 @@ import ac.aux.compose.ui.composable.FeedScreen import ac.aux.compose.ui.composable.ImplementationPendingScreen import ac.aux.compose.ui.composable.LandingScreen import ac.aux.compose.ui.composable.LoadingScreen +import ac.aux.compose.ui.composable.NostrEventDetailScreen +import ac.aux.compose.ui.composable.SearchScreen import ac.aux.compose.ui.composable.SignInToProfileScreen import ac.aux.compose.ui.composable.SocialPreconditionScreen import ac.aux.compose.ui.composable.UnannouncedProfileScreen @@ -23,6 +25,8 @@ import ac.aux.compose.ui.composable.navigation.routes.FeedRoute import ac.aux.compose.ui.composable.navigation.routes.ImplementationPendingRoute import ac.aux.compose.ui.composable.navigation.routes.LandingRoute import ac.aux.compose.ui.composable.navigation.routes.LoadingRoute +import ac.aux.compose.ui.composable.navigation.routes.NostrEventDetailRoute +import ac.aux.compose.ui.composable.navigation.routes.SearchRoute import ac.aux.compose.ui.composable.navigation.routes.SignInRoute import androidx.compose.runtime.Composable import androidx.navigation.NavHostController @@ -245,9 +249,7 @@ fun AuxNavHost( composable { backStackEntry -> val route = backStackEntry.toRoute() - UnsignedProfileScreen( - unsignedNostrEvent = route.toPlaceholderUnsignedNostrEvent() - ) + UnsignedProfileScreen() } composable { backStackEntry -> val route = backStackEntry.toRoute() @@ -272,9 +274,7 @@ fun AuxNavHost( composable { backStackEntry -> val route = backStackEntry.toRoute() - UnannouncedProfileScreen( - nostrEvent = route.toPlaceholderNostrEvent() - ) + UnannouncedProfileScreen() } composable { SocialPreconditionScreen( @@ -319,9 +319,18 @@ fun AuxNavHost( color = Color.Black ) { - } } + composable { backStackEntry -> + val route = backStackEntry.toRoute() + + SearchScreen() + } + composable { backStackEntry -> + val route = backStackEntry.toRoute() + + NostrEventDetailScreen() + } composable { backStackEntry -> val route: ImplementationPendingRoute = backStackEntry.toRoute() ImplementationPendingScreen( diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/CreateProfileRoute.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/CreateProfileRoute.kt index 4c08a996..303b69b9 100755 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/CreateProfileRoute.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/CreateProfileRoute.kt @@ -9,16 +9,4 @@ import kotlin.time.Clock data class CreateProfileRoute( val nostrEventId: String? = null, ): Route() { - - fun toPlaceholderNostrEvent(): NostrEvent? = nostrEventId?.let { - NostrEvent( - id = nostrEventId, - pubKey = "", - createdAt = Clock.System.now(), - tags = emptyArray(), - kind = 0, - sig = "", - content = "" - ) - } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/NostrEventDetailRoute.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/NostrEventDetailRoute.kt new file mode 100755 index 00000000..9ca044aa --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/NostrEventDetailRoute.kt @@ -0,0 +1,12 @@ +package ac.aux.compose.ui.composable.navigation.routes + +import ac.aux.compose.database.model.NostrEvent +import ac.aux.compose.database.model.Profile +import kotlinx.serialization.Serializable +import kotlin.time.Clock + +@Serializable +data class NostrEventDetailRoute( + val nostrEventId: String? = null, +): Route() { +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/SearchRoute.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/SearchRoute.kt new file mode 100755 index 00000000..a85b80d0 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/SearchRoute.kt @@ -0,0 +1,6 @@ +package ac.aux.compose.ui.composable.navigation.routes + +import kotlinx.serialization.Serializable + +@Serializable +object SearchRoute: Route() \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnannouncedProfileRoute.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnannouncedProfileRoute.kt index 322201af..7c58129a 100755 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnannouncedProfileRoute.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnannouncedProfileRoute.kt @@ -1,5 +1,6 @@ package ac.aux.compose.ui.composable.navigation.routes +import ac.aux.compose.database.GENESIS_AT import ac.aux.compose.database.model.NostrEvent import ac.aux.compose.database.model.Profile import kotlinx.serialization.Serializable @@ -9,14 +10,4 @@ import kotlin.time.Clock data class UnannouncedProfileRoute( val nostrEventId: String, ): Route() { - - fun toPlaceholderNostrEvent(): NostrEvent = NostrEvent( - id = nostrEventId, - pubKey = "", - createdAt = Clock.System.now(), - tags = emptyArray(), - kind = 0, - sig = "", - content = "" - ) } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnsignedProfileRoute.kt b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnsignedProfileRoute.kt index 35acedb3..778f11a4 100755 --- a/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnsignedProfileRoute.kt +++ b/composeApp/src/commonMain/kotlin/ac/aux/compose/ui/composable/navigation/routes/UnsignedProfileRoute.kt @@ -1,5 +1,6 @@ package ac.aux.compose.ui.composable.navigation.routes +import ac.aux.compose.database.GENESIS_AT import ac.aux.compose.database.model.UnsignedNostrEvent import kotlinx.serialization.Serializable import kotlin.time.Clock @@ -8,13 +9,4 @@ import kotlin.time.Clock data class UnsignedProfileRoute( val unsignedNostrEventId: Long, ): Route() { - - fun toPlaceholderUnsignedNostrEvent(): UnsignedNostrEvent = UnsignedNostrEvent( - id = unsignedNostrEventId, - pubKey = "", - createdAt = Clock.System.now(), - tags = emptyArray(), - kind = 0, - content = "" - ) } \ No newline at end of file