-
Notifications
You must be signed in to change notification settings - Fork 1
PrezelDialog 컴포넌트 추가 및 modal 컴포넌트 구조 정리 #94
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
297e285
refactor: Snackbar 관련 컴포넌트 패키지 위치 이동 (`modal` 서브 패키지 추가)
moondev03 ed473b6
refactor: PrezelTheme의 기본 콘텐츠 색상 변경
moondev03 d7b9736
feat: PrezelDialog 구현
moondev03 6e54529
refactor: PrezelDialog ActionType 열거형 명명 규칙 수정
moondev03 11d6868
refactor: PrezelDialog 내 액션 버튼에 접근성 Role 추가
moondev03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...em/src/main/java/com/team/prezel/core/designsystem/component/modal/dialog/PrezelDialog.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) {} | ||
| } | ||
| } | ||
| } | ||
| } | ||
77 changes: 77 additions & 0 deletions
77
...c/main/java/com/team/prezel/core/designsystem/component/modal/dialog/PrezelDialogScope.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| ) | ||
| } | ||
moondev03 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @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) {} | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
2 changes: 1 addition & 1 deletion
2
...stem/component/snackbar/PrezelSnackbar.kt → ...omponent/modal/snackbar/PrezelSnackbar.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...system/component/snackbar/SnackbarHost.kt → .../component/modal/snackbar/SnackbarHost.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.