Switches Social Icons to faster SVG versions
@@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui.actions
|
||||
import androidx.compose.animation.Crossfade
|
||||
import androidx.compose.animation.core.FiniteAnimationSpec
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.vitorpamplona.amethyst.model.FeatureSetType
|
||||
@@ -38,7 +39,9 @@ fun <T> CrossfadeIfEnabled(
|
||||
content: @Composable (T) -> Unit,
|
||||
) {
|
||||
if (accountViewModel.settings.featureSet == FeatureSetType.PERFORMANCE) {
|
||||
content(targetState)
|
||||
Box(modifier) {
|
||||
content(targetState)
|
||||
}
|
||||
} else {
|
||||
Crossfade(targetState, modifier, animationSpec, label, content)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vitorpamplona.amethyst.ui.note.RepostedIcon
|
||||
import com.vitorpamplona.amethyst.ui.note.RepostIcon
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size55Modifier
|
||||
@@ -55,7 +55,7 @@ fun GenericRepostLayout(
|
||||
Box(
|
||||
remember { Size18Modifier.align(Alignment.BottomStart).padding(1.dp) },
|
||||
) {
|
||||
RepostedIcon(modifier = Size18Modifier, MaterialTheme.colorScheme.placeholderText)
|
||||
RepostIcon(modifier = Size18Modifier, MaterialTheme.colorScheme.placeholderText)
|
||||
}
|
||||
|
||||
Box(
|
||||
|
||||
@@ -77,8 +77,7 @@ sealed class Route(
|
||||
nullable = true
|
||||
defaultValue = null
|
||||
},
|
||||
)
|
||||
.toImmutableList(),
|
||||
).toImmutableList(),
|
||||
contentDescriptor = R.string.route_home,
|
||||
hasNewItems = { accountViewModel, newNotes ->
|
||||
HomeLatestItem.hasNewItems(accountViewModel, newNotes)
|
||||
@@ -95,7 +94,7 @@ sealed class Route(
|
||||
object Search :
|
||||
Route(
|
||||
route = "Search",
|
||||
icon = R.drawable.ic_search,
|
||||
icon = R.drawable.ic_moments,
|
||||
contentDescriptor = R.string.route_search,
|
||||
)
|
||||
|
||||
@@ -212,8 +211,7 @@ sealed class Route(
|
||||
nullable = true
|
||||
defaultValue = null
|
||||
},
|
||||
)
|
||||
.toImmutableList(),
|
||||
).toImmutableList(),
|
||||
)
|
||||
|
||||
object RoomByAuthor :
|
||||
@@ -256,9 +254,7 @@ sealed class Route(
|
||||
open class LatestItem {
|
||||
var newestItemPerAccount: Map<String, Note?> = mapOf()
|
||||
|
||||
fun getNewestItem(account: Account): Note? {
|
||||
return newestItemPerAccount[account.userProfile().pubkeyHex]
|
||||
}
|
||||
fun getNewestItem(account: Account): Note? = newestItemPerAccount[account.userProfile().pubkeyHex]
|
||||
|
||||
fun clearNewestItem(account: Account) {
|
||||
val userHex = account.userProfile().pubkeyHex
|
||||
@@ -279,9 +275,10 @@ open class LatestItem {
|
||||
if (newestItem == null || !account.isAcceptable(newestItem)) {
|
||||
filterMore(filter.feed(), account).firstOrNull { it.createdAt() != null && account.isAcceptable(it) }
|
||||
} else {
|
||||
filter.sort(
|
||||
filterMore(filter.applyFilter(newNotes), account) + newestItem,
|
||||
).firstOrNull { it.createdAt() != null && account.isAcceptable(it) }
|
||||
filter
|
||||
.sort(
|
||||
filterMore(filter.applyFilter(newNotes), account) + newestItem,
|
||||
).firstOrNull { it.createdAt() != null && account.isAcceptable(it) }
|
||||
}
|
||||
|
||||
newestItemPerAccount = newestItemPerAccount + Pair(account.userProfile().pubkeyHex, newNewest)
|
||||
@@ -292,16 +289,12 @@ open class LatestItem {
|
||||
open fun filterMore(
|
||||
newItems: Set<Note>,
|
||||
account: Account,
|
||||
): Set<Note> {
|
||||
return newItems
|
||||
}
|
||||
): Set<Note> = newItems
|
||||
|
||||
open fun filterMore(
|
||||
newItems: List<Note>,
|
||||
account: Account,
|
||||
): List<Note> {
|
||||
return newItems
|
||||
}
|
||||
): List<Note> = newItems
|
||||
}
|
||||
|
||||
object HomeLatestItem : LatestItem() {
|
||||
@@ -382,16 +375,12 @@ object MessagesLatestItem : LatestItem() {
|
||||
override fun filterMore(
|
||||
newItems: Set<Note>,
|
||||
account: Account,
|
||||
): Set<Note> {
|
||||
return newItems.filter { isNew(it, account) }.toSet()
|
||||
}
|
||||
): Set<Note> = newItems.filter { isNew(it, account) }.toSet()
|
||||
|
||||
override fun filterMore(
|
||||
newItems: List<Note>,
|
||||
account: Account,
|
||||
): List<Note> {
|
||||
return newItems.filter { isNew(it, account) }
|
||||
}
|
||||
): List<Note> = newItems.filter { isNew(it, account) }
|
||||
}
|
||||
|
||||
fun getRouteWithArguments(navController: NavHostController): String? {
|
||||
@@ -399,9 +388,7 @@ fun getRouteWithArguments(navController: NavHostController): String? {
|
||||
return getRouteWithArguments(currentEntry.destination, currentEntry.arguments)
|
||||
}
|
||||
|
||||
fun getRouteWithArguments(navState: State<NavBackStackEntry?>): String? {
|
||||
return navState.value?.let { getRouteWithArguments(it.destination, it.arguments) }
|
||||
}
|
||||
fun getRouteWithArguments(navState: State<NavBackStackEntry?>): String? = navState.value?.let { getRouteWithArguments(it.destination, it.arguments) }
|
||||
|
||||
private fun getRouteWithArguments(
|
||||
destination: NavDestination,
|
||||
|
||||
@@ -137,7 +137,7 @@ private fun ChatroomPrivateMessages(
|
||||
}
|
||||
}
|
||||
|
||||
CrossfadeIfEnabled(userRoom, label = "ChatroomPrivateMessages", accountViewModel = accountViewModel) { room ->
|
||||
CrossfadeIfEnabled(targetState = userRoom, label = "ChatroomPrivateMessages", accountViewModel = accountViewModel) { room ->
|
||||
if (room != null) {
|
||||
UserRoomCompose(baseNote, room, accountViewModel, nav)
|
||||
} else {
|
||||
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.filled.OpenInNew
|
||||
import androidx.compose.material.icons.automirrored.filled.Reply
|
||||
import androidx.compose.material.icons.automirrored.filled.VolumeOff
|
||||
import androidx.compose.material.icons.automirrored.filled.VolumeUp
|
||||
import androidx.compose.material.icons.filled.Bolt
|
||||
@@ -43,8 +44,6 @@ import androidx.compose.material.icons.filled.Link
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.PushPin
|
||||
import androidx.compose.material.icons.filled.Report
|
||||
import androidx.compose.material.icons.materialIcon
|
||||
import androidx.compose.material.icons.materialPath
|
||||
import androidx.compose.material.icons.outlined.ArrowForwardIos
|
||||
import androidx.compose.material.icons.outlined.BarChart
|
||||
import androidx.compose.material.icons.outlined.Bolt
|
||||
@@ -56,7 +55,6 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
@@ -66,7 +64,14 @@ import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.commons.hashtags.Amethyst
|
||||
import com.vitorpamplona.amethyst.commons.hashtags.Cashu
|
||||
import com.vitorpamplona.amethyst.commons.hashtags.CustomHashTagIcons
|
||||
import com.vitorpamplona.amethyst.commons.labels.Following
|
||||
import com.vitorpamplona.amethyst.commons.icons.Following
|
||||
import com.vitorpamplona.amethyst.commons.icons.Like
|
||||
import com.vitorpamplona.amethyst.commons.icons.Liked
|
||||
import com.vitorpamplona.amethyst.commons.icons.Reply
|
||||
import com.vitorpamplona.amethyst.commons.icons.Repost
|
||||
import com.vitorpamplona.amethyst.commons.icons.Reposted
|
||||
import com.vitorpamplona.amethyst.commons.icons.Search
|
||||
import com.vitorpamplona.amethyst.commons.icons.ZapSplit
|
||||
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
||||
@@ -153,12 +158,15 @@ fun HashCheckFailedIcon(iconSize: Dp) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LikedIcon(modifier: Modifier) {
|
||||
fun LikedIcon(
|
||||
modifier: Modifier,
|
||||
tint: Color = Color.Unspecified,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_liked),
|
||||
null,
|
||||
imageVector = Liked,
|
||||
stringResource(id = R.string.like_description),
|
||||
modifier = modifier,
|
||||
tint = Color.Unspecified,
|
||||
tint = tint,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -168,20 +176,33 @@ fun LikeIcon(
|
||||
grayTint: Color,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_like),
|
||||
imageVector = Like,
|
||||
contentDescription = stringResource(id = R.string.like_description),
|
||||
modifier = iconSizeModifier,
|
||||
tint = grayTint,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RepostIcon(
|
||||
modifier: Modifier,
|
||||
tint: Color = Color.Unspecified,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Repost,
|
||||
contentDescription = stringResource(id = R.string.boost_or_quote_description),
|
||||
modifier = modifier,
|
||||
tint = tint,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RepostedIcon(
|
||||
modifier: Modifier,
|
||||
tint: Color = Color.Unspecified,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_retweeted),
|
||||
imageVector = Reposted,
|
||||
contentDescription = stringResource(id = R.string.boost_or_quote_description),
|
||||
modifier = modifier,
|
||||
tint = tint,
|
||||
@@ -305,7 +326,7 @@ fun CommentIcon(
|
||||
tint: Color,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_comment),
|
||||
imageVector = Reply,
|
||||
contentDescription = stringResource(id = R.string.reply_description),
|
||||
modifier = iconSizeModifier,
|
||||
tint = tint,
|
||||
@@ -390,7 +411,7 @@ fun SearchIcon(
|
||||
tint: Color = Color.Unspecified,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_search),
|
||||
imageVector = Search,
|
||||
contentDescription = stringResource(id = R.string.search_button),
|
||||
modifier = modifier,
|
||||
tint = tint,
|
||||
@@ -542,7 +563,7 @@ fun ZapSplitIcon(
|
||||
tint: Color = BitcoinOrange,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = ZapSplitVector,
|
||||
imageVector = ZapSplit,
|
||||
contentDescription = stringResource(id = R.string.zap_split_title),
|
||||
modifier = modifier,
|
||||
tint = tint,
|
||||
@@ -580,38 +601,3 @@ fun ZapSplitPreview() {
|
||||
ZapSplitIcon(tint = BitcoinOrange)
|
||||
}
|
||||
}
|
||||
|
||||
public val ZapSplitVector: ImageVector
|
||||
get() {
|
||||
if (zapSplit != null) {
|
||||
return zapSplit!!
|
||||
}
|
||||
zapSplit =
|
||||
materialIcon(name = "ZapSplit") {
|
||||
materialPath {
|
||||
moveTo(7.0f, 21.0f)
|
||||
horizontalLineToRelative(-1.0f)
|
||||
lineToRelative(1.0f, -7.0f)
|
||||
horizontalLineTo(3.5f)
|
||||
curveToRelative(-0.88f, 0.0f, -0.33f, -0.75f, -0.31f, -0.78f)
|
||||
curveTo(4.48f, 10.94f, 6.42f, 7.54f, 9.01f, 3.0f)
|
||||
horizontalLineToRelative(1.0f)
|
||||
lineToRelative(-1.0f, 7.0f)
|
||||
horizontalLineToRelative(3.51f)
|
||||
curveToRelative(0.4f, 0.0f, 0.62f, 0.19f, 0.4f, 0.66f)
|
||||
curveTo(8.97f, 17.55f, 7.0f, 21.0f, 7.0f, 21.0f)
|
||||
close()
|
||||
moveTo(14.59f, 16.59f)
|
||||
lineTo(19.17f, 12.0f)
|
||||
lineTo(14.59f, 7.41f)
|
||||
lineTo(16.0f, 6.0f)
|
||||
lineToRelative(6.0f, 6.0f)
|
||||
lineToRelative(-6.0f, 6.0f)
|
||||
lineToRelative(-1.41f, -1.41f)
|
||||
close()
|
||||
}
|
||||
}
|
||||
return zapSplit!!
|
||||
}
|
||||
|
||||
private var zapSplit: ImageVector? = null
|
||||
|
||||
@@ -50,7 +50,6 @@ import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -79,7 +78,6 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
@@ -120,8 +118,8 @@ import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeightWithPadding
|
||||
import com.vitorpamplona.amethyst.ui.theme.ReactionRowZapraiser
|
||||
import com.vitorpamplona.amethyst.ui.theme.ReactionRowZapraiserWithPadding
|
||||
import com.vitorpamplona.amethyst.ui.theme.RowColSpacing
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size16Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size17Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size18dp
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size19Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size20dp
|
||||
@@ -130,7 +128,6 @@ import com.vitorpamplona.amethyst.ui.theme.Size24dp
|
||||
import com.vitorpamplona.amethyst.ui.theme.TinyBorders
|
||||
import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink
|
||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||
import com.vitorpamplona.amethyst.ui.theme.placeholderTextColorFilter
|
||||
import com.vitorpamplona.quartz.encoders.Nip30CustomEmoji
|
||||
import com.vitorpamplona.quartz.events.BaseTextNoteEvent
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
@@ -205,11 +202,11 @@ private fun InnerReactionRow(
|
||||
ZapReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav = nav)
|
||||
},
|
||||
six = {
|
||||
ViewCountReaction(
|
||||
note = baseNote,
|
||||
grayTint = MaterialTheme.colorScheme.placeholderText,
|
||||
viewCountColorFilter = MaterialTheme.colorScheme.placeholderTextColorFilter,
|
||||
)
|
||||
// ViewCountReaction(
|
||||
// note = baseNote,
|
||||
// grayTint = MaterialTheme.colorScheme.placeholderText,
|
||||
// viewCountColorFilter = MaterialTheme.colorScheme.placeholderTextColorFilter,
|
||||
// )
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -585,7 +582,7 @@ fun ReplyReaction(
|
||||
grayTint: Color,
|
||||
accountViewModel: AccountViewModel,
|
||||
showCounter: Boolean = true,
|
||||
iconSizeModifier: Modifier = Size17Modifier,
|
||||
iconSizeModifier: Modifier = Size19Modifier,
|
||||
onPress: () -> Unit,
|
||||
) {
|
||||
IconButton(
|
||||
@@ -710,7 +707,7 @@ fun BoostReaction(
|
||||
baseNote: Note,
|
||||
grayTint: Color,
|
||||
accountViewModel: AccountViewModel,
|
||||
iconSizeModifier: Modifier = Size20Modifier,
|
||||
iconSizeModifier: Modifier = Size19Modifier,
|
||||
iconSize: Dp = Size20dp,
|
||||
onQuotePress: () -> Unit,
|
||||
onForkPress: () -> Unit,
|
||||
@@ -787,8 +784,8 @@ fun LikeReaction(
|
||||
grayTint: Color,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: (String) -> Unit,
|
||||
iconSize: Dp = Size20dp,
|
||||
heartSizeModifier: Modifier = Size16Modifier,
|
||||
iconSize: Dp = Size18dp,
|
||||
heartSizeModifier: Modifier = Size18Modifier,
|
||||
iconFontSize: TextUnit = Font14SP,
|
||||
) {
|
||||
var wantsToChangeReactionSymbol by remember { mutableStateOf(false) }
|
||||
@@ -1408,12 +1405,8 @@ private fun ActionableReactionButton(
|
||||
} else {
|
||||
when (reactionType) {
|
||||
"+" -> {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_liked),
|
||||
null,
|
||||
modifier = remember { thisModifier.size(16.dp) },
|
||||
tint = Color.White,
|
||||
)
|
||||
LikedIcon(modifier = thisModifier.size(16.dp), tint = Color.White)
|
||||
|
||||
Text(
|
||||
text = removeSymbol,
|
||||
color = Color.White,
|
||||
|
||||
@@ -42,7 +42,6 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Surface
|
||||
@@ -59,7 +58,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||
@@ -95,7 +93,9 @@ import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class UpdateReactionTypeViewModel(val account: Account) : ViewModel() {
|
||||
class UpdateReactionTypeViewModel(
|
||||
val account: Account,
|
||||
) : ViewModel() {
|
||||
var nextChoice by mutableStateOf(TextFieldValue(""))
|
||||
var reactionSet by mutableStateOf(listOf<String>())
|
||||
|
||||
@@ -103,9 +103,7 @@ class UpdateReactionTypeViewModel(val account: Account) : ViewModel() {
|
||||
this.reactionSet = account.reactionChoices
|
||||
}
|
||||
|
||||
fun toListOfChoices(commaSeparatedAmounts: String): List<Long> {
|
||||
return commaSeparatedAmounts.split(",").map { it.trim().toLongOrNull() ?: 0 }
|
||||
}
|
||||
fun toListOfChoices(commaSeparatedAmounts: String): List<Long> = commaSeparatedAmounts.split(",").map { it.trim().toLongOrNull() ?: 0 }
|
||||
|
||||
fun addChoice() {
|
||||
val newValue = nextChoice.text.trim().firstFullChar()
|
||||
@@ -131,14 +129,12 @@ class UpdateReactionTypeViewModel(val account: Account) : ViewModel() {
|
||||
nextChoice = TextFieldValue("")
|
||||
}
|
||||
|
||||
fun hasChanged(): Boolean {
|
||||
return reactionSet != account.reactionChoices
|
||||
}
|
||||
fun hasChanged(): Boolean = reactionSet != account.reactionChoices
|
||||
|
||||
class Factory(val account: Account) : ViewModelProvider.Factory {
|
||||
override fun <UpdateReactionTypeViewModel : ViewModel> create(modelClass: Class<UpdateReactionTypeViewModel>): UpdateReactionTypeViewModel {
|
||||
return UpdateReactionTypeViewModel(account) as UpdateReactionTypeViewModel
|
||||
}
|
||||
class Factory(
|
||||
val account: Account,
|
||||
) : ViewModelProvider.Factory {
|
||||
override fun <UpdateReactionTypeViewModel : ViewModel> create(modelClass: Class<UpdateReactionTypeViewModel>): UpdateReactionTypeViewModel = UpdateReactionTypeViewModel(account) as UpdateReactionTypeViewModel
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,12 +293,8 @@ private fun RenderReactionOption(
|
||||
} else {
|
||||
when (reactionType) {
|
||||
"+" -> {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_liked),
|
||||
null,
|
||||
modifier = remember { Modifier.size(16.dp) },
|
||||
tint = Color.White,
|
||||
)
|
||||
LikedIcon(modifier = Modifier.size(16.dp), tint = Color.White)
|
||||
|
||||
Text(
|
||||
text = " ✖",
|
||||
color = Color.White,
|
||||
|
||||
@@ -39,7 +39,6 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -93,7 +92,10 @@ fun UserReactionsRow(
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = CenterVertically,
|
||||
modifier = Modifier.clickable(onClick = onClick).padding(10.dp),
|
||||
modifier =
|
||||
Modifier
|
||||
.clickable(onClick = onClick)
|
||||
.padding(10.dp),
|
||||
) {
|
||||
Row(verticalAlignment = CenterVertically, modifier = Modifier.width(68.dp)) {
|
||||
Text(
|
||||
@@ -143,12 +145,7 @@ private fun UserZapModel(model: UserReactionsViewModel) {
|
||||
|
||||
@Composable
|
||||
private fun UserReactionModel(model: UserReactionsViewModel) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_liked),
|
||||
null,
|
||||
modifier = Size20Modifier,
|
||||
tint = Color.Unspecified,
|
||||
)
|
||||
LikedIcon(modifier = Size20Modifier)
|
||||
|
||||
Spacer(modifier = StdHorzSpacer)
|
||||
|
||||
@@ -157,9 +154,7 @@ private fun UserReactionModel(model: UserReactionsViewModel) {
|
||||
|
||||
@Composable
|
||||
private fun UserBoostModel(model: UserReactionsViewModel) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_retweeted),
|
||||
null,
|
||||
RepostedIcon(
|
||||
modifier = Size24Modifier,
|
||||
tint = Color.Unspecified,
|
||||
)
|
||||
@@ -171,12 +166,7 @@ private fun UserBoostModel(model: UserReactionsViewModel) {
|
||||
|
||||
@Composable
|
||||
private fun UserReplyModel(model: UserReactionsViewModel) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_comment),
|
||||
null,
|
||||
modifier = Size20Modifier,
|
||||
tint = RoyalBlue,
|
||||
)
|
||||
CommentIcon(Size20Modifier, RoyalBlue)
|
||||
|
||||
Spacer(modifier = StdHorzSpacer)
|
||||
|
||||
@@ -184,7 +174,9 @@ private fun UserReplyModel(model: UserReactionsViewModel) {
|
||||
}
|
||||
|
||||
@Stable
|
||||
class UserReactionsViewModel(val account: Account) : ViewModel() {
|
||||
class UserReactionsViewModel(
|
||||
val account: Account,
|
||||
) : ViewModel() {
|
||||
val user: User = account.userProfile()
|
||||
|
||||
private var _reactions = MutableStateFlow<Map<String, Int>>(emptyMap())
|
||||
@@ -213,11 +205,10 @@ class UserReactionsViewModel(val account: Account) : ViewModel() {
|
||||
|
||||
var shouldShowDecimalsInAxis = false
|
||||
|
||||
fun formatDate(createAt: Long): String {
|
||||
return sdf.format(
|
||||
fun formatDate(createAt: Long): String =
|
||||
sdf.format(
|
||||
Instant.ofEpochSecond(createAt).atZone(ZoneId.systemDefault()).toLocalDateTime(),
|
||||
)
|
||||
}
|
||||
|
||||
fun today() = sdf.format(LocalDateTime.now())
|
||||
|
||||
@@ -452,10 +443,10 @@ class UserReactionsViewModel(val account: Account) : ViewModel() {
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
class Factory(val account: Account) : ViewModelProvider.Factory {
|
||||
override fun <UserReactionsViewModel : ViewModel> create(modelClass: Class<UserReactionsViewModel>): UserReactionsViewModel {
|
||||
return UserReactionsViewModel(account) as UserReactionsViewModel
|
||||
}
|
||||
class Factory(
|
||||
val account: Account,
|
||||
) : ViewModelProvider.Factory {
|
||||
override fun <UserReactionsViewModel : ViewModel> create(modelClass: Class<UserReactionsViewModel>): UserReactionsViewModel = UserReactionsViewModel(account) as UserReactionsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 839 B |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |