Adds an outlined Zap icon to match the other icons

This commit is contained in:
Vitor Pamplona 2024-06-18 18:59:41 -04:00
parent a23cbd1a38
commit a463e8889c
3 changed files with 98 additions and 1 deletions

View File

@ -71,6 +71,7 @@ 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.Zap
import com.vitorpamplona.amethyst.commons.icons.ZapSplit
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
@ -239,6 +240,7 @@ fun ReactionRowIconPreview() {
CommentIcon(Size20Modifier, Color.Unspecified)
RepostedIcon(Size20Modifier)
LikeIcon(Size20Modifier, Color.Unspecified)
OutlinedZapIcon(Size20Modifier)
ZapIcon(Size20Modifier)
ZappedIcon(Size20Modifier)
}
@ -258,6 +260,20 @@ fun ZapIcon(
)
}
@Composable
fun OutlinedZapIcon(
modifier: Modifier,
tint: Color = Color.Unspecified,
contentDescriptor: Int = R.string.zap_description,
) {
Icon(
imageVector = Zap,
contentDescription = stringResource(contentDescriptor),
tint = tint,
modifier = modifier,
)
}
@Composable
fun CashuIcon(modifier: Modifier) {
Icon(

View File

@ -1094,7 +1094,7 @@ fun ZapReaction(
if (it) {
ZappedIcon(iconSizeModifier)
} else {
ZapIcon(iconSizeModifier, grayTint)
OutlinedZapIcon(iconSizeModifier, grayTint)
}
}
}

View File

@ -0,0 +1,81 @@
/**
* Copyright (c) 2024 Vitor Pamplona
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.vitorpamplona.amethyst.commons.icons
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.vector.DefaultFillType
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.PathBuilder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.tooling.preview.Preview
@Preview
@Composable
private fun VectorPreview() {
Image(Zap, null)
}
private var zap: ImageVector? = null
val Zap: ImageVector
get() =
zap ?: materialIcon(name = "Zap") {
materialOutlinedPath {
moveTo(11.0f, 21.0f)
horizontalLineToRelative(-1.0f)
lineToRelative(1.0f, -7.0f)
horizontalLineTo(7.5f)
curveToRelative(-0.58f, 0.0f, -0.57f, -0.32f, -0.38f, -0.66f)
curveToRelative(0.19f, -0.34f, 0.05f, -0.08f, 0.07f, -0.12f)
curveTo(8.48f, 10.94f, 10.42f, 7.54f, 13.0f, 3.0f)
horizontalLineToRelative(1.0f)
lineToRelative(-1.0f, 7.0f)
horizontalLineToRelative(3.5f)
curveToRelative(0.49f, 0.0f, 0.56f, 0.33f, 0.47f, 0.51f)
lineToRelative(-0.07f, 0.15f)
curveTo(12.96f, 17.55f, 11.0f, 21.0f, 11.0f, 21.0f)
close()
}
}.also { zap = it }
inline fun ImageVector.Builder.materialOutlinedPath(
fillAlpha: Float = 1f,
strokeAlpha: Float = 1f,
pathFillType: PathFillType = DefaultFillType,
pathBuilder: PathBuilder.() -> Unit,
) = path(
fill = null,
fillAlpha = fillAlpha,
stroke = SolidColor(Color.Black),
strokeAlpha = strokeAlpha,
strokeLineWidth = 1.4f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Bevel,
strokeLineMiter = 1f,
pathFillType = pathFillType,
pathBuilder = pathBuilder,
)