Skip to content

Commit

Permalink
[REFACTOR/#63] AddAlarmButton 가독성 향상
Browse files Browse the repository at this point in the history
  • Loading branch information
DongChyeon committed Feb 3, 2025
1 parent b3f89d5 commit 6fccecd
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions feature/home/src/main/java/com/yapp/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -506,39 +506,38 @@ private fun AddAlarmButton(
disabledContentColor: Color = OrbitTheme.colors.gray_400,
) {
val interactionSource = remember { MutableInteractionSource() }
val isPressed = interactionSource.collectIsPressedAsState().value
val isPressed by interactionSource.collectIsPressedAsState()

val currentContainerColor = if (isPressed) pressedContainerColor else containerColor
val currentContentColor = if (isPressed) pressedContentColor else contentColor
val (currentContainerColor, currentContentColor) = when {
!enabled -> disabledContainerColor to disabledContentColor
isPressed -> pressedContainerColor to pressedContentColor
else -> containerColor to contentColor
}

val padding by animateDpAsState(
targetValue = if (isPressed) 2.dp else 0.dp,
animationSpec = tween(durationMillis = 100),
label = "",
label = "PaddingAnimation",
)

Button(
onClick = onClick,
modifier = modifier
.padding(all = padding)
.height(height),
enabled = enabled,
shape = RoundedCornerShape(16.dp),
colors = ButtonDefaults.buttonColors(
containerColor = currentContainerColor,
contentColor = currentContentColor,
disabledContainerColor = disabledContainerColor,
disabledContentColor = disabledContentColor,
),
contentPadding = PaddingValues(
horizontal = 32.dp,
),
contentPadding = PaddingValues(horizontal = 32.dp),
interactionSource = interactionSource,
modifier = modifier
.then(if (padding > 0.dp) Modifier.padding(padding) else Modifier)
.height(height - padding * 2),
) {
Icon(
painter = painterResource(core.designsystem.R.drawable.ic_plus),
tint = Color.Unspecified,
contentDescription = "IC_PLUS",
contentDescription = "Add Alarm",
)

Spacer(modifier = Modifier.width(4.dp))
Expand Down

0 comments on commit 6fccecd

Please sign in to comment.