Show profile avatars on search
This commit is contained in:
1 parent
96806cfb78
commit
4515bfa375
4 files changed
+37
-23
No files matched your search
+5
-1
@@ -74,7 +74,11 @@ data class Profile(
|
|||||||
override val broadcastedAt: Instant? = null,
|
override val broadcastedAt: Instant? = null,
|
||||||
): NostrEventEntity, TimestampedEntity, LocalStoreEntity, UserViewableEntity, BroadcastableEntity, SoftDeletableEntity {
|
): NostrEventEntity, TimestampedEntity, LocalStoreEntity, UserViewableEntity, BroadcastableEntity, SoftDeletableEntity {
|
||||||
fun humanReadableNameOrPubkey(): String {
|
fun humanReadableNameOrPubkey(): String {
|
||||||
return displayName ?: userName ?: nip05 ?: twitter ?: publicKey
|
return displayName ?: userName ?: lud16 ?: nip05 ?: twitter ?: publicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
fun staticIdentifier(): String {
|
||||||
|
return lud16 ?: nip05 ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
+25
-20
@@ -5,6 +5,7 @@ import ac.cord.auxiliary.compose.repository.SearchRepository
|
|||||||
import ac.cord.auxiliary.compose.ui.composable.navigation.routes.NostrEventDetailRoute
|
import ac.cord.auxiliary.compose.ui.composable.navigation.routes.NostrEventDetailRoute
|
||||||
import ac.cord.auxiliary.compose.ui.composable.navigation.routes.Route
|
import ac.cord.auxiliary.compose.ui.composable.navigation.routes.Route
|
||||||
import ac.cord.auxiliary.compose.ui.composable.navigation.routes.SearchResultRoute
|
import ac.cord.auxiliary.compose.ui.composable.navigation.routes.SearchResultRoute
|
||||||
|
import ac.cord.auxiliary.compose.ui.composable.widgets.profile.ProfileAvatar
|
||||||
import ac.cord.auxiliary.compose.ui.theme.AuxTheme
|
import ac.cord.auxiliary.compose.ui.theme.AuxTheme
|
||||||
import ac.cord.auxiliary.compose.ui.view.model.SearchViewModel
|
import ac.cord.auxiliary.compose.ui.view.model.SearchViewModel
|
||||||
import ac.cord.auxiliary.compose.ui.view.state.SearchUIState
|
import ac.cord.auxiliary.compose.ui.view.state.SearchUIState
|
||||||
@@ -21,6 +22,7 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||||||
import androidx.compose.foundation.lazy.LazyRow
|
import androidx.compose.foundation.lazy.LazyRow
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.text.input.rememberTextFieldState
|
import androidx.compose.foundation.text.input.rememberTextFieldState
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowBackIosNew
|
import androidx.compose.material.icons.filled.ArrowBackIosNew
|
||||||
@@ -52,6 +54,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.semantics.isTraversalGroup
|
import androidx.compose.ui.semantics.isTraversalGroup
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
@@ -221,25 +224,27 @@ fun SearchScreen(
|
|||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
itemsIndexed(searchViewModel.filteredProfiles) { index, profile ->
|
items(
|
||||||
|
items = searchViewModel.filteredProfiles
|
||||||
|
) { profile ->
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(profile.humanReadableNameOrPubkey()) },
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
profile.humanReadableNameOrPubkey(),
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
|
},
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text("Profile")
|
Text(
|
||||||
|
text = profile.staticIdentifier(),
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
IconButton(
|
ProfileAvatar(
|
||||||
onClick = {
|
profile = profile,
|
||||||
onNavigateToProfile.invoke(
|
publicKey = profile.publicKey
|
||||||
NostrEventDetailRoute(profile.nostrEventId)
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
Icons.Default.Person,
|
|
||||||
contentDescription = "Person"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable {
|
.clickable {
|
||||||
@@ -274,7 +279,7 @@ fun SearchScreen(
|
|||||||
|
|
||||||
LazyRow {
|
LazyRow {
|
||||||
items(searchViewModel.searchableProfiles) { profile ->
|
items(searchViewModel.searchableProfiles) { profile ->
|
||||||
val profileName = profile.displayName ?: profile.userName ?: profile.nip05 ?: profile.nostrEventId
|
val profileName = profile.humanReadableNameOrPubkey()
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(10.dp).width(70.dp),
|
modifier = Modifier.padding(10.dp).width(70.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
@@ -291,10 +296,10 @@ fun SearchScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Icon(
|
ProfileAvatar(
|
||||||
modifier = Modifier.size(70.dp),
|
size = 70.dp,
|
||||||
imageVector = Icons.Default.Person,
|
profile = profile,
|
||||||
contentDescription = profileName
|
publicKey = profile.publicKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ fun MetadataEventDetail(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
ProfileAvatar(
|
ProfileAvatar(
|
||||||
modifier = Modifier.size(75.dp).clip(shape = CircleShape),
|
size = 75.dp,
|
||||||
profile = profile,
|
profile = profile,
|
||||||
publicKey = localNostrEvent.nostrEvent.pubKey
|
publicKey = localNostrEvent.nostrEvent.pubKey
|
||||||
)
|
)
|
||||||
|
|||||||
+6
-1
@@ -17,19 +17,24 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ProfileAvatar(
|
fun ProfileAvatar(
|
||||||
modifier: Modifier = Modifier.size(55.dp).clip(shape = CircleShape),
|
size: Dp = 55.dp,
|
||||||
|
shape: Shape = CircleShape,
|
||||||
publicKey: String,
|
publicKey: String,
|
||||||
profile: Profile?
|
profile: Profile?
|
||||||
) {
|
) {
|
||||||
|
val modifier = Modifier.size(size).clip(shape = shape)
|
||||||
|
|
||||||
val tintColor = Color.hsl(
|
val tintColor = Color.hsl(
|
||||||
hue = abs(
|
hue = abs(
|
||||||
publicKey.hashCode()
|
publicKey.hashCode()
|
||||||
|
|||||||
Reference in new issue
Block a user