Skip to content

Commit

Permalink
[YDS-#215] noRippleClickable 이름 변경 및 개선, LocalYdsContentColor public (#…
Browse files Browse the repository at this point in the history
…236)

* rename: NoRippleClickable -> YdsClickable

* rename: LocalContentColor -> LocalYdsContentColor

* Resolve conflict

* Resolve conflict
  • Loading branch information
cometj03 authored Jan 15, 2024
1 parent cb30c8d commit 53a7a5e
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import com.yourssu.design.system.compose.base.ProvideTextStyle
import com.yourssu.design.system.compose.foundation.LocalContentColor
import com.yourssu.design.system.compose.foundation.LocalYdsContentColor
import com.yourssu.design.system.compose.foundation.LocalYdsColorScheme
import com.yourssu.design.system.compose.foundation.LocalYdsTypography
import com.yourssu.design.system.compose.foundation.YdsColorScheme
Expand All @@ -26,7 +26,7 @@ fun YdsTheme(
CompositionLocalProvider(
LocalYdsColorScheme provides colors,
LocalYdsTypography provides typography,
LocalContentColor provides colors.textPrimary,
LocalYdsContentColor provides colors.textPrimary,
) {
ProvideTextStyle(value = typography.body1) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.yourssu.design.system.compose.YdsTheme
import com.yourssu.design.system.compose.base.IconSize
import com.yourssu.design.system.compose.base.YdsText
import com.yourssu.design.system.compose.base.Icon
import com.yourssu.design.system.compose.base.noRippleClickable
import com.yourssu.design.system.compose.base.ydsClickable
import com.yourssu.design.system.compose.states.ButtonSizeState

enum class CheckBoxSize {
Expand Down Expand Up @@ -84,7 +84,7 @@ fun CheckBox(
val betweenSpace = sizeState.betweenSpace

val clickableModifier = if (isDisabled) Modifier else
Modifier.noRippleClickable(interactionSource) { onCheckedChange(!checked) }
Modifier.ydsClickable(interactionSource) { onCheckedChange(!checked) }

Row(
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.yourssu.design.system.compose.R
import com.yourssu.design.system.compose.YdsTheme
import com.yourssu.design.system.compose.base.YdsText
import com.yourssu.design.system.compose.base.Icon
import com.yourssu.design.system.compose.base.noRippleClickable
import com.yourssu.design.system.compose.base.ydsClickable

@Composable
fun ListItem(
Expand All @@ -46,7 +46,7 @@ fun ListItem(
modifier = modifier
.fillMaxWidth()
.height(48.dp)
.noRippleClickable(interactionSource) {
.ydsClickable(interactionSource) {
if (!isDisabled) {
onClick()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.yourssu.design.system.compose.YdsTheme
import com.yourssu.design.system.compose.base.noRippleClickable
import com.yourssu.design.system.compose.base.ydsClickable
import com.yourssu.design.system.compose.rule.YdsEasing
import com.yourssu.design.system.compose.rule.YdsBorder

Expand Down Expand Up @@ -57,7 +57,7 @@ fun Toggle(
}

val clickableModifier = if (isDisabled) modifier else
modifier.noRippleClickable(interactionSource) { onCheckedChange(!checked) }
modifier.ydsClickable(interactionSource) { onCheckedChange(!checked) }

Box(
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.yourssu.design.system.compose.foundation.LocalContentColor
import com.yourssu.design.system.compose.foundation.LocalYdsContentColor

sealed class IconSize(val value: Dp) {
object ExtraSmall : IconSize(16.dp)
Expand All @@ -30,7 +30,7 @@ fun Icon(
@DrawableRes id: Int,
modifier: Modifier = Modifier,
iconSize: IconSize = IconSize.Medium,
tint: Color = LocalContentColor.current,
tint: Color = LocalYdsContentColor.current,
) {
Icon(
imageVector = ImageVector.vectorResource(id = id),
Expand All @@ -45,7 +45,7 @@ fun Icon(
imageVector: ImageVector,
modifier: Modifier = Modifier,
iconSize: IconSize = IconSize.Medium,
tint: Color = LocalContentColor.current,
tint: Color = LocalYdsContentColor.current,
) {
Icon(
painter = rememberVectorPainter(imageVector),
Expand All @@ -60,7 +60,7 @@ fun Icon(
painter: Painter,
modifier: Modifier = Modifier,
iconSize: IconSize = IconSize.Medium,
tint: Color = LocalContentColor.current,
tint: Color = LocalYdsContentColor.current,
) {
val colorFilter = ColorFilter.tint(tint)
Box(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ import androidx.compose.ui.semantics.isContainer
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Dp
import com.yourssu.design.system.compose.YdsTheme
import com.yourssu.design.system.compose.foundation.LocalContentColor
import com.yourssu.design.system.compose.foundation.LocalYdsContentColor

@Composable
fun Surface(
modifier: Modifier = Modifier,
rounding: Dp? = null,
shape: Shape = rounding?.let { RoundedCornerShape(it) } ?: RectangleShape,
color: Color = YdsTheme.colors.bgNormal,
contentColor: Color = LocalContentColor.current,
contentColor: Color = LocalYdsContentColor.current,
border: BorderStroke? = null,
content: @Composable () -> Unit,
) {
CompositionLocalProvider(
LocalContentColor provides contentColor,
LocalYdsContentColor provides contentColor,
) {
Box(
modifier = modifier
Expand Down Expand Up @@ -65,13 +65,13 @@ fun Surface(
rounding: Dp? = null,
shape: Shape = rounding?.let { RoundedCornerShape(it) } ?: RectangleShape,
color: Color = YdsTheme.colors.bgNormal,
contentColor: Color = LocalContentColor.current,
contentColor: Color = LocalYdsContentColor.current,
border: BorderStroke? = null,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
content: @Composable () -> Unit,
) {
CompositionLocalProvider(
LocalContentColor provides contentColor,
LocalYdsContentColor provides contentColor,
) {
Box(
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.yourssu.design.system.compose.base

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.ui.Modifier

/**
* (전) noRippleClickable
*
* ripple 효과가 없는 clickable입니다.
*/
inline fun Modifier.ydsClickable(
interactionSource: MutableInteractionSource,
enabled: Boolean = true,
crossinline onClick: () -> Unit,
): Modifier = this.clickable(
interactionSource = interactionSource,
indication = null,
enabled = enabled,
) {
onClick()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import com.yourssu.design.system.compose.R
import com.yourssu.design.system.compose.YdsTheme
import com.yourssu.design.system.compose.atom.BoxButton
import com.yourssu.design.system.compose.atom.TopBarButton
import com.yourssu.design.system.compose.component.topbar.TopBar
import com.yourssu.design.system.compose.component.toast.ToastDuration
import com.yourssu.design.system.compose.component.toast.ToastHost
import com.yourssu.design.system.compose.component.toast.ToastHostState
import com.yourssu.design.system.compose.component.toast.rememberToastHostState
import com.yourssu.design.system.compose.foundation.LocalContentColor
import com.yourssu.design.system.compose.component.topbar.TopBar
import com.yourssu.design.system.compose.foundation.LocalYdsContentColor
import kotlinx.coroutines.launch

private enum class ScaffoldLayoutContent { TopBar, MainContent, Snackbar, BottomBar }
Expand All @@ -38,15 +38,15 @@ fun YdsScaffold(
bottomBar: @Composable () -> Unit = {},
toastHost: @Composable (ToastHostState) -> Unit = { ToastHost(it) },
backgroundColor: Color = YdsTheme.colors.bgNormal,
contentColor: Color = LocalContentColor.current,
content: @Composable (PaddingValues) -> Unit
contentColor: Color = LocalYdsContentColor.current,
content: @Composable (PaddingValues) -> Unit,
) {
Surface(modifier = modifier, color = backgroundColor, contentColor = contentColor) {
ScaffoldLayout(
topBar = topBar,
bottomBar = bottomBar,
toast = { toastHost(toastHostState) },
content = content
content = content,
)
}
}
Expand All @@ -56,7 +56,7 @@ private fun ScaffoldLayout(
topBar: @Composable () -> Unit,
bottomBar: @Composable () -> Unit,
toast: @Composable () -> Unit,
content: @Composable (PaddingValues) -> Unit
content: @Composable (PaddingValues) -> Unit,
) {
val pxValue = LocalDensity.current.run { ToastApartFromBottom.toPx() }.toInt()

Expand Down Expand Up @@ -149,12 +149,12 @@ private fun YdsScaffoldPreview() {
scope.launch {
toastHostState.showToast(
message = "Snackbar",
duration = ToastDuration.SHORT
duration = ToastDuration.SHORT,
)
}
}
},
)
}
},
)
},
bottomBar = {
Expand All @@ -167,7 +167,7 @@ private fun YdsScaffoldPreview() {
YdsText(
text = "This is 72.dp",
style = YdsTheme.typography.body1,
color = Color.White
color = Color.White,
)
}
},
Expand All @@ -176,27 +176,33 @@ private fun YdsScaffoldPreview() {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
YdsText(text = "content", style = YdsTheme.typography.body1)
BoxButton(onClick = {
scope.launch {
toastHostState.showToast(
message = "잠, 아스라히 노새, 멀듯이, 흙으로 봅니다.",
duration = ToastDuration.SHORT
)
}
}, text = "짧은 토스트 버튼")
BoxButton(onClick = {
scope.launch {
toastHostState.showToast(
message = "잠, 아스라히 노새, 멀듯이, 흙으로 봅니다. 때 불러 가슴속에 나의 풀이 이름과 언덕 오면 가을 봅니다.",
duration = ToastDuration.LONG
)
}
}, text = "긴 토스트 버튼")
BoxButton(
onClick = {
scope.launch {
toastHostState.showToast(
message = "잠, 아스라히 노새, 멀듯이, 흙으로 봅니다.",
duration = ToastDuration.SHORT,
)
}
},
text = "짧은 토스트 버튼",
)
BoxButton(
onClick = {
scope.launch {
toastHostState.showToast(
message = "잠, 아스라히 노새, 멀듯이, 흙으로 봅니다. 때 불러 가슴속에 나의 풀이 이름과 언덕 오면 가을 봅니다.",
duration = ToastDuration.LONG,
)
}
},
text = "긴 토스트 버튼",
)
}
}
},
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.text.TextLayoutResult
import com.yourssu.design.system.compose.foundation.LocalContentColor
import com.yourssu.design.system.compose.foundation.LocalYdsContentColor
import com.yourssu.design.system.compose.foundation.YdsTextStyle

@Composable
Expand All @@ -17,11 +17,11 @@ fun YdsText(
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
onTextLayout: (TextLayoutResult) -> Unit = {},
style: YdsTextStyle = LocalTextStyle.current
style: YdsTextStyle = LocalTextStyle.current,
) {
val textColor = color.takeOrElse {
style.color.takeOrElse {
LocalContentColor.current
LocalYdsContentColor.current
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ private fun YdsColorScheme.pressedColorFor(color: Color): Color {
}

internal val LocalYdsColorScheme = staticCompositionLocalOf { lightColorScheme }
internal val LocalContentColor = compositionLocalOf { lightColorScheme.textPrimary }
val LocalYdsContentColor = compositionLocalOf { lightColorScheme.textPrimary }

0 comments on commit 53a7a5e

Please sign in to comment.