From e13f72d03d0c3548d4262d77bde43d6bc014f63f Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Thu, 18 Jun 2026 08:17:08 +0700 Subject: [PATCH] update profile screen --- .../androidMain/kotlin/su/reya/coop/App.kt | 2 +- .../kotlin/su/reya/coop/Navigation.kt | 2 +- .../su/reya/coop/screens/ProfileScreen.kt | 35 ++++++++++++++----- .../su/reya/coop/screens/RequestListScreen.kt | 5 ++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt index ed281a6..cd603da 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt @@ -184,7 +184,7 @@ fun App(viewModel: NostrViewModel) { NewChatScreen() } entry { key -> - ProfileScreen(pubkey = key.pubkey) + ProfileScreen(pubkey = key.pubkey, screening = key.screening) } entry { UpdateProfileScreen() diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt index 6a53f67..213aad0 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt @@ -30,7 +30,7 @@ sealed interface Screen : NavKey { data class Chat(val id: Long) : Screen @Serializable - data class Profile(val pubkey: String) : Screen + data class Profile(val pubkey: String, val screening: Boolean = false) : Screen @Serializable data object ContactList : Screen diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ProfileScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ProfileScreen.kt index 2b10250..c2b7f6a 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ProfileScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ProfileScreen.kt @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.FilledTonalIconButton import androidx.compose.material3.Icon @@ -23,7 +24,6 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.SegmentedListItem import androidx.compose.material3.SnackbarHost import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.toShape import androidx.compose.runtime.Composable @@ -54,27 +54,28 @@ import su.reya.coop.short @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun ProfileScreen(pubkey: String) { - val pubkey = runCatching { PublicKey.parse(pubkey) }.getOrNull() ?: return - +fun ProfileScreen(pubkey: String, screening: Boolean = false) { val context = LocalContext.current val snackbarHostState = LocalSnackbarHostState.current val navigator = LocalNavigator.current val viewModel = LocalNostrViewModel.current - val scope = rememberCoroutineScope() + + val pubkey = runCatching { PublicKey.parse(pubkey) }.getOrNull() ?: return + val metadataFlow = remember(pubkey) { viewModel.getMetadata(pubkey) } val metadata by metadataFlow.collectAsState(initial = null) - val profile = metadata?.asRecord() + val displayName = profile?.displayName ?: profile?.name ?: "No name" val nip05 = profile?.nip05 ?: pubkey.short() val picture = profile?.picture + val details = remember(profile) { listOf( "Username:" to (profile?.name ?: "None"), "Website:" to (profile?.website ?: "None"), - "Lightning Address:" to (profile?.lud16 ?: "None"), + "₿ Lightning Address:" to (profile?.lud16 ?: "None"), ) } @@ -82,8 +83,15 @@ fun ProfileScreen(pubkey: String) { containerColor = MaterialTheme.colorScheme.surfaceContainer, snackbarHost = { SnackbarHost(snackbarHostState) }, topBar = { - TopAppBar( - title = { }, + CenterAlignedTopAppBar( + title = { + if (screening) { + Text( + text = "Screening", + style = MaterialTheme.typography.titleMediumEmphasized + ) + } + }, navigationIcon = { IconButton(onClick = { navigator.goBack() }) { Icon( @@ -233,6 +241,15 @@ fun ProfileScreen(pubkey: String) { ) } } + + if (screening) { + Column( + modifier = Modifier.fillMaxWidth(), + verticalArrangement = Arrangement.spacedBy(ListItemDefaults.SegmentedGap), + ) { + // TODO + } + } } } } diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/RequestListScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/RequestListScreen.kt index 75ee8da..fbeb0a2 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/RequestListScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/RequestListScreen.kt @@ -71,7 +71,10 @@ fun RequestListScreen() { containerColor = MaterialTheme.colorScheme.surfaceContainer, ), title = { - Text("New Requests", style = MaterialTheme.typography.titleMediumEmphasized) + Text( + text = "New Requests", + style = MaterialTheme.typography.titleMediumEmphasized + ) }, navigationIcon = { IconButton(onClick = { navigator.goBack() }) {