Cropping long reactions to two chars for emojis
This commit is contained in:
@@ -178,6 +178,12 @@ fun RenderLikeGallery(
|
||||
likeEvents.isNotEmpty()
|
||||
}
|
||||
|
||||
val shortReaction by remember {
|
||||
derivedStateOf {
|
||||
reactionType.take(2)
|
||||
}
|
||||
}
|
||||
|
||||
if (isNotEmpty) {
|
||||
Row(remember { Modifier.fillMaxWidth() }) {
|
||||
Box(
|
||||
@@ -192,7 +198,7 @@ fun RenderLikeGallery(
|
||||
.align(Alignment.TopEnd)
|
||||
}
|
||||
|
||||
when (reactionType) {
|
||||
when (shortReaction) {
|
||||
"+" -> Icon(
|
||||
painter = painterResource(R.drawable.ic_liked),
|
||||
null,
|
||||
@@ -200,7 +206,7 @@ fun RenderLikeGallery(
|
||||
tint = Color.Unspecified
|
||||
)
|
||||
"-" -> Text(text = "\uD83D\uDC4E", modifier = modifier)
|
||||
else -> Text(text = reactionType, modifier = modifier)
|
||||
else -> Text(text = shortReaction, modifier = modifier)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -504,14 +504,14 @@ fun LikeIcon(baseNote: Note, iconSize: Dp = 20.dp, grayTint: Color, loggedIn: Us
|
||||
val reactionsState by baseNote.live().reactions.observeAsState()
|
||||
|
||||
var reactionType by remember(baseNote) {
|
||||
mutableStateOf<String?>(null)
|
||||
mutableStateOf<String>("+")
|
||||
}
|
||||
|
||||
LaunchedEffect(key1 = reactionsState) {
|
||||
launch(Dispatchers.Default) {
|
||||
val newReactionType = reactionsState?.note?.isReactedBy(loggedIn)
|
||||
if (reactionType != newReactionType) {
|
||||
reactionType = newReactionType
|
||||
reactionType = newReactionType?.take(2) ?: "+"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ fun LikeIcon(baseNote: Note, iconSize: Dp = 20.dp, grayTint: Color, loggedIn: Us
|
||||
)
|
||||
}
|
||||
"-" -> Text(text = "\uD83D\uDC4E")
|
||||
else -> Text(text = reactionType!!)
|
||||
else -> Text(text = reactionType)
|
||||
}
|
||||
} else {
|
||||
Icon(
|
||||
|
||||
@@ -64,7 +64,7 @@ class UpdateReactionTypeViewModel(val account: Account) : ViewModel() {
|
||||
}
|
||||
|
||||
fun addChoice() {
|
||||
val newValue = nextChoice.text.trim()
|
||||
val newValue = nextChoice.text.trim().take(2)
|
||||
reactionSet = reactionSet + newValue
|
||||
|
||||
nextChoice = TextFieldValue("")
|
||||
|
||||
Reference in New Issue
Block a user