From 36a6ea4093cc04fd1ccffc2f48eeb73749545c09 Mon Sep 17 00:00:00 2001 From: Tmdhoon2 Date: Wed, 7 Feb 2024 21:51:59 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat=20::=20KeyboardAsState=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jobisdesignsystemv2/utils/KeyboardAsState.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/KeyboardAsState.kt diff --git a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/KeyboardAsState.kt b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/KeyboardAsState.kt new file mode 100644 index 0000000..9aa1c17 --- /dev/null +++ b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/KeyboardAsState.kt @@ -0,0 +1,14 @@ +package team.returm.jobisdesignsystemv2.utils + +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.ime +import androidx.compose.runtime.Composable +import androidx.compose.runtime.State +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.ui.platform.LocalDensity + +@Composable +fun keyboardAsState(): State { + val isImeVisible = WindowInsets.ime.getBottom(LocalDensity.current) > 0 + return rememberUpdatedState(newValue = isImeVisible) +} From 035323e3b7db9250c0d4720089059cee8f7c92bc Mon Sep 17 00:00:00 2001 From: Tmdhoon2 Date: Wed, 7 Feb 2024 21:52:21 +0900 Subject: [PATCH 2/5] =?UTF-8?q?refactor=20::=20textfield=20horizontal=20pa?= =?UTF-8?q?dding=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../returm/jobisdesignsystemv2/textfield/JobisTextField.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/textfield/JobisTextField.kt b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/textfield/JobisTextField.kt index cbe0096..f6a5f9c 100644 --- a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/textfield/JobisTextField.kt +++ b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/textfield/JobisTextField.kt @@ -275,7 +275,10 @@ fun JobisTextField( Column( modifier = Modifier .fillMaxWidth() - .padding(vertical = 12.dp), + .padding( + horizontal = 24.dp, + vertical = 12.dp, + ), horizontalAlignment = Alignment.Start, verticalArrangement = Arrangement.Center, ) { From 8690a4f39a451f6684274d2f1b44ed5fb0af59c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=89=E1=85=B3=E1=86=BC?= =?UTF-8?q?=E1=84=92=E1=85=AE=E1=86=AB?= Date: Wed, 7 Feb 2024 22:06:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?refactor=20::=20clickable=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../returm/jobisdesignsystemv2/utils/Clickable.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/Clickable.kt b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/Clickable.kt index 127ea1b..c9d57f2 100644 --- a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/Clickable.kt +++ b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/utils/Clickable.kt @@ -16,6 +16,9 @@ import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.input.pointer.pointerInteropFilter internal const val DURATION_MILLIS = 200 +internal const val DEFAULT_PRESS_DEPTH = 0.98f +internal const val MIN_PRESS_DEPTH = 1f +internal const val DEFAULT_DISABLED_MILLIS = 300L /** * This is the ripple upon click used by Jobis. @@ -32,10 +35,10 @@ internal const val DURATION_MILLIS = 200 @Composable fun Modifier.clickable( enabled: Boolean, - pressDepth: Float = 0.98f, + pressDepth: Float = DEFAULT_PRESS_DEPTH, onPressed: (pressed: Boolean) -> Unit, onClick: () -> Unit, - disabledMillis: Long = 300L, + disabledMillis: Long = DEFAULT_DISABLED_MILLIS, ): Modifier { var pressed by remember { mutableStateOf(false) } var lastClick by remember { mutableLongStateOf(0L) } @@ -55,17 +58,16 @@ fun Modifier.clickable( scaleY = scale } .pointerInteropFilter { event -> - if (enabled && System.currentTimeMillis() - lastClick >= disabledMillis) { + if (enabled) { when (event.action) { MotionEvent.ACTION_DOWN -> { pressed = true onPressed(true) } - MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { pressed = false onPressed(false) - if (event.action == MotionEvent.ACTION_UP) { + if (event.action == MotionEvent.ACTION_UP && System.currentTimeMillis() - lastClick >= disabledMillis) { lastClick = System.currentTimeMillis() onClick() } From 05f21ba75bacf300e267b5c3c99e8817c49969cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=89=E1=85=B3=E1=86=BC?= =?UTF-8?q?=E1=84=92=E1=85=AE=E1=86=AB?= Date: Wed, 7 Feb 2024 22:07:22 +0900 Subject: [PATCH 4/5] =?UTF-8?q?refactor=20::=20JobisButton=20=ED=8C=A8?= =?UTF-8?q?=EB=94=A9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jobisdesignsystemv2/button/JobisButton.kt | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/button/JobisButton.kt b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/button/JobisButton.kt index 6a09c2e..56c26c6 100644 --- a/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/button/JobisButton.kt +++ b/jobisdesignsystemv2/src/main/java/team/returm/jobisdesignsystemv2/button/JobisButton.kt @@ -4,9 +4,11 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.tween import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape @@ -19,7 +21,6 @@ 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.res.painterResource import androidx.compose.ui.res.stringResource @@ -30,8 +31,11 @@ import team.returm.jobisdesignsystemv2.foundation.JobisIcon import team.returm.jobisdesignsystemv2.foundation.JobisTheme import team.returm.jobisdesignsystemv2.foundation.JobisTypography import team.returm.jobisdesignsystemv2.text.JobisText +import team.returm.jobisdesignsystemv2.utils.DEFAULT_PRESS_DEPTH import team.returm.jobisdesignsystemv2.utils.DURATION_MILLIS +import team.returm.jobisdesignsystemv2.utils.MIN_PRESS_DEPTH import team.returm.jobisdesignsystemv2.utils.clickable +import team.returm.jobisdesignsystemv2.utils.keyboardAsState private val largeButtonShape = RoundedCornerShape(12.dp) private val smallButtonShape = RoundedCornerShape(8.dp) @@ -46,14 +50,35 @@ private fun BasicButton( onClick: () -> Unit, content: @Composable () -> Unit, ) { + val keyboardShow by keyboardAsState() + val padding = if (keyboardShow) { + PaddingValues( + vertical = 0.dp, + horizontal = 0.dp, + ) + } else { + PaddingValues( + vertical = 12.dp, + horizontal = 24.dp, + ) + } + val (shapeByKeyboardShow, pressDepth) = if (keyboardShow) { + RoundedCornerShape(0.dp) to MIN_PRESS_DEPTH + } else { + shape to DEFAULT_PRESS_DEPTH + } + Surface( modifier = modifier .clickable( + pressDepth = pressDepth, enabled = enabled, onPressed = onPressed, onClick = onClick, - ), - shape = shape, + ) + .padding(padding) + .imePadding(), + shape = shapeByKeyboardShow, color = backgroundColor, content = content, ) @@ -145,9 +170,7 @@ private fun LargeButton( var pressed by remember { mutableStateOf(false) } ColoredButton( - modifier = modifier - .fillMaxWidth() - .clip(largeButtonShape), + modifier = modifier.fillMaxWidth(), color = color, shape = largeButtonShape, enabled = enabled, @@ -192,7 +215,7 @@ private fun SmallButton( var pressed by remember { mutableStateOf(false) } ColoredButton( - modifier = modifier.clip(smallButtonShape), + modifier = modifier, color = color, shape = smallButtonShape, enabled = enabled, From 24f9885d480a2cf081a9cabd11077e8b43c7a4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=89=E1=85=B3=E1=86=BC?= =?UTF-8?q?=E1=84=92=E1=85=AE=E1=86=AB?= Date: Wed, 7 Feb 2024 22:12:30 +0900 Subject: [PATCH 5/5] =?UTF-8?q?chore=20::=201.1.1=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jobisdesignsystemv2/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobisdesignsystemv2/build.gradle.kts b/jobisdesignsystemv2/build.gradle.kts index 07fa6eb..a2d9ad9 100644 --- a/jobisdesignsystemv2/build.gradle.kts +++ b/jobisdesignsystemv2/build.gradle.kts @@ -46,7 +46,7 @@ afterEvaluate { from(components["release"]) groupId = "team.return.jobis.android" artifactId = "design-system-v2" - version = "1.1.0" + version = "1.1.1" } } }