Refining the padding of chat messages and reaction row
This commit is contained in:
@@ -37,6 +37,7 @@ object OnlineChecker {
|
|||||||
.build()
|
.build()
|
||||||
|
|
||||||
val result = HttpClient.getHttpClient().newCall(request).execute().use {
|
val result = HttpClient.getHttpClient().newCall(request).execute().use {
|
||||||
|
checkNotInMainThread()
|
||||||
it.isSuccessful
|
it.isSuccessful
|
||||||
}
|
}
|
||||||
checkOnlineCache.put(url, OnlineCheckResult(System.currentTimeMillis(), result))
|
checkOnlineCache.put(url, OnlineCheckResult(System.currentTimeMillis(), result))
|
||||||
|
|||||||
@@ -58,8 +58,11 @@ import com.vitorpamplona.amethyst.ui.theme.ChatBubbleShapeThem
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Font12SP
|
import com.vitorpamplona.amethyst.ui.theme.Font12SP
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeightChat
|
import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeightChat
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size15dp
|
import com.vitorpamplona.amethyst.ui.theme.Size15dp
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size20dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink
|
import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink
|
||||||
@@ -305,8 +308,8 @@ fun NormalChatNote(
|
|||||||
Row(
|
Row(
|
||||||
horizontalArrangement = alignment,
|
horizontalArrangement = alignment,
|
||||||
modifier = modif2.onSizeChanged {
|
modifier = modif2.onSizeChanged {
|
||||||
if (availableBubbleSize.value != it.width) {
|
if (availableBubbleSize.intValue != it.width) {
|
||||||
availableBubbleSize.value = it.width
|
availableBubbleSize.intValue = it.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
@@ -359,8 +362,8 @@ private fun RenderBubble(
|
|||||||
Modifier
|
Modifier
|
||||||
.padding(start = 10.dp, end = 5.dp, bottom = 5.dp)
|
.padding(start = 10.dp, end = 5.dp, bottom = 5.dp)
|
||||||
.onSizeChanged {
|
.onSizeChanged {
|
||||||
if (bubbleSize.value != it.width) {
|
if (bubbleSize.intValue != it.width) {
|
||||||
bubbleSize.value = it.width
|
bubbleSize.intValue = it.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,15 +433,30 @@ private fun MessageBubbleLines(
|
|||||||
|
|
||||||
ConstrainedStatusRow(
|
ConstrainedStatusRow(
|
||||||
bubbleSize = bubbleSize,
|
bubbleSize = bubbleSize,
|
||||||
availableBubbleSize = availableBubbleSize
|
availableBubbleSize = availableBubbleSize,
|
||||||
) {
|
firstColumn = {
|
||||||
StatusRow(
|
IncognitoBadge(baseNote)
|
||||||
baseNote = baseNote,
|
ChatTimeAgo(baseNote)
|
||||||
accountViewModel = accountViewModel,
|
RelayBadgesHorizontal(baseNote, accountViewModel, nav = nav)
|
||||||
nav = nav,
|
Spacer(modifier = DoubleHorzSpacer)
|
||||||
onWantsToReply = onWantsToReply
|
},
|
||||||
)
|
secondColumn = {
|
||||||
}
|
LikeReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav)
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
ZapReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav = nav)
|
||||||
|
Spacer(modifier = DoubleHorzSpacer)
|
||||||
|
ReplyReaction(
|
||||||
|
baseNote = baseNote,
|
||||||
|
grayTint = MaterialTheme.colorScheme.placeholderText,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
showCounter = false,
|
||||||
|
iconSize = Size15dp
|
||||||
|
) {
|
||||||
|
onWantsToReply(baseNote)
|
||||||
|
}
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -524,58 +542,38 @@ private fun NoteRow(
|
|||||||
private fun ConstrainedStatusRow(
|
private fun ConstrainedStatusRow(
|
||||||
bubbleSize: MutableState<Int>,
|
bubbleSize: MutableState<Int>,
|
||||||
availableBubbleSize: MutableState<Int>,
|
availableBubbleSize: MutableState<Int>,
|
||||||
content: @Composable () -> Unit
|
firstColumn: @Composable () -> Unit,
|
||||||
|
secondColumn: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
modifier = with(LocalDensity.current) {
|
modifier = with(LocalDensity.current) {
|
||||||
Modifier
|
Modifier
|
||||||
.height(26.dp)
|
.padding(top = Size5dp)
|
||||||
.padding(top = 5.dp)
|
.height(Size20dp)
|
||||||
.widthIn(
|
.widthIn(
|
||||||
bubbleSize.value.toDp(),
|
bubbleSize.value.toDp(),
|
||||||
availableBubbleSize.value.toDp()
|
availableBubbleSize.value.toDp()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
content()
|
Column(modifier = ReactionRowHeightChat) {
|
||||||
}
|
Row(
|
||||||
}
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = ReactionRowHeightChat
|
||||||
@Composable
|
|
||||||
private fun StatusRow(
|
|
||||||
baseNote: Note,
|
|
||||||
accountViewModel: AccountViewModel,
|
|
||||||
nav: (String) -> Unit,
|
|
||||||
onWantsToReply: (Note) -> Unit
|
|
||||||
) {
|
|
||||||
Column(modifier = ReactionRowHeightChat) {
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = ReactionRowHeightChat) {
|
|
||||||
IncognitoBadge(baseNote)
|
|
||||||
Spacer(modifier = StdHorzSpacer)
|
|
||||||
ChatTimeAgo(baseNote)
|
|
||||||
RelayBadgesHorizontal(baseNote, accountViewModel, nav = nav)
|
|
||||||
Spacer(modifier = DoubleHorzSpacer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column(modifier = ReactionRowHeightChat) {
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = ReactionRowHeightChat) {
|
|
||||||
LikeReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav)
|
|
||||||
Spacer(modifier = StdHorzSpacer)
|
|
||||||
ZapReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav = nav)
|
|
||||||
Spacer(modifier = DoubleHorzSpacer)
|
|
||||||
ReplyReaction(
|
|
||||||
baseNote = baseNote,
|
|
||||||
grayTint = MaterialTheme.colorScheme.placeholderText,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
showCounter = false,
|
|
||||||
iconSize = Size15dp
|
|
||||||
) {
|
) {
|
||||||
onWantsToReply(baseNote)
|
firstColumn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column(modifier = ReactionRowHeightChat) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = ReactionRowHeightChat
|
||||||
|
) {
|
||||||
|
secondColumn()
|
||||||
}
|
}
|
||||||
Spacer(modifier = StdHorzSpacer)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,6 +589,7 @@ fun IncognitoBadge(baseNote: Note) {
|
|||||||
.size(14.dp),
|
.size(14.dp),
|
||||||
tint = MaterialTheme.colorScheme.placeholderText
|
tint = MaterialTheme.colorScheme.placeholderText
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
} else if (baseNote.event is PrivateDmEvent) {
|
} else if (baseNote.event is PrivateDmEvent) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.drawable.incognito_off),
|
painter = painterResource(id = R.drawable.incognito_off),
|
||||||
@@ -600,6 +599,7 @@ fun IncognitoBadge(baseNote: Note) {
|
|||||||
.size(14.dp),
|
.size(14.dp),
|
||||||
tint = MaterialTheme.colorScheme.placeholderText
|
tint = MaterialTheme.colorScheme.placeholderText
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,7 +719,7 @@ private fun DrawAuthorInfo(
|
|||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = alignment,
|
horizontalArrangement = alignment,
|
||||||
modifier = Modifier.padding(top = 5.dp)
|
modifier = Modifier.padding(top = Size10dp)
|
||||||
) {
|
) {
|
||||||
DisplayAndWatchNoteAuthor(baseNote, loadProfilePicture, nav)
|
DisplayAndWatchNoteAuthor(baseNote, loadProfilePicture, nav)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.vitorpamplona.amethyst.ui.note
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.FlowRow
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
@@ -22,6 +23,7 @@ import androidx.compose.runtime.livedata.observeAsState
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
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.draw.clip
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -62,7 +64,7 @@ public fun RelayBadgesHorizontal(baseNote: Note, accountViewModel: AccountViewMo
|
|||||||
fun RenderRelayList(baseNote: Note, expanded: MutableState<Boolean>, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
fun RenderRelayList(baseNote: Note, expanded: MutableState<Boolean>, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
||||||
val noteRelays by baseNote.live().relayInfo.observeAsState()
|
val noteRelays by baseNote.live().relayInfo.observeAsState()
|
||||||
|
|
||||||
FlowRow(StdStartPadding) {
|
FlowRow(StdStartPadding, verticalArrangement = Arrangement.Center) {
|
||||||
val relaysToDisplay = remember(noteRelays, expanded.value) {
|
val relaysToDisplay = remember(noteRelays, expanded.value) {
|
||||||
if (expanded.value) noteRelays else noteRelays?.take(3)?.toImmutableList()
|
if (expanded.value) noteRelays else noteRelays?.take(3)?.toImmutableList()
|
||||||
}
|
}
|
||||||
@@ -160,7 +162,8 @@ fun RenderRelay(relay: RelayBriefInfo, accountViewModel: AccountViewModel, nav:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = clickableModifier
|
modifier = clickableModifier,
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
RenderRelayIcon(relay.favIcon, automaticallyShowProfilePicture)
|
RenderRelayIcon(relay.favIcon, automaticallyShowProfilePicture)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user