mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-26 13:46:21 +02:00
Creates Daniel's idea for reposted profile icons
This commit is contained in:
@@ -54,6 +54,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||||
|
import androidx.compose.ui.Alignment.Companion.TopStart
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
@@ -135,11 +136,12 @@ import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size16Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size16Modifier
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size24Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size24Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size30Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size30Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size30dp
|
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size55Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size55Modifier
|
||||||
@@ -158,7 +160,6 @@ import com.vitorpamplona.amethyst.ui.theme.newItemBackgroundColor
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
import com.vitorpamplona.amethyst.ui.theme.replyBackground
|
import com.vitorpamplona.amethyst.ui.theme.replyBackground
|
||||||
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.repostProfileBorder
|
|
||||||
import com.vitorpamplona.amethyst.ui.theme.subtleBorder
|
import com.vitorpamplona.amethyst.ui.theme.subtleBorder
|
||||||
import com.vitorpamplona.quartz.encoders.ATag
|
import com.vitorpamplona.quartz.encoders.ATag
|
||||||
import com.vitorpamplona.quartz.encoders.toNpub
|
import com.vitorpamplona.quartz.encoders.toNpub
|
||||||
@@ -1042,7 +1043,9 @@ private fun NoteBody(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(3.dp))
|
if (baseNote.event !is RepostEvent && baseNote.event !is GenericRepostEvent) {
|
||||||
|
Spacer(modifier = Modifier.height(3.dp))
|
||||||
|
}
|
||||||
|
|
||||||
if (!makeItShort) {
|
if (!makeItShort) {
|
||||||
ReplyRow(
|
ReplyRow(
|
||||||
@@ -2635,12 +2638,14 @@ fun FirstUserInfoRow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val textColor = if (isRepost) MaterialTheme.colors.placeholderText else Color.Unspecified
|
||||||
|
|
||||||
if (showAuthorPicture) {
|
if (showAuthorPicture) {
|
||||||
NoteAuthorPicture(baseNote, nav, accountViewModel, Size25dp)
|
NoteAuthorPicture(baseNote, nav, accountViewModel, Size25dp)
|
||||||
Spacer(HalfPadding)
|
Spacer(HalfPadding)
|
||||||
NoteUsernameDisplay(baseNote, remember { Modifier.weight(1f) })
|
NoteUsernameDisplay(baseNote, remember { Modifier.weight(1f) }, textColor = textColor)
|
||||||
} else {
|
} else {
|
||||||
NoteUsernameDisplay(baseNote, remember { Modifier.weight(1f) })
|
NoteUsernameDisplay(baseNote, remember { Modifier.weight(1f) }, textColor = textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRepost) {
|
if (isRepost) {
|
||||||
@@ -2752,12 +2757,18 @@ private fun RenderAuthorImages(
|
|||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
accountViewModel: AccountViewModel
|
accountViewModel: AccountViewModel
|
||||||
) {
|
) {
|
||||||
NoteAuthorPicture(baseNote, nav, accountViewModel, Size55dp)
|
val baseRepost by remember {
|
||||||
|
derivedStateOf {
|
||||||
|
baseNote.replyTo?.lastOrNull()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val isRepost = baseNote.event is RepostEvent || baseNote.event is GenericRepostEvent
|
val isRepost = baseNote.event is RepostEvent || baseNote.event is GenericRepostEvent
|
||||||
|
|
||||||
if (isRepost) {
|
if (isRepost && baseRepost != null) {
|
||||||
RepostNoteAuthorPicture(baseNote, accountViewModel, nav)
|
RepostNoteAuthorPicture(baseNote, baseRepost!!, accountViewModel, nav)
|
||||||
|
} else {
|
||||||
|
NoteAuthorPicture(baseNote, nav, accountViewModel, Size55dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
val isChannel = baseNote.event is ChannelMessageEvent && baseNote.channelHex() != null
|
val isChannel = baseNote.event is ChannelMessageEvent && baseNote.channelHex() != null
|
||||||
@@ -2828,23 +2839,30 @@ private fun ChannelNotePicture(baseChannel: Channel) {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun RepostNoteAuthorPicture(
|
private fun RepostNoteAuthorPicture(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
|
baseRepost: Note,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val baseRepost by remember {
|
Box(modifier = Size55Modifier) {
|
||||||
derivedStateOf {
|
Box(Size35Modifier.align(Alignment.TopStart)) {
|
||||||
baseNote.replyTo?.lastOrNull()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
baseRepost?.let {
|
|
||||||
Box(Size30Modifier) {
|
|
||||||
NoteAuthorPicture(
|
NoteAuthorPicture(
|
||||||
baseNote = it,
|
baseNote = baseNote,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
size = Size30dp,
|
size = Size34dp
|
||||||
pictureModifier = MaterialTheme.colors.repostProfileBorder
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Box(Size18Modifier.align(Alignment.BottomStart).padding(1.dp)) {
|
||||||
|
RepostedIcon(modifier = Size18Modifier, MaterialTheme.colors.placeholderText)
|
||||||
|
}
|
||||||
|
|
||||||
|
Box(Size35Modifier.align(Alignment.BottomEnd)) {
|
||||||
|
NoteAuthorPicture(
|
||||||
|
baseNote = baseRepost,
|
||||||
|
nav = nav,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
size = Size34dp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ import androidx.compose.runtime.livedata.observeAsState
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@@ -31,20 +32,20 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
|||||||
import com.vitorpamplona.quartz.events.ImmutableListOfLists
|
import com.vitorpamplona.quartz.events.ImmutableListOfLists
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NoteUsernameDisplay(baseNote: Note, weight: Modifier = Modifier, showPlayButton: Boolean = true) {
|
fun NoteUsernameDisplay(baseNote: Note, weight: Modifier = Modifier, showPlayButton: Boolean = true, textColor: Color = Color.Unspecified) {
|
||||||
val authorState by baseNote.live().metadata.map {
|
val authorState by baseNote.live().metadata.map {
|
||||||
it.note.author
|
it.note.author
|
||||||
}.observeAsState(baseNote.author)
|
}.observeAsState(baseNote.author)
|
||||||
|
|
||||||
Crossfade(targetState = authorState, modifier = weight) {
|
Crossfade(targetState = authorState, modifier = weight) {
|
||||||
it?.let {
|
it?.let {
|
||||||
UsernameDisplay(it, weight, showPlayButton)
|
UsernameDisplay(it, weight, showPlayButton, textColor = textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UsernameDisplay(baseUser: User, weight: Modifier = Modifier, showPlayButton: Boolean = true, fontWeight: FontWeight = FontWeight.Bold) {
|
fun UsernameDisplay(baseUser: User, weight: Modifier = Modifier, showPlayButton: Boolean = true, fontWeight: FontWeight = FontWeight.Bold, textColor: Color = Color.Unspecified) {
|
||||||
val npubDisplay by remember {
|
val npubDisplay by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
baseUser.pubkeyDisplayHex()
|
baseUser.pubkeyDisplayHex()
|
||||||
@@ -57,9 +58,9 @@ fun UsernameDisplay(baseUser: User, weight: Modifier = Modifier, showPlayButton:
|
|||||||
|
|
||||||
Crossfade(targetState = userMetadata, modifier = weight) {
|
Crossfade(targetState = userMetadata, modifier = weight) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
UserNameDisplay(it.bestUsername(), it.bestDisplayName(), npubDisplay, it.tags, weight, showPlayButton, fontWeight)
|
UserNameDisplay(it.bestUsername(), it.bestDisplayName(), npubDisplay, it.tags, weight, showPlayButton, fontWeight, textColor)
|
||||||
} else {
|
} else {
|
||||||
NPubDisplay(npubDisplay, weight, fontWeight)
|
NPubDisplay(npubDisplay, weight, fontWeight, textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,27 +73,29 @@ private fun UserNameDisplay(
|
|||||||
tags: ImmutableListOfLists<String>?,
|
tags: ImmutableListOfLists<String>?,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
showPlayButton: Boolean = true,
|
showPlayButton: Boolean = true,
|
||||||
fontWeight: FontWeight = FontWeight.Bold
|
fontWeight: FontWeight = FontWeight.Bold,
|
||||||
|
textColor: Color = Color.Unspecified
|
||||||
) {
|
) {
|
||||||
if (bestUserName != null && bestDisplayName != null && bestDisplayName != bestUserName) {
|
if (bestUserName != null && bestDisplayName != null && bestDisplayName != bestUserName) {
|
||||||
UserAndUsernameDisplay(bestDisplayName.trim(), tags, bestUserName.trim(), modifier, showPlayButton, fontWeight)
|
UserAndUsernameDisplay(bestDisplayName.trim(), tags, bestUserName.trim(), modifier, showPlayButton, fontWeight, textColor)
|
||||||
} else if (bestDisplayName != null) {
|
} else if (bestDisplayName != null) {
|
||||||
UserDisplay(bestDisplayName.trim(), tags, modifier, showPlayButton, fontWeight)
|
UserDisplay(bestDisplayName.trim(), tags, modifier, showPlayButton, fontWeight, textColor)
|
||||||
} else if (bestUserName != null) {
|
} else if (bestUserName != null) {
|
||||||
UserDisplay(bestUserName.trim(), tags, modifier, showPlayButton, fontWeight)
|
UserDisplay(bestUserName.trim(), tags, modifier, showPlayButton, fontWeight, textColor)
|
||||||
} else {
|
} else {
|
||||||
NPubDisplay(npubDisplay, modifier, fontWeight)
|
NPubDisplay(npubDisplay, modifier, fontWeight, textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NPubDisplay(npubDisplay: String, modifier: Modifier, fontWeight: FontWeight = FontWeight.Bold) {
|
fun NPubDisplay(npubDisplay: String, modifier: Modifier, fontWeight: FontWeight = FontWeight.Bold, textColor: Color = Color.Unspecified) {
|
||||||
Text(
|
Text(
|
||||||
text = npubDisplay,
|
text = npubDisplay,
|
||||||
fontWeight = fontWeight,
|
fontWeight = fontWeight,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
color = textColor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +105,8 @@ private fun UserDisplay(
|
|||||||
tags: ImmutableListOfLists<String>?,
|
tags: ImmutableListOfLists<String>?,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
showPlayButton: Boolean = true,
|
showPlayButton: Boolean = true,
|
||||||
fontWeight: FontWeight = FontWeight.Bold
|
fontWeight: FontWeight = FontWeight.Bold,
|
||||||
|
textColor: Color = Color.Unspecified
|
||||||
) {
|
) {
|
||||||
Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
|
||||||
CreateTextWithEmoji(
|
CreateTextWithEmoji(
|
||||||
@@ -111,7 +115,8 @@ private fun UserDisplay(
|
|||||||
fontWeight = fontWeight,
|
fontWeight = fontWeight,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
modifier = modifier
|
modifier = modifier,
|
||||||
|
color = textColor
|
||||||
)
|
)
|
||||||
if (showPlayButton) {
|
if (showPlayButton) {
|
||||||
Spacer(StdHorzSpacer)
|
Spacer(StdHorzSpacer)
|
||||||
@@ -127,7 +132,8 @@ private fun UserAndUsernameDisplay(
|
|||||||
bestUserName: String,
|
bestUserName: String,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
showPlayButton: Boolean = true,
|
showPlayButton: Boolean = true,
|
||||||
fontWeight: FontWeight = FontWeight.Bold
|
fontWeight: FontWeight = FontWeight.Bold,
|
||||||
|
textColor: Color = Color.Unspecified
|
||||||
) {
|
) {
|
||||||
Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
|
||||||
CreateTextWithEmoji(
|
CreateTextWithEmoji(
|
||||||
@@ -135,7 +141,8 @@ private fun UserAndUsernameDisplay(
|
|||||||
tags = tags,
|
tags = tags,
|
||||||
fontWeight = fontWeight,
|
fontWeight = fontWeight,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
modifier = modifier
|
modifier = modifier,
|
||||||
|
color = textColor
|
||||||
)
|
)
|
||||||
/*
|
/*
|
||||||
CreateTextWithEmoji(
|
CreateTextWithEmoji(
|
||||||
|
Reference in New Issue
Block a user