Handle sign in navigation
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
package ac.aux.compose.ui.composable
|
||||
|
||||
import ac.aux.compose.database.model.NostrEvent
|
||||
import ac.aux.compose.database.model.Profile
|
||||
import ac.aux.compose.database.model.UnsignedNostrEvent
|
||||
import ac.aux.compose.repository.NostrRepository
|
||||
import ac.aux.compose.ui.composable.navigation.routes.UnannouncedProfileRoute
|
||||
import ac.aux.compose.ui.composable.widgets.LoadingDataIndicator
|
||||
import ac.aux.compose.ui.theme.AuxTheme
|
||||
import ac.aux.compose.ui.theme.BluePill
|
||||
import ac.aux.compose.ui.theme.RedPill
|
||||
import ac.aux.compose.ui.view.model.CreateProfileViewModel
|
||||
import ac.aux.compose.ui.view.state.CreateProfileUIState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Badge
|
||||
import androidx.compose.material.icons.filled.Description
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LoadingIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
||||
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
fun UnsyncedProfileScreen(
|
||||
unsyncedProfilePublicKey: String
|
||||
) {
|
||||
Scaffold { innerPadding ->
|
||||
Column(
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
) {
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().padding(
|
||||
10.dp
|
||||
),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||
) {
|
||||
|
||||
Spacer(
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Text(
|
||||
text = "We are searching the internet to find your profile and complete sign in.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "We are looking for your profile on as many relays as possible. Nostr aims to be decentralized by distributing data to multiple nodse.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
LoadingDataIndicator(
|
||||
fillScreen = false
|
||||
)
|
||||
|
||||
Spacer(
|
||||
modifier = Modifier.weight(2f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun UnsyncedProfileScreenPreview() {
|
||||
AuxTheme {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
UnsyncedProfileScreen(
|
||||
unsyncedProfilePublicKey = "npub is for living."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import ac.aux.compose.ui.composable.UnannouncedProfileScreen
|
||||
import ac.aux.compose.ui.composable.UnindexedProfileScreen
|
||||
import ac.aux.compose.ui.composable.UnqueuedProfileScreen
|
||||
import ac.aux.compose.ui.composable.UnsignedProfileScreen
|
||||
import ac.aux.compose.ui.composable.UnsyncedProfileScreen
|
||||
import ac.aux.compose.ui.composable.WriteNewNoteScreen
|
||||
import ac.aux.compose.ui.composable.navigation.routes.BlankRoute
|
||||
import ac.aux.compose.ui.composable.navigation.routes.CreateProfileRoute
|
||||
@@ -32,6 +33,7 @@ import ac.aux.compose.ui.composable.navigation.routes.UnannouncedProfileRoute
|
||||
import ac.aux.compose.ui.composable.navigation.routes.UnindexedProfileRoute
|
||||
import ac.aux.compose.ui.composable.navigation.routes.UnqueuedProfileRoute
|
||||
import ac.aux.compose.ui.composable.navigation.routes.UnsignedProfileRoute
|
||||
import ac.aux.compose.ui.composable.navigation.routes.UnsyncedProfileRoute
|
||||
import ac.aux.compose.ui.composable.navigation.routes.WriteNewNoteRoute
|
||||
import ac.aux.compose.ui.composable.widgets.feed.DUMMY_EVENTS
|
||||
import ac.aux.compose.ui.view.model.NavigationViewModel
|
||||
@@ -118,6 +120,15 @@ fun AuxNavHost(
|
||||
popUpTo(0)
|
||||
}
|
||||
}
|
||||
is NavigationUIState.UnsyncedProfile -> {
|
||||
navController.navigate(
|
||||
route = UnsyncedProfileRoute(
|
||||
state.unsignedNostrEvent.pubKey
|
||||
)
|
||||
) {
|
||||
popUpTo(0)
|
||||
}
|
||||
}
|
||||
is NavigationUIState.UnindexedProfile -> {
|
||||
navController.navigate(
|
||||
route = UnindexedProfileRoute(
|
||||
@@ -226,6 +237,12 @@ fun AuxNavHost(
|
||||
unsignedNostrEvent = route.toPlaceholderUnsignedNostrEvent()
|
||||
)
|
||||
}
|
||||
composable<UnsyncedProfileRoute> { backStackEntry ->
|
||||
val route = backStackEntry.toRoute<UnsyncedProfileRoute>()
|
||||
UnsyncedProfileScreen(
|
||||
unsyncedProfilePublicKey = route.publicKey
|
||||
)
|
||||
}
|
||||
composable<UnindexedProfileRoute> {
|
||||
UnindexedProfileScreen()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package ac.aux.compose.ui.composable.navigation.routes
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UnsyncedProfileRoute(
|
||||
val publicKey: String,
|
||||
): Route() {
|
||||
}
|
||||
@@ -266,6 +266,11 @@ class NavigationViewModel(
|
||||
NavigationUIState.UnindexedProfile(
|
||||
nostrEvent = localProfile.nostrEvent
|
||||
)
|
||||
} else if (localProfile.unsignedNostrEvent != null && localProfile.unsignedNostrEvent.signedAt != null) {
|
||||
logger.i("We should be syncing the profile: ${localProfile.unsignedNostrEvent}")
|
||||
NavigationUIState.UnsyncedProfile(
|
||||
unsignedNostrEvent = localProfile.unsignedNostrEvent
|
||||
)
|
||||
} else {
|
||||
logger.i("We have an unsigned profile: ${localProfile.unsignedNostrEvent}")
|
||||
NavigationUIState.UnsignedProfile(
|
||||
|
||||
@@ -18,6 +18,10 @@ abstract class NavigationUIState {
|
||||
val unsignedNostrEvent: UnsignedNostrEvent,
|
||||
) : NavigationUIState()
|
||||
|
||||
data class UnsyncedProfile(
|
||||
val unsignedNostrEvent: UnsignedNostrEvent,
|
||||
) : NavigationUIState()
|
||||
|
||||
data class UnindexedProfile(
|
||||
val nostrEvent: NostrEvent,
|
||||
) : NavigationUIState()
|
||||
|
||||
Reference in New Issue
Block a user