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

[UI/#53] TerningBasicDialog #61

Merged
merged 13 commits into from
Jul 12, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun SortingButton(
)
)
Image(
painter = painterResource(id = R.drawable.ic_down),
painter = painterResource(id = R.drawable.ic_down_18),
contentDescription = stringResource(id = R.string.sort_button_description),
modifier = modifier
.padding(vertical = 5.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
package com.terning.core.designsystem.component.dialog

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.component.button.RoundButton
import com.terning.core.designsystem.component.item.ColorPalette
import com.terning.core.designsystem.theme.CalBlue2
import com.terning.core.designsystem.theme.CalGreen2
import com.terning.core.designsystem.theme.CalRed
import com.terning.core.designsystem.theme.Grey200
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey350
import com.terning.core.designsystem.theme.Grey500
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White
import com.terning.core.extension.noRippleClickable


@Composable
fun ScrapDialogContent(
onDismissRequest: () -> Unit,
isScrapped: Boolean,
internInfoList: List<Pair<String, String>>,
) {
var isColorChange by remember { mutableStateOf(false) }
var selectedColor by remember { mutableStateOf(CalRed) }

Box(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(30.dp)
.background(
color = White,
shape = RoundedCornerShape(20.dp)
Comment on lines +62 to +64
Copy link
Member

Choose a reason for hiding this comment

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

요거 자동으로 White 설정은 안 되는 건가용,,?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넹 머터리얼 기본 보라색,,.?희미한 그 색이 되더라구욧..

),
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
) {
IconButton(
onClick = { onDismissRequest() },
modifier = Modifier
.padding(6.dp)
) {
Icon(
painter = painterResource(id = R.drawable.ic_dialog_x_32),
contentDescription = null,
tint = Grey300,
modifier = Modifier
.noRippleClickable { onDismissRequest() }
)
}
}
Box(
modifier = Modifier
.fillMaxWidth()
.padding(top = 32.dp),
contentAlignment = Alignment.TopCenter
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 11.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Row(
modifier = Modifier
.width(60.dp)
.height(60.dp)
Copy link
Member

Choose a reason for hiding this comment

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

aspectRatio 사용해도 좋을 것 같아요!

.border(
width = 1.dp,
color = TerningMain,
shape = RoundedCornerShape(size = 15.dp)
)
) {
Image(
painter = painterResource(
id = R.drawable.ic_character1
),
modifier = Modifier
.fillMaxWidth()
.background(
Grey200,
shape = RoundedCornerShape(size = 15.dp)
),
contentDescription = null,
contentScale = ContentScale.Fit,
alignment = Alignment.Center
)
}
Text(
text = "[한양대학교 컬렉티브임팩트센터] /코이카 영프로페셔널(YP) 모집합니다",
textAlign = TextAlign.Center,
style = TerningTheme.typography.title4,
color = Grey500,
modifier = Modifier.padding(top = 20.dp)
)
Text(
text = stringResource(id = R.string.dialog_content_scrap_sub_title),
style = TerningTheme.typography.body5,
color = Grey350,
modifier = Modifier.padding(
top = 4.dp,
bottom = 13.dp
)
)
Column(
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.Top,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 13.dp)
) {
Row(
modifier = Modifier
.background(
color = if (selectedColor != CalRed) CalBlue2 else CalGreen2,
shape = RoundedCornerShape(14.dp)
)
.noRippleClickable {
isColorChange = !isColorChange
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
Icon(
painter = painterResource(
id = if (isColorChange) R.drawable.ic_up_22
else R.drawable.ic_down_22
),
contentDescription = stringResource(
id = R.string.dialog_content_color_button
),
tint = White,
modifier = Modifier.padding(
start = 7.dp,
top = 2.dp,
bottom = 2.dp
)
)
Text(
text = stringResource(id = R.string.dialog_content_color_button),
style = TerningTheme.typography.body5,
color = White,
modifier = Modifier.padding(end = 13.dp)
)
}
HorizontalDivider(
thickness = 1.dp,
color = Grey200,
modifier = Modifier.padding(
top = 11.dp,
bottom = 8.dp
)
)
if (isColorChange) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(
top = 12.dp,
bottom = 23.dp,
),
contentAlignment = Alignment.Center
) {
ColorPalette(
initialColor = CalRed,
onColorSelected = { selectedColor = it })
}
} else {
Text(
text = stringResource(id = R.string.intern_item_d_day),
style = TerningTheme.typography.body5,
color = TerningMain,
modifier = Modifier.padding(bottom = 9.dp)
)
Column(
modifier = Modifier.padding(bottom = 29.dp),
verticalArrangement = Arrangement.spacedBy(
5.dp,
Alignment.CenterVertically
Copy link
Member

Choose a reason for hiding this comment

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

와우 Arrangement 안에 Alignment 넣을 수 있는거 처음 알았어요..!!

),
horizontalAlignment = Alignment.Start,
) {
internInfoList.forEach { (title, value) ->
InternInfoRow(title, value)
}
}
}
}
RoundButton(
style = TerningTheme.typography.button3,
paddingVertical = 12.dp,
cornerRadius = 8.dp,
text = if (isScrapped) {
if (isColorChange)
R.string.dialog_content_color_button
else R.string.dialog_scrap_button
} else {
R.string.dialog_scrap_button
},
onButtonClick = { /*TODO*/ },
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 하면 ripple이 생겨서 noRippleClickable 사용하는게 좋을 것 같아요!

Copy link
Member

Choose a reason for hiding this comment

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

흠,,근데 제가 noRippleTheme 작성했었는데 적용이 안 되나요,,?
onButtonClick에 아무 로직이 없어서 그런 것 같기도 한데 한번 해보고 ripple 없는 지 확인해주세요!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

요거는 유빈이가 만들어준거라서 디폴트로 적용되어 이씁니다!

modifier = Modifier.padding(bottom = 8.dp)
)
}
}
}
}

