Skip to content

Commit

Permalink
[feat #93] :: 로그인 퍼블리싱
Browse files Browse the repository at this point in the history
  • Loading branch information
parkuiery authored Jan 2, 2025
2 parents 10491bf + 98ad627 commit a7ce323
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ fun Modifier.horizontalPadding(
value: Dp = PaddingDefaults.ExtraLarge,
): Modifier = padding(horizontal = value)

fun Modifier.startPadding(value: Dp): Modifier = padding(start = value)

fun Modifier.endPadding(value: Dp): Modifier = padding(end = value)

fun Modifier.topPadding(
value: Dp = PaddingDefaults.Medium,
): Modifier = padding(top = value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ package team.aliens.dms.kmp.core.designsystem.button
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import team.aliens.dms.kmp.core.designsystem.foundation.DmsTheme
import team.aliens.dms.kmp.core.designsystem.foundation.DmsTypography
Expand Down Expand Up @@ -124,16 +121,16 @@ private fun ButtonColor.containedColors() = when (this) {
private fun ButtonColor.outlinedColors() = when (this) {
ButtonColor.Primary -> ButtonState(
enabled = ButtonTheme(
textColor = DmsTheme.colors.onSecondaryContainer,
borderColor = DmsTheme.colors.onSecondaryContainer,
textColor = DmsTheme.colors.secondary,
borderColor = DmsTheme.colors.secondary,
),
pressed = ButtonTheme(
textColor = DmsTheme.colors.surfaceTint,
borderColor = DmsTheme.colors.errorContainer,
textColor = DmsTheme.colors.onSecondaryContainer,
borderColor = DmsTheme.colors.onSecondaryContainer,
),
disabled = ButtonTheme(
textColor = DmsTheme.colors.surfaceTint,
borderColor = DmsTheme.colors.onError,
textColor = DmsTheme.colors.primaryContainer,
borderColor = DmsTheme.colors.primaryContainer,
),
)

Expand Down Expand Up @@ -318,8 +315,11 @@ private fun ButtonColor.roundedColors() = when (this) {
@Composable
private fun BasicButton(
modifier: Modifier = Modifier,
backgroundColor: Color,
enabled: Boolean,
shape: Shape,
borderColor: Color,
buttonType: ButtonType,
onClick: () -> Unit,
onPressed: (pressed: Boolean) -> Unit,
keyboardInteractionEnabled: Boolean,
Expand All @@ -342,162 +342,34 @@ private fun BasicButton(
} else {
shape to DEFAULT_PRESS_DEPTH
}

Box(
modifier = modifier
.clip(shape = shapeByKeyboardShow)
.background(backgroundColor)
.then(
if (buttonType == ButtonType.Outlined) {
Modifier.border(
1.dp,
color = borderColor,
shapeByKeyboardShow,
)
} else {
Modifier
},
)
.clickable(
pressDepth = pressDepth,
enabled = enabled,
onPressed = onPressed,
onClick = onClick,
),
contentAlignment = Alignment.Center,
) {
content()
}
}

/*@Composable
fun DmsButton(
modifier: Modifier = Modifier,
text: String,
enabled: Boolean = true,
onClick: () -> Unit,
) {
val backgroundColor by animateColorAsState(
targetValue = if (enabled) {
DmsTheme.colors.onSecondary
} else {
DmsTheme.colors.onTertiaryContainer
},
)
BasicButton(
modifier = modifier,
enabled = enabled,
backgroundColor = backgroundColor,
onClick = onClick,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = 24.dp,
vertical = 16.dp,
),
horizontalArrangement = Arrangement.Center,
) {
DmsText(
text = text,
style = DmsTypography.SubtitleSemiBold,
color = DmsTheme.colors.surfaceContainerHighest,
)
}
}
}*/

/*@Composable
fun DmsSmallButton(
modifier: Modifier = Modifier,
text: String,
enabled: Boolean = true,
onClick: () -> Unit,
) {
val backgroundColor by animateColorAsState(
targetValue = if (enabled) {
DmsTheme.colors.onSecondary
} else {
DmsTheme.colors.error
},
)
val contentColor by animateColorAsState(
targetValue = if (enabled) {
DmsTheme.colors.surfaceContainerHighest
} else {
DmsTheme.colors.surfaceContainerHigh
},
)
BasicButton(
modifier = modifier,
enabled = enabled,
backgroundColor = backgroundColor,
onClick = onClick,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = 14.dp,
vertical = 8.dp,
),
horizontalArrangement = Arrangement.Center,
) {
DmsText(
text = text,
style = DmsTypography.Body1Medium,
color = contentColor,
)
}
}
}*/

@Composable
fun DmsContainedButton(
modifier: Modifier = Modifier,
text: String,
enabled: Boolean = true,
shape: Shape = RoundedCornerShape(4.dp),
buttonColor: ButtonColor,
contentPadding: PaddingValues = PaddingValues(horizontal = 16.dp, vertical = 14.dp),
keyboardInteractionEnabled: Boolean = true,
onClick: () -> Unit,
) {
var pressed by remember { mutableStateOf(false) }

val buttonColors = buttonColor.containedColors()
val backgroundColor by animateColorAsState(
targetValue = if (!enabled) {
buttonColors.disabled.backgroundColor!!
} else if (pressed) {
buttonColors.pressed.backgroundColor!!
} else {
buttonColors.enabled.backgroundColor!!
},
)
val contentColor by animateColorAsState(
targetValue = if (!enabled) {
buttonColors.disabled.textColor
} else if (pressed) {
buttonColors.pressed.textColor
} else {
buttonColors.pressed.textColor
},
)

BasicButton(
modifier = modifier,
enabled = enabled,
shape = shape,
onClick = onClick,
onPressed = { pressed = it },
keyboardInteractionEnabled = keyboardInteractionEnabled,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.background(backgroundColor)
.padding(contentPadding),
horizontalArrangement = Arrangement.Center,
) {
DmsText(
text = text,
style = DmsTypography.Button0,
color = contentColor,
)
}
}
}

@Composable
fun DmsButton(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -552,49 +424,21 @@ fun DmsButton(

BasicButton(
modifier = modifier,
backgroundColor = backgroundColor,
enabled = enabled,
shape = buttonShape,
borderColor = borderColor,
buttonType = buttonType,
onClick = onClick,
onPressed = { pressed = it },
keyboardInteractionEnabled = keyboardInteractionEnabled,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.background(backgroundColor)
.border(
buttonType = buttonType,
width = 1.dp,
shape = buttonShape,
color = borderColor,
)
.padding(contentPadding),
horizontalArrangement = Arrangement.Center,
) {
DmsText(
text = text,
style = if (buttonType == ButtonType.Underline) DmsTypography.Button3 else DmsTypography.Button0,
color = contentColor,
textDecoration = if (buttonType == ButtonType.Underline) TextDecoration.Underline else TextDecoration.None,
)
}
}
}

@Composable
private fun Modifier.border(
buttonType: ButtonType,
width: Dp,
shape: Shape,
color: Color,
): Modifier {
return if (buttonType == ButtonType.Outlined) {
Modifier.border(
width = width,
shape = shape,
color = color,
DmsText(
modifier = Modifier.padding(contentPadding),
text = text,
style = if (buttonType == ButtonType.Underline) DmsTypography.Button3 else DmsTypography.Button0,
color = contentColor,
textDecoration = if (buttonType == ButtonType.Underline) TextDecoration.Underline else TextDecoration.None,
)
} else {
Modifier
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package team.aliens.dms.kmp.core.designsystem.textfield

import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package team.aliens.dms.kmp.feature.home.ui

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -37,8 +35,6 @@ import team.aliens.dms.kmp.core.designsystem.appbar.DmsTopAppBar
import team.aliens.dms.kmp.core.designsystem.button.DmsIconButton
import team.aliens.dms.kmp.core.designsystem.foundation.DmsIcon
import team.aliens.dms.kmp.core.designsystem.foundation.DmsTheme
import team.aliens.dms.kmp.core.designsystem.foundation.DmsTypography
import team.aliens.dms.kmp.core.designsystem.text.DmsText
import team.aliens.dms.kmp.feature.home.viewmodel.HomeState
import team.aliens.dms.kmp.feature.home.viewmodel.HomeViewModel

Expand Down Expand Up @@ -140,7 +136,7 @@ private fun DateCard(
// text = "${selectDate.monthNumber}월 ${selectDate.dayOfMonth}일 ${selectDate.dayOfWeek.text}요일",
// color = DmsTheme.colors.surfaceContainerLow,
// style = DmsTypography.Body1SemiBold,
//)
// )
DmsIconButton(
resource = DmsIcon.Forward,
tint = DmsTheme.colors.surfaceContainerLow,
Expand Down
Loading

0 comments on commit a7ce323

Please sign in to comment.