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
| data class TimeData( | |
| val hours: TimeUnit = TimeUnit(), | |
| val mins: TimeUnit = TimeUnit(), | |
| val secs: TimeUnit = TimeUnit(), | |
| ) { | |
| fun isDataFull() = hours.leftDigit > 0 | |
| fun isDataEmpty() = | |
| hours.leftDigit == 0 && hours.rightDigit == 0 | |
| && mins.leftDigit == 0 && mins.rightDigit == 0 |
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
| @Composable | |
| fun TimeDisplay( | |
| time: TimeData = TimeData(), | |
| ) { | |
| val timeUnitColor = if (time.isDataEmpty()) GRAY_TEXT else BLUE_LIGHT | |
| Row( | |
| horizontalArrangement = Arrangement.spacedBy(16.dp) | |
| ) { |
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
| private fun addTime(value: String) { | |
| val intValue = value.toInt() | |
| val hours = TimeUnit( | |
| leftDigit = timeState.value.hours.rightDigit, | |
| rightDigit = timeState.value.mins.leftDigit, | |
| ) | |
| val mins = TimeUnit( | |
| leftDigit = timeState.value.mins.rightDigit, | |
| rightDigit = timeState.value.secs.leftDigit, | |
| ) |
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
| private fun deleteTime() { | |
| val secs = TimeUnit( | |
| rightDigit = timeState.value.secs.leftDigit, | |
| leftDigit = timeState.value.mins.rightDigit, | |
| ) | |
| val mins = TimeUnit( | |
| rightDigit = timeState.value.mins.leftDigit, | |
| leftDigit = timeState.value.hours.rightDigit, | |
| ) | |
| val hours = TimeUnit( |
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
| private fun onKeyPress(key: Keypad) { | |
| when(key) { | |
| Keypad.KeyDelete -> { | |
| /* when delete key is clicked */ | |
| if (timeState.value.isDataEmpty()) | |
| return | |
| deleteTime() | |
| } | |
| Keypad.Key00 -> { | |
| /* when double zero key is clicked */ |
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
| @Composable | |
| fun HeaderBarParallaxScroll() { | |
| val scrollState = rememberScrollState() | |
| Box { | |
| Column( | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .verticalScroll(scrollState), | |
| ) { | |
| Box( |
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
| @Composable | |
| fun ImageParallaxScroll() { | |
| val scrollState = rememberScrollState() | |
| Column( | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .verticalScroll(scrollState), | |
| ) { | |
| Box( | |
| modifier = Modifier |
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
| val xAxisSpace = (size.width - paddingSpace.toPx()) / xValues.size | |
| val yAxisSpace = size.height / yValues.size | |
| /** placing x axis points */ | |
| for (i in xValues.indices) { | |
| drawContext.canvas.nativeCanvas.drawText( | |
| "${xValues[i]}", | |
| xAxisSpace * (i + 1), | |
| size.height - 30, | |
| textPaint | |
| ) |
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
| /** calculating the connection points */ | |
| for (i in 1 until coordinates.size) { | |
| controlPoints1.add(PointF((coordinates[i].x + coordinates[i - 1].x) / 2, coordinates[i - 1].y)) | |
| controlPoints2.add(PointF((coordinates[i].x + coordinates[i - 1].x) / 2, coordinates[i].y)) | |
| } |
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
| /** drawing the path */ | |
| val stroke = Path().apply { | |
| reset() | |
| moveTo(coordinates.first().x, coordinates.first().y) | |
| for (i in 0 until coordinates.size - 1) { | |
| cubicTo( | |
| controlPoints1[i].x,controlPoints1[i].y, | |
| controlPoints2[i].x,controlPoints2[i].y, | |
| coordinates[i + 1].x,coordinates[i + 1].y | |
| ) |