Created
July 9, 2021 16:25
-
-
Save mahendranv/87de70694221bd28446910ce25ab5c24 to your computer and use it in GitHub Desktop.
A tag shape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.foundation.shape.GenericShape | |
import androidx.compose.material.Surface | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.tooling.preview.Preview | |
import androidx.compose.ui.unit.dp | |
import com.ex2.dribbble.ui.theme.DribbleUITheme | |
val TagShape3 = GenericShape { size, _ -> | |
val w = size.width / 27f | |
val h = size.height / 11f | |
moveTo(5f * w, 0f * h) | |
lineTo(25f * w, 0f * h) | |
cubicTo(26f * w, 0f, 27f * w, 1f * h, 27f * w, 2f * h) | |
lineTo(27f * w, 9f * h) | |
cubicTo(27f * w, 10f * h, 26f * w, 11f * h, 25f * w, 11f * h) | |
lineTo(5f * w, 11f * h) | |
lineTo(1f * w, 7f * h) | |
cubicTo(0f * w, 6f * h, 0f * w, 5f * h, 1f * w, 4f * h) | |
} | |
@Composable | |
fun TagView(tag: String, modifier: Modifier = Modifier) { | |
Surface( | |
color = color_green, | |
shape = TagShape3, | |
) { | |
Text( | |
text = tag, | |
modifier = Modifier.padding(start = 40.dp, end = 8.dp, top = 8.dp, bottom = 8.dp) | |
) | |
} | |
} | |
@Preview(showBackground = true) | |
@Composable | |
fun previewTagShape() { | |
DribbleUITheme { | |
Box(modifier = Modifier.padding(24.dp)) { | |
TagView(tag = "Compose") | |
} | |
} | |
} |
Author
mahendranv
commented
Jul 9, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment