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
val buttonInteractionSource = remember { MutableInteractionSource() } | |
Box( | |
modifier = Modifier | |
.clickable( | |
onClick = {}, | |
interactionSource = buttonInteractionSource | |
) | |
.scaleOnPress(buttonInteractionSource) | |
) |
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
Box( | |
modifier = Modifier | |
.clickable( | |
onClick = {} | |
) | |
) |
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 fun onTouchEvent() { | |
binding.llButtonContainer.setOnTouchListener { _, event -> | |
if (event.action == MotionEvent.ACTION_DOWN) { | |
// do this when button pressed | |
return@setOnTouchListener true <-- important to receive events which come after ACTION_DOWN | |
} else if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) { | |
// do this when button user lifts their finger or cancels the interaction | |
} | |
return@setOnTouchListener false | |
} |
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 fun showsubtitle() { | |
tvSubtitle.updateHeight(ConstraintLayout.LayoutParams.WRAP_CONTENT) | |
//TODO measure the view | |
//TODO animate | |
} |
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 fun showSubtitle() { | |
//TODO measure the view | |
val subtitleHeight = tvSubtitle.measuredHeight | |
tvSubtitle.height = 0 | |
tvsubtitle.isVisible = true | |
val heightAnimator = ValueAnimator.of Int(0, subtitleHeight) | |
heightAnimator.addUpdateListener { | |
tvSubtitle.updateHeight(it.animatedValue as Int) | |
} |
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
val totalMarginForSubtitle = 2 + 16.toPx() | |
tvSubtitle.measure( | |
View.MeasureSpec.makeMeasureSpec | |
clContainer.width - totalMarginForSubtitle, | |
View.MeasureSpec. EXACTLY | |
), | |
View.MeasureSpec.UNSPECIFIED | |
) | |
val subtitleHeight = tvsubtitle.measuredHeight |
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
fun darkenColor(@ColorInt color: Int): Int { | |
return Color.HSVToColor(FloatArray(3).apply { | |
Color.colorToHSV(color, this) | |
this[2] *= 0.7f | |
}) | |
} |
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
ClipRect( | |
child: CustomPaint( | |
size: Size(CIRCLE_RADIUS, CIRCLE_RADIUS), | |
painter: DrawCircle(color, CIRCLE_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
CustomPaint( | |
size: Size(CIRCLE_RADIUS, CIRCLE_RADIUS), | |
painter: DrawCircle(color, CIRCLE_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
CustomPaint( | |
size: Size(CIRCLE_RADIUS * 2, CIRCLE_RADIUS * 2), | |
painter: DrawCircle(color, CIRCLE_RADIUS), | |
); |