diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ImportScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ImportScreen.kt index c2d4af5..39ad654 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ImportScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ImportScreen.kt @@ -90,7 +90,7 @@ fun ImportScreen() { val profile = metadata?.asRecord() val displayName = profile?.displayName ?: profile?.name ?: pubkey?.short() ?: "Unknown" val picture = profile?.picture - + LaunchedEffect(qrScanResult.content) { qrScanResult.content?.let { result -> runCatching { @@ -205,6 +205,7 @@ fun ImportScreen() { BasicTextField( value = secret, onValueChange = { secret = it }, + enabled = !isLoggedIn, modifier = Modifier.fillMaxWidth(), maxLines = 4, keyboardOptions = KeyboardOptions( @@ -217,10 +218,10 @@ fun ImportScreen() { ), visualTransformation = PasswordVisualTransformation('*'), textStyle = MaterialTheme.typography.bodyMediumEmphasized.copy( - color = MaterialTheme.colorScheme.primaryFixed, + color = MaterialTheme.colorScheme.tertiaryFixedDim, fontWeight = FontWeight.SemiBold, ), - cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary), + cursorBrush = SolidColor(MaterialTheme.colorScheme.tertiaryContainer), decorationBox = { innerTextField -> Box(contentAlignment = Alignment.CenterStart) { if (secret.isEmpty()) { @@ -263,7 +264,7 @@ fun ImportScreen() { LoadingIndicator() } else { Text( - text = if (pubkey == null) "Verify" else "Continue", + text = if (pubkey == null) "Verify" else "Click again to Continue", style = MaterialTheme.typography.titleMediumEmphasized, ) } diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt index 71d6e5a..ea3139c 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt @@ -183,6 +183,7 @@ fun NewIdentityScreen() { BasicTextField( value = name, onValueChange = { name = it }, + enabled = !isLoggedIn, modifier = Modifier.fillMaxWidth(), singleLine = true, keyboardOptions = KeyboardOptions( @@ -194,10 +195,10 @@ fun NewIdentityScreen() { } ), textStyle = MaterialTheme.typography.headlineLargeEmphasized.copy( - color = MaterialTheme.colorScheme.primaryFixed, + color = MaterialTheme.colorScheme.tertiaryFixedDim, fontWeight = FontWeight.SemiBold, ), - cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary), + cursorBrush = SolidColor(MaterialTheme.colorScheme.tertiaryContainer), decorationBox = { innerTextField -> Box(contentAlignment = Alignment.CenterStart) { if (name.isEmpty()) { @@ -225,6 +226,7 @@ fun NewIdentityScreen() { BasicTextField( value = bio, onValueChange = { bio = it }, + enabled = !isLoggedIn, modifier = Modifier.fillMaxWidth(), maxLines = 3, keyboardOptions = KeyboardOptions( diff --git a/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt b/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt index 2a78360..91d669b 100644 --- a/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt +++ b/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt @@ -375,13 +375,16 @@ class NostrViewModel( } suspend fun verifyIdentity(secret: String): PublicKey? { - return runCatching { + try { val signer = createSigner(secret) if (secret.startsWith("bunker://")) { showError("Please approve the connection.") } - signer.getPublicKeyAsync() - }.getOrNull() + return signer.getPublicKeyAsync() + } catch (e: Exception) { + showError("Error: ${e.message}") + return null + } } suspend fun importIdentity(secret: String) { @@ -394,7 +397,7 @@ class NostrViewModel( showError("Error: ${e.message}") } finally { _signerRequired.value = false - _isLoggedIn.value = true + _isLoggedIn.value = false } }