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