Skip to content

Instantly share code, notes, and snippets.

@zivkesten
Created July 6, 2025 06:42
Show Gist options
  • Save zivkesten/7eae3f93449a120e035c651ea5eed405 to your computer and use it in GitHub Desktop.
Save zivkesten/7eae3f93449a120e035c651ea5eed405 to your computer and use it in GitHub Desktop.
A three
// Link to Figma with key SVGs
// https://www.figma.com/community/file/1523256749938041908
@Composable
fun KeyboardKey3D(
label: String,
modifier: Modifier = Modifier,
) {
var isPressed by remember { mutableStateOf(false) }
val keyOffset by animateDpAsState(
targetValue = if (isPressed) 80.dp else 0.dp,
animationSpec = spring(
dampingRatio = 0.5f,
)
)
Box(
modifier = modifier
.fillMaxSize()
.clickable(
onClick = { /* action */ },
onClickLabel = "Key Press"
)
.pointerInput(Unit) {
detectTapGestures(
onPress = {
isPressed = true
tryAwaitRelease()
isPressed = false
}
)
}
) {
Image(
modifier = Modifier.align(Center),
painter = painterResource(R.drawable.button_base),
contentDescription = "Background",
)
Box(
modifier = Modifier
.align(Center)
.padding(bottom = 70.dp)
.graphicsLayer(
translationY = keyOffset.value
),
) {
Image(
painter = painterResource(R.drawable.button),
contentDescription = "Logo",
)
Text(
text = label,
modifier = Modifier
.align(Center)
.padding(bottom = 110.dp)
.padding(end = 20.dp)
.graphicsLayer {
rotationX = 40f
rotationY = -10f
rotationZ = 30f
},
color = Color.White,
style = androidx.compose.ui.text.TextStyle(
fontSize = 36.sp,
fontWeight = FontWeight.Bold
)
)
}
Image(
modifier = Modifier.align(Center),
painter = painterResource(R.drawable.base_front),
contentDescription = null,
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment