Skip to content

Instantly share code, notes, and snippets.

View zurche's full-sized avatar
👋

Alejandro Zurcher zurche

👋
View GitHub Profile
@zurche
zurche / TickerName.kt
Created September 11, 2023 19:30
Ticker Name Composable
@Composable
private fun TickerName(name: String = "Apple Inc.", tickerName: String = "AAPL") {
Column(
modifier = Modifier
.padding(start = 10.dp, end = 5.dp)
.width(80.dp)
) {
Text(
text = name,
style = MaterialTheme.typography.labelMedium,
@Composable
private fun AssetIcon(iconDrawable: Int = R.drawable.apple) {
Box(modifier = Modifier.size(50.dp), contentAlignment = Alignment.Center) {
Canvas(modifier = Modifier, onDraw = {
val radius = 65f
drawCircle(
color = Color.White,
radius = radius
private val mockAssetInfo = AssetInfo(
R.drawable.amd_icon,
"Advanced Micro Devices, Inc.",
"AMD",
listOf(
113.518f,
113.799f,
113.333f,
113.235f,
114.099f,
@Composable
fun AssetPerformanceCard(
assetInfo: AssetInfo = mockAssetInfo
) {
Card(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
.padding(start = 5.dp, end = 5.dp, bottom = 5.dp),
colors = CardDefaults.cardColors(containerColor = CryptoWhite)
data class AssetInfo(
val iconDrawable: Int,
val name: String,
val tickerName: String,
val lastDayChange: List<Float>,
val currentValue: Float,
val total: Float,
)
// ...
Card(
modifier = Modifier
.padding(10.dp)
.fillMaxWidth()
.height(300.dp),
shape = CubicBezierCardShape(), // <--- Here!
colors = CardDefaults.cardColors(containerColor = Color.Transparent)
) {
AnimatedVisibility(
class CubicBezierCardShape : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
val path = Path().apply {
val width = size.width
val height = size.height
class CubicBezierCardShape : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
TODO()
}
}
@Composable
@Preview(showBackground = true)
fun BezierTest() {
Canvas(modifier = Modifier.size(300.dp), onDraw = {
val path = Path().apply {
val width = size.width
val height = size.height
// Top left corner
// Top right corner
lineTo(x = width.times(.75f), y = height.times(.02f))