Skip to content

Instantly share code, notes, and snippets.

View alohaabhi's full-sized avatar

Abhishek Jangra alohaabhi

View GitHub Profile
val buttonInteractionSource = remember { MutableInteractionSource() }
Box(
modifier = Modifier
.clickable(
onClick = {},
interactionSource = buttonInteractionSource
)
.scaleOnPress(buttonInteractionSource)
)
Box(
modifier = Modifier
.clickable(
onClick = {}
)
)
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
}
private fun showsubtitle() {
tvSubtitle.updateHeight(ConstraintLayout.LayoutParams.WRAP_CONTENT)
//TODO measure the view
//TODO animate
}
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)
}
val totalMarginForSubtitle = 2 + 16.toPx()
tvSubtitle.measure(
View.MeasureSpec.makeMeasureSpec
clContainer.width - totalMarginForSubtitle,
View.MeasureSpec. EXACTLY
),
View.MeasureSpec.UNSPECIFIED
)
val subtitleHeight = tvsubtitle.measuredHeight
@alohaabhi
alohaabhi / DarkenColor.Kt
Created October 31, 2021 10:50
color_shade
fun darkenColor(@ColorInt color: Int): Int {
return Color.HSVToColor(FloatArray(3).apply {
Color.colorToHSV(color, this)
this[2] *= 0.7f
})
}
ClipRect(
child: CustomPaint(
size: Size(CIRCLE_RADIUS, CIRCLE_RADIUS),
painter: DrawCircle(color, CIRCLE_RADIUS)
)
);
CustomPaint(
size: Size(CIRCLE_RADIUS, CIRCLE_RADIUS),
painter: DrawCircle(color, CIRCLE_RADIUS)
);
CustomPaint(
size: Size(CIRCLE_RADIUS * 2, CIRCLE_RADIUS * 2),
painter: DrawCircle(color, CIRCLE_RADIUS),
);