Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] #59 design component #67

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
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.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -20,14 +21,15 @@ import com.record.designsystem.theme.RecordyTheme
@Composable
fun RecordyLocationBadge(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(8.dp),
location: String? = null,
isTransparent: Boolean = false,
) {
Row(
modifier = modifier
.background(
color = if (isTransparent) Color.Transparent else RecordyTheme.colors.black50,
shape = RoundedCornerShape(8.dp),
shape = shape,
),
verticalAlignment = Alignment.CenterVertically,
) {
Expand All @@ -43,7 +45,7 @@ fun RecordyLocationBadge(
contentDescription = "cursor",
tint = RecordyTheme.colors.gray01,
)
location?.let {
if (location != null) {
Text(
modifier = Modifier
.padding(end = 12.dp),
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜น์‹œ BasicButton์ด๋ž‘ RecordyButton์„ ๋ถ„๋ฆฌํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ปค์Šคํ…€์œผ๋กœ ๋ฒ„ํŠผ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.record.designsystem.component.button

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.record.ui.extension.customClickable

@Composable
fun BasicButton(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
text: String = "",
textStyle: TextStyle = TextStyle.Default,
textColor: Color = Color.Unspecified,
clickable: Boolean = true,
backgroundColor: Color = Color.Unspecified,
rippleColor: Color = Color.Unspecified,
borderColor: Color = Color.Unspecified,
borderWidth: Dp = 0.dp,
padding: PaddingValues = PaddingValues(0.dp),
onClick: () -> Unit,
icon: Int? = null,
) {
Box(
modifier = modifier
.clip(shape = shape)
.background(
color = backgroundColor,
shape = shape,
)
.border(
width = borderWidth,
color = borderColor,
shape = shape,
)
.customClickable(
runIf = clickable,
rippleColor = rippleColor,
rippleEnabled = true,
onClick = onClick,
)
.padding(padding),
contentAlignment = Alignment.Center,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
) {
if (icon != null) {
Image(modifier = Modifier.padding(end = 4.dp), painter = painterResource(id = icon), contentDescription = null)
}
Text(
text = text,
style = textStyle,
color = textColor,
maxLines = 1,
)
}
}
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.record.designsystem.component.navbar

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
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.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.record.designsystem.theme.Background
import com.record.designsystem.theme.RecordyTheme

@Composable
fun TopNavigationBar(
modifier: Modifier = Modifier,
title: String = "",
enableGradation: Boolean = false,
) {
val gradient = Brush.verticalGradient(
colors = listOf(
if (enableGradation) Background.copy(alpha = 0f) else Background,
Background,
),
)
Box(
modifier = modifier
.background(brush = gradient)
.fillMaxWidth()
.padding(
top = 45.dp,
bottom = 15.dp,
),
) {
Text(
modifier = Modifier.align(Alignment.Center),
text = title,
color = Color.White,
style = RecordyTheme.typography.title3,
)
}
}

@Preview(showBackground = true, backgroundColor = 0xFF000000)
@Composable
fun RecordyTopNavigationBarPreview() {
RecordyTheme {
RecordyTheme {
Column(
modifier = Modifier
.background(Color.White)
.padding(vertical = 10.dp, horizontal = 10.dp),
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
TopNavigationBar(title = "Title", enableGradation = true)
TopNavigationBar(title = "Title")
}
}
}
}
Empty file modified gradlew
100644 โ†’ 100755
Empty file.