Skip to content

Commit

Permalink
[refactor] #59 Custom Btn
Browse files Browse the repository at this point in the history
  • Loading branch information
lsakee committed Jul 11, 2024
1 parent cc614bb commit 166babb
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun RecordyLocationBadge(
contentDescription = "cursor",
tint = RecordyTheme.colors.gray01,
)
if (location != null)
if (location != null) {
Text(
modifier = Modifier
.padding(end = 12.dp),
Expand All @@ -54,6 +54,7 @@ fun RecordyLocationBadge(
color = RecordyTheme.colors.gray01,
textAlign = TextAlign.Center,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ fun BasicButton(
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,80 @@
package com.record.designsystem.component.button

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Color.Companion.White
import androidx.compose.ui.graphics.Shape
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.record.designsystem.theme.Black
import com.record.designsystem.theme.Main
import com.record.designsystem.theme.RecordyTheme
import timber.log.Timber

@Composable
fun RecordyButton(
modifier: Modifier = Modifier,
text: String,
containerColor: Color = RecordyTheme.colors.main,
contentColor: Color = RecordyTheme.colors.gray09,
textStyle: TextStyle = RecordyTheme.typography.button1,
cornerShape: Dp = 12.dp,
enabled: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(6.dp),
enabled: Boolean = true,
clickable: Boolean = true,
onClick: () -> Unit = {},
backgroundColor: Color = Main,
textColor: Color = RecordyTheme.colors.gray09,
borderWidth: Dp = 0.dp,
borderColor: Color = Color.Transparent,
rippleColor: Color = White,
) {
Button(
onClick = onClick,
enabled = enabled,
colors = ButtonDefaults.buttonColors(
containerColor = containerColor,
contentColor = contentColor,
disabledContainerColor = RecordyTheme.colors.gray08,
disabledContentColor = RecordyTheme.colors.gray04,
),
shape = RoundedCornerShape(cornerShape),
BasicButton(
modifier = modifier
.fillMaxWidth(),
) {
Text(
text = text,
style = textStyle,
)
text = text,
shape = shape,
onClick = onClick,
backgroundColor = if (enabled) backgroundColor else RecordyTheme.colors.gray08,
rippleColor = rippleColor,
textColor = if (enabled) textColor else RecordyTheme.colors.gray04,
clickable = clickable,
padding = PaddingValues(15.dp),
textStyle = textStyle,
borderWidth = borderWidth,
borderColor = borderColor,
)
}

@Preview(showBackground = true, backgroundColor = 0xFFFFFF)
@Composable
fun RecordyButtonPreview() {
RecordyTheme {
RecordyTheme {
Column(
modifier = Modifier
.background(Black)
.padding(vertical = 10.dp, horizontal = 10.dp),
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
RecordyButton(
text = "키워드",
onClick = { Timber.d("basic key word") },
)

RecordyButton(
text = "키워드",
enabled = false,
onClick = { Timber.d("basic key word") },
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -25,6 +26,7 @@ import com.record.designsystem.theme.RecordyTheme
@Composable
fun RecordyDialog(
graphicAsset: Int? = null,
shape: Shape = RoundedCornerShape(8.dp),
title: String? = null,
subTitle: String? = null,
positiveButtonLabel: String = "",
Expand All @@ -36,7 +38,7 @@ fun RecordyDialog(
Column(
modifier = Modifier
.fillMaxWidth()
.background(color = RecordyTheme.colors.gray08, shape = RoundedCornerShape(8.dp))
.background(color = RecordyTheme.colors.gray08, shape = shape)
.padding(horizontal = 16.dp)
.padding(bottom = 24.dp, top = 28.dp),
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -57,35 +59,32 @@ fun RecordyDialog(
color = RecordyTheme.colors.gray01,
textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(4.dp))
}
subTitle?.let {
if (subTitle != null) {
Text(
modifier = Modifier.padding(top = 4.dp, bottom = 20.dp),
text = subTitle,
style = RecordyTheme.typography.caption1,
color = RecordyTheme.colors.gray01,
textAlign = TextAlign.Center,
)
}
Spacer(modifier = Modifier.height(20.dp))
Row(
modifier = Modifier.fillMaxWidth(),
) {
RecordyButton(
text = negativeButtonLabel,
cornerShape = 8.dp,
enabled = true,
shape = shape,
enabled = false,
textStyle = RecordyTheme.typography.button2,
containerColor = RecordyTheme.colors.gray05,
contentColor = RecordyTheme.colors.gray01,
onClick = { onDismissRequest() },
modifier = Modifier
.weight(1f)
.padding(horizontal = 4.dp),
)
RecordyButton(
text = positiveButtonLabel,
cornerShape = 8.dp,
shape = shape,
enabled = true,
textStyle = RecordyTheme.typography.button2,
onClick = { onPositiveButtonClick() },
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.

0 comments on commit 166babb

Please sign in to comment.