This file contains 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
@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, |
This file contains 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
@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 |
This file contains 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
private val mockAssetInfo = AssetInfo( | |
R.drawable.amd_icon, | |
"Advanced Micro Devices, Inc.", | |
"AMD", | |
listOf( | |
113.518f, | |
113.799f, | |
113.333f, | |
113.235f, | |
114.099f, |
This file contains 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
@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) |
This file contains 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
data class AssetInfo( | |
val iconDrawable: Int, | |
val name: String, | |
val tickerName: String, | |
val lastDayChange: List<Float>, | |
val currentValue: Float, | |
val total: Float, | |
) |
This file contains 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
// ... | |
Card( | |
modifier = Modifier | |
.padding(10.dp) | |
.fillMaxWidth() | |
.height(300.dp), | |
shape = CubicBezierCardShape(), // <--- Here! | |
colors = CardDefaults.cardColors(containerColor = Color.Transparent) | |
) { | |
AnimatedVisibility( |
This file contains 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
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 |
This file contains 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
class CubicBezierCardShape : Shape { | |
override fun createOutline( | |
size: Size, | |
layoutDirection: LayoutDirection, | |
density: Density | |
): Outline { | |
TODO() | |
} | |
} |
This file contains 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
@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 |
This file contains 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
// Top right corner | |
lineTo(x = width.times(.75f), y = height.times(.02f)) |