Skip to content

Instantly share code, notes, and snippets.

View cp-radhika-s's full-sized avatar
🎯
Focusing

Radhika canopas cp-radhika-s

🎯
Focusing
View GitHub Profile
@Composable
fun PulsateEffect() {
Button(onClick = {
// clicked
}, shape = RoundedCornerShape(12.dp),
contentPadding = PaddingValues(16.dp),
modifier = Modifier.bounceClick()) {
Text(text = "Click me")
}
}
enum class ButtonState { Pressed, Idle }
fun Modifier.bounceClick() = composed {
var buttonState by remember { mutableStateOf(ButtonState.Idle) }
val scale by animateFloatAsState(if (buttonState == ButtonState.Pressed) 0.70f else 1f)
this
.graphicsLayer {
scaleX = scale
scaleY = scale
}
Transitions: {
default: {
from: 'start',
to: 'end',
onSwipe: {
anchor: 'contentBg',
direction: 'up',
side: 'top'
},
}
start: {
date: {
width: 'spread',
height: 'wrap',
start: ['parent', 'start'],
end: ['parent', 'end'],
top: ['subTitleDivider','bottom'],
},
actions: {
width: 'spread',
Text(
modifier = Modifier
.layoutId("date")
.fillMaxWidth()
.padding(6.dp),
text = "September, 2022", fontSize = 16.sp,
textAlign = TextAlign.Center,
color = Gray
)
Row(
start: {
title: {
width: 'spread',
height: 'wrap',
start: ['parent', 'start'],
end: ['parent', 'end'],
top: ['parent','top',200],
},
titleDivider: {
width: 'spread',
Text(
text = "Fresh Strawberry Cake", fontSize = 22.sp,
textAlign = TextAlign.Center,
fontWeight = FontWeight.SemiBold, modifier = Modifier
.layoutId("title")
.fillMaxWidth()
.padding(10.dp)
)
Divider(
start: {
...
contentBg: {
width: 'spread',
height: 'spread',
start: ['parent', 'start',16],
end: ['parent', 'end',16],
top: ['parent','top', 200],
bottom: ['parent','bottom'],
}
Box(
modifier = Modifier
.fillMaxHeight()
.background(White, shape = RoundedCornerShape(topStart = corners, topEnd = corners))
.layoutId("contentBg")
)
start: {
headerImage: {
width: "spread",
height: 250,
top: ['parent', 'top', 0],
start: ['parent', 'start', 0],
end: ['parent', 'end', 0],
translationY: 0,
alpha: 1
}