Brings the ZapForwarding icon to Compose

This commit is contained in:
Vitor Pamplona 2024-03-12 11:11:46 -04:00
parent abb9edc46b
commit 9a6a857a11
4 changed files with 94 additions and 107 deletions

View File

@ -56,8 +56,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowForwardIos
import androidx.compose.material.icons.automirrored.outlined.ArrowForwardIos
import androidx.compose.material.icons.filled.Bolt import androidx.compose.material.icons.filled.Bolt
import androidx.compose.material.icons.filled.CurrencyBitcoin import androidx.compose.material.icons.filled.CurrencyBitcoin
import androidx.compose.material.icons.filled.LocationOff import androidx.compose.material.icons.filled.LocationOff
@ -147,6 +145,7 @@ import com.vitorpamplona.amethyst.ui.note.NoteCompose
import com.vitorpamplona.amethyst.ui.note.PollIcon import com.vitorpamplona.amethyst.ui.note.PollIcon
import com.vitorpamplona.amethyst.ui.note.RegularPostIcon import com.vitorpamplona.amethyst.ui.note.RegularPostIcon
import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.note.UsernameDisplay
import com.vitorpamplona.amethyst.ui.note.ZapSplitIcon
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.MyTextField import com.vitorpamplona.amethyst.ui.screen.loggedIn.MyTextField
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ShowUserSuggestionList import com.vitorpamplona.amethyst.ui.screen.loggedIn.ShowUserSuggestionList
@ -1073,30 +1072,7 @@ fun FowardZapTo(
.fillMaxWidth() .fillMaxWidth()
.padding(bottom = 10.dp), .padding(bottom = 10.dp),
) { ) {
Box( ZapSplitIcon()
Modifier
.height(20.dp)
.width(25.dp),
) {
Icon(
imageVector = Icons.Outlined.Bolt,
contentDescription = stringResource(id = R.string.zaps),
modifier =
Modifier
.size(20.dp)
.align(Alignment.CenterStart),
tint = BitcoinOrange,
)
Icon(
imageVector = Icons.AutoMirrored.Outlined.ArrowForwardIos,
contentDescription = stringResource(id = R.string.zaps),
modifier =
Modifier
.size(13.dp)
.align(Alignment.CenterEnd),
tint = BitcoinOrange,
)
}
Text( Text(
text = stringResource(R.string.zap_split_title), text = stringResource(R.string.zap_split_title),
@ -1436,50 +1412,10 @@ private fun ForwardZapTo(
IconButton( IconButton(
onClick = { onClick() }, onClick = { onClick() },
) { ) {
Box( if (!postViewModel.wantsForwardZapTo) {
Modifier ZapSplitIcon(tint = MaterialTheme.colorScheme.onBackground)
.height(20.dp) } else {
.width(25.dp), ZapSplitIcon(tint = BitcoinOrange)
) {
if (!postViewModel.wantsForwardZapTo) {
Icon(
imageVector = Icons.Default.Bolt,
contentDescription = stringResource(R.string.add_zap_split),
modifier =
Modifier
.size(20.dp)
.align(Alignment.CenterStart),
tint = MaterialTheme.colorScheme.onBackground,
)
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowForwardIos,
contentDescription = null,
modifier =
Modifier
.size(13.dp)
.align(Alignment.CenterEnd),
tint = MaterialTheme.colorScheme.onBackground,
)
} else {
Icon(
imageVector = Icons.Outlined.Bolt,
contentDescription = stringResource(id = R.string.cancel_zap_split),
modifier =
Modifier
.size(20.dp)
.align(Alignment.CenterStart),
tint = BitcoinOrange,
)
Icon(
imageVector = Icons.AutoMirrored.Outlined.ArrowForwardIos,
contentDescription = null,
modifier =
Modifier
.size(13.dp)
.align(Alignment.CenterEnd),
tint = BitcoinOrange,
)
}
} }
} }
} }

View File

@ -20,7 +20,11 @@
*/ */
package com.vitorpamplona.amethyst.ui.note package com.vitorpamplona.amethyst.ui.note
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.OpenInNew import androidx.compose.material.icons.automirrored.filled.OpenInNew
@ -38,17 +42,25 @@ import androidx.compose.material.icons.filled.Link
import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.PushPin import androidx.compose.material.icons.filled.PushPin
import androidx.compose.material.icons.filled.Report 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.BarChart
import androidx.compose.material.icons.outlined.Bolt
import androidx.compose.material.icons.outlined.PlayCircle import androidx.compose.material.icons.outlined.PlayCircle
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
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.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
@ -73,7 +85,7 @@ fun FollowingIcon(iconSize: Dp) {
Icon( Icon(
painter = painterResource(R.drawable.following), painter = painterResource(R.drawable.following),
contentDescription = stringResource(id = R.string.following), contentDescription = stringResource(id = R.string.following),
modifier = remember(iconSize) { Modifier.size(iconSize) }, modifier = Modifier.size(iconSize),
tint = Color.Unspecified, tint = Color.Unspecified,
) )
} }
@ -506,3 +518,75 @@ fun IncognitoIconOff(
tint = tint, tint = tint,
) )
} }
@Composable
fun ZapSplitIcon(
modifier: Modifier = Size20Modifier,
tint: Color = BitcoinOrange,
) {
Icon(
imageVector = ZapSplitVector,
contentDescription = stringResource(id = R.string.zap_split_title),
modifier = modifier,
tint = tint,
)
}
@Preview
@Composable
fun ZapSplitPreview() {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Box(
Modifier.height(20.dp).width(25.dp),
) {
Icon(
imageVector = Icons.Outlined.Bolt,
contentDescription = stringResource(id = R.string.zaps),
modifier = Modifier.size(20.dp).align(Alignment.CenterStart),
tint = BitcoinOrange,
)
Icon(
imageVector = Icons.Outlined.ArrowForwardIos,
contentDescription = stringResource(id = R.string.zaps),
modifier = Modifier.size(13.dp).align(Alignment.CenterEnd),
tint = BitcoinOrange,
)
}
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

View File

@ -28,11 +28,9 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
@ -162,9 +160,6 @@ fun ClickableUserPicture(
onClick: ((User) -> Unit)? = null, onClick: ((User) -> Unit)? = null,
onLongClick: ((User) -> Unit)? = null, onLongClick: ((User) -> Unit)? = null,
) { ) {
val interactionSource = remember { MutableInteractionSource() }
val ripple = rememberRipple(bounded = false, radius = size)
// BaseUser is the same reference as accountState.user // BaseUser is the same reference as accountState.user
val myModifier = val myModifier =
remember { remember {
@ -174,16 +169,12 @@ fun ClickableUserPicture(
onClick = { onClick(baseUser) }, onClick = { onClick(baseUser) },
onLongClick = { onLongClick(baseUser) }, onLongClick = { onLongClick(baseUser) },
role = Role.Button, role = Role.Button,
interactionSource = interactionSource,
indication = ripple,
) )
} else if (onClick != null) { } else if (onClick != null) {
Modifier.size(size) Modifier.size(size)
.clickable( .clickable(
onClick = { onClick(baseUser) }, onClick = { onClick(baseUser) },
role = Role.Button, role = Role.Button,
interactionSource = interactionSource,
indication = ripple,
) )
} else { } else {
Modifier.size(size) Modifier.size(size)

View File

@ -20,30 +20,21 @@
*/ */
package com.vitorpamplona.amethyst.ui.note.elements package com.vitorpamplona.amethyst.ui.note.elements
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
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.ClickableText
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowForwardIos
import androidx.compose.material.icons.outlined.Bolt
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
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.res.stringResource
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.note.UserPicture import com.vitorpamplona.amethyst.ui.note.UserPicture
import com.vitorpamplona.amethyst.ui.note.ZapSplitIcon
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
import com.vitorpamplona.amethyst.ui.theme.Size25dp import com.vitorpamplona.amethyst.ui.theme.Size25dp
@ -78,22 +69,7 @@ fun DisplayZapSplits(
if (list.isEmpty()) return if (list.isEmpty()) return
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Box( ZapSplitIcon(tint = BitcoinOrange)
Modifier.height(20.dp).width(25.dp),
) {
Icon(
imageVector = Icons.Outlined.Bolt,
contentDescription = stringResource(id = R.string.zaps),
modifier = Modifier.size(20.dp).align(Alignment.CenterStart),
tint = BitcoinOrange,
)
Icon(
imageVector = Icons.Outlined.ArrowForwardIos,
contentDescription = stringResource(id = R.string.zaps),
modifier = Modifier.size(13.dp).align(Alignment.CenterEnd),
tint = BitcoinOrange,
)
}
Spacer(modifier = StdHorzSpacer) Spacer(modifier = StdHorzSpacer)