Skip to content

Commit

Permalink
chore: branch merge
Browse files Browse the repository at this point in the history
  • Loading branch information
syb8200 committed Jan 1, 2024
2 parents 43793ca + 01d32f4 commit ef7b85a
Show file tree
Hide file tree
Showing 14 changed files with 863 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.susu.core.designsystem.component.button

import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -10,7 +9,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -19,7 +17,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
Expand All @@ -31,18 +28,16 @@ import com.susu.core.ui.extension.susuClickable
fun BasicButton(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
text: String = "",
text: String? = null,
textStyle: TextStyle = TextStyle.Default,
contentColor: Color = Color.Unspecified,
rippleColor: Color = Color.Unspecified,
borderColor: Color = Color.Unspecified,
borderWidth: Dp = 0.dp,
backgroundColor: Color = Color.Unspecified,
padding: PaddingValues = PaddingValues(0.dp),
@DrawableRes leftIcon: Int? = null,
leftIconContentDescription: String? = null,
@DrawableRes rightIcon: Int? = null,
rightIconContentDescription: String? = null,
leftIcon: (@Composable () -> Unit)? = null,
rightIcon: (@Composable () -> Unit)? = null,
iconSpacing: Dp = 0.dp,
isActive: Boolean = true,
onClick: () -> Unit = {},
Expand All @@ -66,33 +61,22 @@ fun BasicButton(
) {
Row(
modifier
.height(textStyle.lineHeight.value.dp)
.wrapContentWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(iconSpacing),
) {
leftIcon?.let {
Icon(
modifier = Modifier.height(textStyle.lineHeight.value.dp),
painter = painterResource(id = it),
contentDescription = leftIconContentDescription,
tint = contentColor,
)
}
leftIcon?.invoke()

Text(
text = text,
style = textStyle,
color = contentColor,
)

rightIcon?.let {
Icon(
modifier = Modifier.height(textStyle.lineHeight.value.dp),
painter = painterResource(id = it),
contentDescription = rightIconContentDescription,
tint = contentColor,
text?.let {
Text(
text = it,
style = textStyle,
color = contentColor,
)
}

rightIcon?.invoke()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.susu.core.designsystem.component.button

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
Expand Down Expand Up @@ -47,13 +49,11 @@ enum class FilledButtonColor(
fun SusuFilledButton(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(4.dp),
text: String = "",
text: String? = null,
color: FilledButtonColor,
style: @Composable () -> ButtonStyle,
@DrawableRes leftIcon: Int? = null,
leftIconContentDescription: String? = null,
@DrawableRes rightIcon: Int? = null,
rightIconContentDescription: String? = null,
leftIcon: (@Composable () -> Unit)? = null,
rightIcon: (@Composable () -> Unit)? = null,
isActive: Boolean = true,
onClick: () -> Unit = {},
) {
Expand All @@ -68,9 +68,7 @@ fun SusuFilledButton(
rippleColor = rippleColor,
backgroundColor = if (isActive) activeBackgroundColor else inactiveBackgroundColor,
leftIcon = leftIcon,
leftIconContentDescription = leftIconContentDescription,
rightIcon = rightIcon,
rightIconContentDescription = rightIconContentDescription,
padding = paddingValues,
iconSpacing = iconSpacing,
isActive = isActive,
Expand Down Expand Up @@ -181,8 +179,22 @@ private fun SusuFilledButtonPreview(
style = large,
color = color,
text = "Button",
rightIcon = R.drawable.ic_arrow_left,
leftIcon = R.drawable.ic_arrow_left,
leftIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = "",
tint = color.activeContentColor,
)
},
rightIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = "",
tint = color.activeContentColor,
)
},
)

SusuFilledButton(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.susu.core.designsystem.component.button

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
Expand Down Expand Up @@ -47,13 +49,11 @@ enum class GhostButtonColor(
fun SusuGhostButton(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(4.dp),
text: String = "",
text: String? = null,
color: GhostButtonColor,
style: @Composable () -> ButtonStyle,
@DrawableRes leftIcon: Int? = null,
leftIconContentDescription: String? = null,
@DrawableRes rightIcon: Int? = null,
rightIconContentDescription: String? = null,
leftIcon: (@Composable () -> Unit)? = null,
rightIcon: (@Composable () -> Unit)? = null,
isActive: Boolean = true,
onClick: () -> Unit = {},
) {
Expand All @@ -68,9 +68,7 @@ fun SusuGhostButton(
rippleColor = rippleColor,
backgroundColor = if (isActive) activeBackgroundColor else inactiveBackgroundColor,
leftIcon = leftIcon,
leftIconContentDescription = leftIconContentDescription,
rightIcon = rightIcon,
rightIconContentDescription = rightIconContentDescription,
padding = paddingValues,
iconSpacing = iconSpacing,
isActive = isActive,
Expand Down Expand Up @@ -181,8 +179,22 @@ private fun SusuGhostButtonPreview(
style = large,
color = color,
text = "Button",
rightIcon = R.drawable.ic_arrow_left,
leftIcon = R.drawable.ic_arrow_left,
leftIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = "",
tint = color.activeContentColor,
)
},
rightIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = "",
tint = color.activeContentColor,
)
},
)

SusuGhostButton(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.susu.core.designsystem.component.button

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
Expand Down Expand Up @@ -54,13 +56,11 @@ enum class LinedButtonColor(
fun SusuLinedButton(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(4.dp),
text: String = "",
text: String? = null,
color: LinedButtonColor,
style: @Composable () -> ButtonStyle,
@DrawableRes leftIcon: Int? = null,
leftIconContentDescription: String? = null,
@DrawableRes rightIcon: Int? = null,
rightIconContentDescription: String? = null,
leftIcon: (@Composable () -> Unit)? = null,
rightIcon: (@Composable () -> Unit)? = null,
isActive: Boolean = true,
onClick: () -> Unit = {},
) {
Expand All @@ -77,9 +77,7 @@ fun SusuLinedButton(
rippleColor = rippleColor,
backgroundColor = if (isActive) activeBackgroundColor else inactiveBackgroundColor,
leftIcon = leftIcon,
leftIconContentDescription = leftIconContentDescription,
rightIcon = rightIcon,
rightIconContentDescription = rightIconContentDescription,
padding = paddingValues,
iconSpacing = iconSpacing,
isActive = isActive,
Expand Down Expand Up @@ -190,8 +188,22 @@ private fun SusuLinedButtonPreview(
style = large,
color = color,
text = "Button",
rightIcon = R.drawable.ic_arrow_left,
leftIcon = R.drawable.ic_arrow_left,
leftIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = "",
tint = color.activeContentColor,
)
},
rightIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = "",
tint = color.activeContentColor,
)
},
)

SusuLinedButton(
Expand Down
Loading

0 comments on commit ef7b85a

Please sign in to comment.