-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD/#16] Button / ์ปดํฌ๋ํธ ๊ตฌํ
- Loading branch information
Showing
30 changed files
with
276 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
core/src/main/java/com/terning/core/designsystem/component/button/RectangleButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.terning.core.designsystem.component.button | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.theme.TerningPointTheme | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
|
||
@Composable | ||
fun RectangleButton( | ||
style: TextStyle, | ||
paddingVertical: Dp, | ||
@StringRes text: Int, | ||
onButtonClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
isEnabled: Boolean = true | ||
) { | ||
TerningBasicButton( | ||
style = style, | ||
paddingVertical = paddingVertical, | ||
text = text, | ||
onButtonClick = onButtonClick, | ||
modifier = modifier, | ||
isEnabled = isEnabled, | ||
shape = RoundedCornerShape(0.dp), | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun RectangleButtonPreview() { | ||
TerningPointTheme { | ||
RectangleButton( | ||
style = TerningTheme.typography.button0, | ||
text = R.string.button_preview, | ||
paddingVertical = 19.dp, | ||
onButtonClick = {} | ||
) | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
core/src/main/java/com/terning/core/designsystem/component/button/RoundButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.terning.core.designsystem.component.button | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.theme.TerningPointTheme | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
|
||
@Composable | ||
fun RoundButton( | ||
style: TextStyle, | ||
paddingVertical: Dp, | ||
cornerRadius: Dp, | ||
@StringRes text: Int, | ||
onButtonClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
isEnabled: Boolean = true, | ||
) { | ||
TerningBasicButton( | ||
modifier = modifier, | ||
style = style, | ||
paddingVertical = paddingVertical, | ||
shape = RoundedCornerShape(cornerRadius), | ||
text = text, | ||
onButtonClick = onButtonClick, | ||
isEnabled = isEnabled, | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun RoundButtonPreview() { | ||
TerningPointTheme { | ||
RoundButton( | ||
style = TerningTheme.typography.button0, | ||
text = R.string.button_preview, | ||
paddingVertical = 19.dp, | ||
cornerRadius = 10.dp, | ||
onButtonClick = {} | ||
) | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
core/src/main/java/com/terning/core/designsystem/component/button/TerningBasicButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.terning.core.designsystem.component.button | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.interaction.collectIsPressedAsState | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.ripple.LocalRippleTheme | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.theme.Black | ||
import com.terning.core.designsystem.theme.Grey150 | ||
import com.terning.core.designsystem.theme.TerningMain | ||
import com.terning.core.designsystem.theme.TerningMain2 | ||
import com.terning.core.designsystem.theme.TerningPointTheme | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
import com.terning.core.designsystem.theme.White | ||
import com.terning.core.util.NoRippleTheme | ||
|
||
@Composable | ||
fun TerningBasicButton( | ||
shape: Shape, | ||
style: TextStyle, | ||
paddingVertical: Dp, | ||
@StringRes text: Int, | ||
onButtonClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
isEnabled: Boolean = true, | ||
) { | ||
val interactionSource = remember { MutableInteractionSource() } | ||
val isPressed by interactionSource.collectIsPressedAsState() | ||
val backgroundColor = if (isPressed) TerningMain2 else TerningMain | ||
|
||
CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) { | ||
Button( | ||
modifier = modifier.fillMaxWidth(), | ||
interactionSource = interactionSource, | ||
enabled = isEnabled, | ||
colors = ButtonDefaults.buttonColors( | ||
containerColor = backgroundColor, | ||
contentColor = White, | ||
disabledContainerColor = Grey150, | ||
disabledContentColor = Black | ||
), | ||
shape = shape, | ||
onClick = { onButtonClick() } | ||
) { | ||
Text( | ||
text = stringResource(id = text), | ||
style = style, | ||
modifier = modifier.padding(vertical = paddingVertical) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun TerningBasicButtonPreview() { | ||
TerningPointTheme { | ||
TerningBasicButton( | ||
text = R.string.button_preview, | ||
shape = ButtonDefaults.shape, | ||
style = TerningTheme.typography.button0, | ||
paddingVertical = 19.dp, | ||
onButtonClick = {} | ||
) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...gnsystem/topappbar/BackButtonTopAppBar.kt โ ...omponent/topappbar/BackButtonTopAppBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/designsystem/topappbar/LogoTopAppBar.kt โ ...stem/component/topappbar/LogoTopAppBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...designsystem/topappbar/MyPageTopAppBar.kt โ ...em/component/topappbar/MyPageTopAppBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package com.terning.core.extension | ||
|
||
|
||
fun String?.isJsonObject(): Boolean = this?.startsWith("{") == true && this.endsWith("}") | ||
|
||
fun String?.isJsonArray(): Boolean = this?.startsWith("[") == true && this.endsWith("]") |
15 changes: 15 additions & 0 deletions
15
core/src/main/java/com/terning/core/util/NoRippleInteractionSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.terning.core.util | ||
|
||
import androidx.compose.foundation.interaction.Interaction | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.emptyFlow | ||
|
||
object NoRippleInteractionSource : MutableInteractionSource { | ||
|
||
override val interactions: Flow<Interaction> = emptyFlow() | ||
|
||
override suspend fun emit(interaction: Interaction) {} | ||
|
||
override fun tryEmit(interaction: Interaction) = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.terning.core.util | ||
|
||
import androidx.compose.material.ripple.RippleAlpha | ||
import androidx.compose.material.ripple.RippleTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
|
||
object NoRippleTheme : RippleTheme { | ||
@Composable | ||
override fun defaultColor() = Color.Unspecified | ||
|
||
@Composable | ||
override fun rippleAlpha(): RippleAlpha = RippleAlpha( | ||
draggedAlpha = 0.0f, | ||
focusedAlpha = 0.0f, | ||
hoveredAlpha = 0.0f, | ||
pressedAlpha = 0.0f | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<!-- ContentDescription--> | ||
<!--ContentDescription--> | ||
<string name="ic_back">๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ</string> | ||
<string name="ic_logo">ํ ๋ฐ ๋ก๊ณ </string> | ||
<string name="ic_20_right">์ค๋ฅธ์ชฝ ๋ฒํผ</string> | ||
|
||
<!-- MyPage--> | ||
<!-- MyPage--> | ||
<string name="my_page_top_app_bar">ํ๋กํ ์์ </string> | ||
|
||
<!-- button--> | ||
<string name="button_preview">button</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.