// TODO 삭제
@Composable
fun InternInfoRow(title: String, value: String) {
Row(
horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.Start),
verticalAlignment = Alignment.Top,
) {
Text(
text = title,
style = TerningTheme.typography.body2,
color = Grey350,
)
Text(
text = value,
style = TerningTheme.typography.body3,
color = Grey500,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.terning.core.designsystem.component.dialog

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties

@Composable
fun TerningBasicDialog(
onDismissRequest: () -> Unit,
properties: DialogProperties = DialogProperties(
usePlatformDefaultWidth = false,
decorFitsSystemWindows = true,
dismissOnBackPress = true,
dismissOnClickOutside = true,
),
content: @Composable () -> Unit,
) {
Dialog(
onDismissRequest = { onDismissRequest() },
properties = properties,
) {
content()
}
}

@Preview(showBackground = true, showSystemUi = true)
@Composable
fun TerningBasicDialogPreview() {
TerningBasicDialog(
onDismissRequest = {},
content = {
ScrapDialogContent(
onDismissRequest = {},
isScrapped = false,
internInfoList = listOf()
)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -27,8 +32,8 @@ import com.terning.core.extension.noRippleClickable

@Composable
fun ColorPalette(
modifier: Modifier = Modifier,
onColorSelected:(Color) -> Unit = {}
initialColor: Color,
onColorSelected: (Color) -> Unit = {},
) {
val colorList = listOf(
CalRed,
Expand All @@ -43,22 +48,24 @@ fun ColorPalette(
CalPink
)

var selectedColor by remember { mutableStateOf(initialColor) }

RadioButtonGroups(
modifier = modifier.size(251.dp, 84.dp),
options = colorList,
gridCellCount = 5,
onOptionSelected = { color ->
selectedColor = color
onColorSelected(color)
},
buttonComposable = {
color, isSelected, onOptionSelected ->
buttonComposable = { color, isSelected, onOptionSelected ->
ColorButton(
color = color,
isSelected = isSelected,
onColorSelected = onOptionSelected)
isSelected = selectedColor == color,
onColorSelected = onOptionSelected
)
},
verticalArrangementSpace = 6.dp,
horizontalArrangementSpace = 14.dp,
horizontalArrangementSpace = 0.dp,
)
}

Expand All @@ -67,13 +74,16 @@ internal fun ColorButton(
modifier: Modifier = Modifier,
color: Color,
isSelected: Boolean,
onColorSelected: (Color) -> Unit
onColorSelected: (Color) -> Unit,
) {
Box(modifier = modifier.size(39.dp)) {
Box(modifier = modifier.wrapContentSize()) {
Box(
Comment on lines 78 to 80
Copy link
Member

Choose a reason for hiding this comment

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

굿!!!!!!!!!!!!!

Copy link
Member

Choose a reason for hiding this comment

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

굿2!!!!!!

modifier = Modifier
.size(39.dp)
.background(shape = CircleShape, color = color)
.background(
shape = CircleShape,
color = color
)
.noRippleClickable {
onColorSelected(color)
},
Expand All @@ -89,10 +99,8 @@ internal fun ColorButton(
}
}


@Preview(showBackground = true)
@Composable
fun ColorPalettePreview() {
ColorPalette()
ColorPalette(initialColor = CalRed)
}

Loading
Loading