Skip to content
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,8 +10,8 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalResources
import com.team.prezel.R
import com.team.prezel.core.designsystem.component.snackbar.dismissById
import com.team.prezel.core.designsystem.component.snackbar.showPrezelSnackbar
import com.team.prezel.core.designsystem.component.modal.snackbar.dismissById
import com.team.prezel.core.designsystem.component.modal.snackbar.showPrezelSnackbar
import com.team.prezel.core.navigation.NavigationState
import com.team.prezel.core.ui.LocalSnackbarHostState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.team.prezel.core.designsystem.component.snackbar.PrezelSnackbarHost
import com.team.prezel.core.designsystem.component.modal.snackbar.PrezelSnackbarHost
import com.team.prezel.core.designsystem.icon.PrezelIcons
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.theme.PrezelTheme
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.team.prezel.core.designsystem.component.modal.dialog

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.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.theme.PrezelTheme

@Composable
fun PrezelDialog(
title: String,
description: String,
onDismiss: () -> Unit,
modifier: Modifier = Modifier,
content: @Composable PrezelDialogScope.() -> Unit,
) {
val scope = remember { PrezelDialogScope() }

Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(
dismissOnClickOutside = false,
usePlatformDefaultWidth = false,
),
) {
Column(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = PrezelTheme.spacing.V20)
.clip(shape = PrezelTheme.shapes.V12)
.background(color = PrezelTheme.colors.bgRegular)
.padding(horizontal = PrezelTheme.spacing.V24),
) {
DialogContent(
title = title,
description = description,
)

ActionSection { scope.content() }
}
}
}

@Composable
private fun DialogContent(
title: String,
description: String,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.padding(vertical = PrezelTheme.spacing.V24),
) {
Text(text = title, style = PrezelTheme.typography.title2Bold, color = PrezelTheme.colors.textLarge)
Spacer(modifier = Modifier.height(PrezelTheme.spacing.V12))
Text(text = description, style = PrezelTheme.typography.body3Medium, color = PrezelTheme.colors.textRegular)
}
}

@Composable
private fun ActionSection(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
Box(
modifier = modifier
.fillMaxWidth()
.padding(bottom = PrezelTheme.spacing.V20),
) {
Row(
modifier = Modifier.align(Alignment.CenterEnd),
horizontalArrangement = Arrangement.spacedBy(PrezelTheme.spacing.V32),
) {
content()
}
}
}

@BasicPreview
@Composable
private fun PrezelDialogPreview() {
PrezelTheme {
Box(modifier = Modifier.fillMaxSize()) {
PrezelDialog(
title = "Title",
description = "Description",
onDismiss = {},
) {
Action(label = "Action2") {}
Action(label = "Action1", type = PrezelDialogScope.ActionType.GOOD) {}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.team.prezel.core.designsystem.component.modal.dialog

import androidx.compose.foundation.layout.LayoutScopeMarker
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import com.team.prezel.core.designsystem.component.base.PrezelTouchArea
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.preview.PreviewSection
import com.team.prezel.core.designsystem.preview.PreviewValueRow
import com.team.prezel.core.designsystem.theme.PrezelTheme

@LayoutScopeMarker
class PrezelDialogScope {
enum class ActionType {
DEFAULT,
GOOD,
BAD,
}

@Composable
fun Action(
label: String,
type: ActionType = ActionType.DEFAULT,
onClick: () -> Unit,
) {
val labelColor = labelColor(type = type)

PrezelTouchArea(
onClick = onClick,
shape = PrezelTheme.shapes.V4,
modifier = Modifier.semantics { role = Role.Button },
) {
Text(
text = label,
style = PrezelTheme.typography.body2Medium,
color = labelColor,
modifier = Modifier.padding(vertical = PrezelTheme.spacing.V8),
)
}
}

@Composable
private fun labelColor(type: ActionType) =
when (type) {
ActionType.DEFAULT -> PrezelTheme.colors.textRegular
ActionType.GOOD -> PrezelTheme.colors.feedbackGoodRegular
ActionType.BAD -> PrezelTheme.colors.feedbackBadRegular
}
}

@BasicPreview
@Composable
private fun PrezelDialogActionPreview() {
PrezelTheme {
PreviewSection(
title = "Dialog Action",
description = "Dialog에 사용되는 리소스입니다.",
) {
with(PrezelDialogScope()) {
PreviewValueRow(name = "Default Action") {
Action(label = "Action", type = PrezelDialogScope.ActionType.DEFAULT) {}
}
PreviewValueRow(name = "Good Action") {
Action(label = "Action", type = PrezelDialogScope.ActionType.GOOD) {}
}
PreviewValueRow(name = "Bad Action") {
Action(label = "Action", type = PrezelDialogScope.ActionType.BAD) {}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team.prezel.core.designsystem.component.snackbar
package com.team.prezel.core.designsystem.component.modal.snackbar

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.Row
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team.prezel.core.designsystem.component.snackbar
package com.team.prezel.core.designsystem.component.modal.snackbar

import androidx.annotation.DrawableRes
import androidx.compose.material3.SnackbarDuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fun PrezelTheme(
LocalPrezelSpacing provides PrezelSpacing,
LocalPrezelStroke provides PrezelStroke,
LocalTextStyle provides typographyScheme.body3Regular,
LocalContentColor provides colorScheme.textLarge,
LocalContentColor provides colorScheme.textRegular,
content = content,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.team.prezel.core.designsystem.component.actions.button.config.ButtonH
import com.team.prezel.core.designsystem.component.actions.button.config.ButtonSize
import com.team.prezel.core.designsystem.component.actions.button.config.ButtonType
import com.team.prezel.core.designsystem.component.actions.button.config.PrezelButtonDefaults
import com.team.prezel.core.designsystem.component.snackbar.showPrezelSnackbar
import com.team.prezel.core.designsystem.component.modal.snackbar.showPrezelSnackbar
import com.team.prezel.core.designsystem.icon.PrezelIcons
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.theme.PrezelTheme
Expand Down