Add NostrEventDetailRoute.kt and SearchRoute.kt and manage routes

This commit is contained in:
Kgothatso Ngako
2026-03-31 23:58:34 +02:00
parent 21230cf365
commit ad9cb0615b
10 changed files with 137 additions and 72 deletions

View File

@@ -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()
}
}
}

View File

@@ -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()
}
}
}

View File

@@ -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()
}
}
}

View File

@@ -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()
}
}
}

View File

@@ -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<UnsignedProfileRoute> { backStackEntry ->
val route = backStackEntry.toRoute<UnsignedProfileRoute>()
UnsignedProfileScreen(
unsignedNostrEvent = route.toPlaceholderUnsignedNostrEvent()
)
UnsignedProfileScreen()
}
composable<UnsyncedProfileRoute> { backStackEntry ->
val route = backStackEntry.toRoute<UnsyncedProfileRoute>()
@@ -272,9 +274,7 @@ fun AuxNavHost(
composable<UnannouncedProfileRoute> { backStackEntry ->
val route = backStackEntry.toRoute<UnannouncedProfileRoute>()
UnannouncedProfileScreen(
nostrEvent = route.toPlaceholderNostrEvent()
)
UnannouncedProfileScreen()
}
composable<SocialPreconditionRoute> {
SocialPreconditionScreen(
@@ -319,9 +319,18 @@ fun AuxNavHost(
color = Color.Black
) {
}
}
composable<SearchRoute> { backStackEntry ->
val route = backStackEntry.toRoute<SearchRoute>()
SearchScreen()
}
composable<NostrEventDetailRoute> { backStackEntry ->
val route = backStackEntry.toRoute<NostrEventDetailRoute>()
NostrEventDetailScreen()
}
composable<ImplementationPendingRoute> { backStackEntry ->
val route: ImplementationPendingRoute = backStackEntry.toRoute()
ImplementationPendingScreen(

View File

@@ -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 = ""
)
}
}

View File

@@ -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() {
}

View File

@@ -0,0 +1,6 @@
package ac.aux.compose.ui.composable.navigation.routes
import kotlinx.serialization.Serializable
@Serializable
object SearchRoute: Route()

View File

@@ -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 = ""
)
}

View File

@@ -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 = ""
)
}