Skip to content

Instantly share code, notes, and snippets.

View zurche's full-sized avatar
👋

Alejandro Zurcher zurche

👋
View GitHub Profile
@Composable
fun PerformanceChart(modifier: Modifier = Modifier, list: List<Float> = listOf(10f, 20f, 3f, 1f)) {
val zipList: List<Pair<Float, Float>> = list.zipWithNext()
Row(modifier = modifier) {
val max = list.max()
val min = list.min()
val lineColor =
if (list.last() > list.first()) LightOlive else LightCarmin // <-- Line color is Green if its going up and Red otherwise
private fun getValuePercentageForRange(value: Float, max: Float, min: Float) =
(value - min) / (max - min)
@zurche
zurche / ThankYouKotlin.kt
Created September 11, 2023 19:56
Max and Min
val max = list.max()
val min = list.min()
@Composable
fun PerformanceChart(modifier: Modifier = Modifier, list: List<Float> = listOf(1f, 2f, 3f, 4f)) {
val zipList: List<Pair<Float, Float>> = list.zipWithNext()
Row(modifier = modifier) {
val lineColor = Color.Black
for (pair in zipList) {
Canvas(
modifier = Modifier
@zurche
zurche / zippedList.kt
Created September 11, 2023 19:52
Output
List<Pair<Float, Float>> = listOf(Pair(1f, 2f), Pair(2f, 3f), Pair(3f, 4f))
@zurche
zurche / Input.kt
Created September 11, 2023 19:50
Input
list: List<Float> = listOf(1f, 2f, 3f, 4f)
@zurche
zurche / zipList.kt
Created September 11, 2023 19:50
Zip List
val zipList: List<Pair<Float, Float>> = list.zipWithNext()
@zurche
zurche / PerfChart.kt
Last active September 11, 2023 19:48
Line Drawing
Canvas(
modifier = Modifier
.fillMaxHeight()
.weight(1f),
onDraw = {
val fromPoint = Offset(x = 0f, y = size.height)
val toPoint = Offset(x = size.width, y = 0f)
drawLine(
color = lineColor,
@zurche
zurche / AssetPerformanceCard.kt
Created September 11, 2023 19:38
Asset Performance Card
@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)
@zurche
zurche / ValueView.kt
Created September 11, 2023 19:36
ValueView Composable
@Composable
fun ValueView(currentValue: Float = 113.02211f, total: Float = 1356f) {
Column(
modifier = Modifier
.padding(start = 10.dp),
horizontalAlignment = Alignment.End
) {
Text(
text = currentValue.toString(),
style = MaterialTheme.typography.labelMedium,