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

[Feature] 시간표 중복 다이얼로그 #442

Merged
merged 5 commits into from
Oct 31, 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 @@ -126,36 +126,36 @@ internal val MediumStyle6 = DefaultTextStyle.copy(

internal val BoldStyle1 = DefaultTextStyle.copy(
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 19.2.sp
)
internal val BoldStyle2 = DefaultTextStyle.copy(
fontSize = 13.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 20.8.sp
)
internal val BoldStyle3 = DefaultTextStyle.copy(
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 22.4.sp
)
internal val BoldStyle4 = DefaultTextStyle.copy(
fontSize = 15.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 24.sp
)
internal val BoldStyle5 = DefaultTextStyle.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 25.6.sp
)
internal val BoldStyle6 = DefaultTextStyle.copy(
fontSize = 18.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 28.8.sp
)
internal val BoldStyle7 = DefaultTextStyle.copy(
fontSize = 20.sp,
fontWeight = FontWeight.Medium,
fontWeight = FontWeight.Bold,
lineHeight = 30.sp
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package `in`.koreatech.koin.feature.timetable.component

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme
import `in`.koreatech.koin.core.designsystem.theme.ThemePreviews

@Composable
fun FilledTextButton(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
textStyle: TextStyle = FilledTextButtonDefaults.textStyle,
textColor: Color = FilledTextButtonDefaults.textColor,
colors: ButtonColors = FilledTextButtonDefaults.colors,
shape: Shape = FilledTextButtonDefaults.shape,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }
) {
Button(
onClick = onClick,
modifier = modifier,
enabled = enabled,
shape = shape,
colors = colors,
elevation = null,
border = null,
contentPadding = FilledTextButtonDefaults.contentPadding,
interactionSource = interactionSource
) {
Text(text = text, style = textStyle, color = textColor)
}
}

object FilledTextButtonDefaults {
val contentPadding = PaddingValues(0.dp)

val colors
@Composable get() = ButtonColors(
containerColor = KoinTheme.colors.primary500,
contentColor = KoinTheme.colors.neutral0,
disabledContainerColor = KoinTheme.colors.neutral300,
disabledContentColor = KoinTheme.colors.neutral600
)
val shape @Composable get() = KoinTheme.shapes.extraSmall
val textColor @Composable get() = KoinTheme.colors.neutral0
val textStyle @Composable get() = KoinTheme.typography.medium15

}

@ThemePreviews
@Composable
private fun FilledTextButtonPreview() {
KoinTheme {
Surface(modifier = Modifier.padding(24.dp)) {
FilledTextButton(
modifier = Modifier
.width(96.dp)
.height(48.dp),
text = "Preview",
onClick = {}
)

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package `in`.koreatech.koin.feature.timetable.component

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.ParagraphStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.LineBreak
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.withStyle
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme
import `in`.koreatech.koin.core.designsystem.theme.ThemePreviews

@Composable
fun HighlightedText(
texts: Array<String>,
highlightIndices: List<Int>,
defaultStyle: TextStyle,
highlightStyle: TextStyle,
modifier: Modifier = Modifier
) {
val annotatedString = buildAnnotatedString {
pushStyle(
ParagraphStyle(
lineBreak = LineBreak(
strategy = LineBreak.Strategy.Balanced,
wordBreak = LineBreak.WordBreak.Phrase,
strictness = LineBreak.Strictness.Normal
)
)
)
texts.forEachIndexed { idx, text ->
withStyle(
style = highlightIndices.find { it == idx }
?.let { highlightStyle.toSpanStyle() }
?: defaultStyle.toSpanStyle()
) {
append(text)
}
}
}

Text(
text = annotatedString,
style = defaultStyle,
textAlign = TextAlign.Center,
modifier = modifier
)
}

@ThemePreviews
@Composable
private fun HighlightedTextPreview() {
KoinTheme {
HighlightedText(
texts = arrayOf("안녕하세요 ", "강조", "입니다"),
highlightIndices = listOf(1),
defaultStyle = KoinTheme.typography.regular15,
highlightStyle = KoinTheme.typography.bold15,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package `in`.koreatech.koin.feature.timetable.view

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
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.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import `in`.koreatech.koin.core.designsystem.theme.FontScalePreviews
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme
import `in`.koreatech.koin.feature.timetable.R
import `in`.koreatech.koin.feature.timetable.component.FilledTextButton
import `in`.koreatech.koin.feature.timetable.component.HighlightedText

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LectureDuplicationDialog(
onConfirm: () -> Unit,
onDismiss: () -> Unit,
modifier: Modifier = Modifier
) {
BasicAlertDialog(
onDismissRequest = { onDismiss() },
modifier = modifier,
) {
Surface(
modifier = Modifier
.wrapContentWidth()
.wrapContentHeight(),
shape = KoinTheme.shapes.extraSmall
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = 32.dp,
vertical = 24.dp
),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = stringResource(id = R.string.lecture_duplication_title),
color = KoinTheme.colors.neutral800,
textAlign = TextAlign.Center,
style = KoinTheme.typography.bold16,
)
Spacer(modifier = Modifier.height(8.dp))
HighlightedText(
texts = stringArrayResource(id = R.array.lecture_duplication_description),
highlightIndices = listOf(1),
defaultStyle = KoinTheme.typography.regular14.copy(
color = KoinTheme.colors.neutral600,
),
highlightStyle = KoinTheme.typography.regular14.copy(
color = KoinTheme.colors.warning600,
)
)
Spacer(modifier = Modifier.height(24.dp))
Row(
modifier = Modifier.wrapContentHeight(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
OutlinedButton(
modifier = Modifier
.height(48.dp)
.weight(1.0F),
colors = ButtonColors(
containerColor = KoinTheme.colors.neutral0,
contentColor = KoinTheme.colors.neutral500,
disabledContainerColor = KoinTheme.colors.neutral400,
disabledContentColor = KoinTheme.colors.neutral500
),
shape = MaterialTheme.shapes.extraSmall,
contentPadding = PaddingValues(0.dp),
border = BorderStroke(1.dp, KoinTheme.colors.neutral500),
onClick = { onDismiss() }
) {
Text(text = stringResource(id = R.string.lecture_duplication_cancellation), style = KoinTheme.typography.medium15, color = KoinTheme.colors.neutral600)
}
FilledTextButton(
modifier = Modifier
.height(48.dp)
.weight(1.0F),
text = stringResource(id = R.string.lecture_duplication_confirmation),
onClick = { onConfirm() }
)
}
}
}
}

}

@FontScalePreviews
@Composable
private fun LectureDuplicationDialogPreview(modifier: Modifier = Modifier) {
KoinTheme {
var isShowing by remember { mutableStateOf(true) }

if (isShowing) {
LectureDuplicationDialog(
onConfirm = {},
onDismiss = { isShowing = false }
)
}
}
}
14 changes: 14 additions & 0 deletions feature/timetable/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="lecture_duplication_title">시간표가 중복돼요.</string>
<string name="lecture_duplication_cancellation">취소</string>
<string name="lecture_duplication_confirmation">대체하기</string>

<string-array name="lecture_duplication_description">
<item>추가하시려는 시간에 이미 다른 강의가 있어요.</item>
<item>" 새로운 강의로 대체"</item>
<item>하시겠어요?</item>
</string-array>


</resources>