-
Notifications
You must be signed in to change notification settings - Fork 1
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/YAF-85] 알람 메인 화면 배경을 구현합니다. #54
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
167a00e
[UI/#15] OrbitBottomSheetState 설정
DongChyeon 2e86a4e
[UI/#15] 기상 알림이 없을 때 화면 UI 구현
DongChyeon 3abb2de
[UI/#15] 홈 상단 바 메일함 버튼 추가
DongChyeon 3a27066
[UI/#15] 알람이 존재하지 않을 때 그래픽, 문구 수정
DongChyeon f95f6d6
[UI/#15] OrbitDialog 컴포넌트 구현
DongChyeon 0ca0a3a
[UI/#15] 풀 스크린 화면 (enableEdgeToEdge) 적용
DongChyeon 9ba9f74
[UI/#15] 이전에 받은 운세 점수에 따른 배경 및 캐릭터 적용
DongChyeon bd09595
[UI/#15] 설정된 알람이 없을 때 화면 컴포넌트 간 간격 수정
DongChyeon f9d0ac9
[UI/#15] 말풍선과 오르비 캐릭터 간 간격 수정
DongChyeon d699f0f
[REMOVE/#15] OrbitBottomSheetState 제거
DongChyeon 3ccd920
[CHORE/#15] 말풍선 에셋을 png 로 교체
DongChyeon ed6c94d
[REMOVE/#15] accompanist-systemui dependency 제거
DongChyeon f590e28
[UI/#15] 언덕 Radius 및 위치 수정
DongChyeon 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
210 changes: 210 additions & 0 deletions
210
core/ui/src/main/java/com/yapp/ui/component/dialog/OrbitDialog.kt
This file contains 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,210 @@ | ||
package com.yapp.ui.component.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.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.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 | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Dialog | ||
import com.yapp.designsystem.theme.OrbitTheme | ||
import com.yapp.ui.component.button.OrbitButton | ||
|
||
@Composable | ||
fun OrbitDialog( | ||
title: String, | ||
message: String, | ||
confirmText: String, | ||
cancelText: String? = null, | ||
onConfirm: () -> Unit, | ||
onCancel: (() -> Unit)? = null, | ||
confirmButtonContainerColor: Color = OrbitTheme.colors.main, | ||
confirmButtonContentColor: Color = OrbitTheme.colors.gray_900, | ||
cancelButtonContainerColor: Color = OrbitTheme.colors.gray_600, | ||
cancelButtonContentColor: Color = OrbitTheme.colors.white, | ||
cornerRadius: Dp = 20.dp, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Dialog( | ||
onDismissRequest = { | ||
if (cancelText == null) { | ||
onConfirm() | ||
} else { | ||
onCancel?.invoke() | ||
} | ||
}, | ||
) { | ||
Column( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.background( | ||
color = OrbitTheme.colors.gray_700, | ||
shape = RoundedCornerShape(cornerRadius), | ||
) | ||
.padding(20.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
Text( | ||
text = title, | ||
style = OrbitTheme.typography.heading1SemiBold, | ||
color = OrbitTheme.colors.gray_50, | ||
textAlign = TextAlign.Center, | ||
) | ||
Spacer(modifier = Modifier.height(20.dp)) | ||
Text( | ||
text = message, | ||
style = OrbitTheme.typography.body1Regular, | ||
color = OrbitTheme.colors.gray_300, | ||
textAlign = TextAlign.Center, | ||
) | ||
Spacer(modifier = Modifier.height(20.dp)) | ||
if (cancelText != null && onCancel != null) { | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
) { | ||
DialogButton( | ||
text = cancelText, | ||
containerColor = cancelButtonContainerColor, | ||
contentColor = cancelButtonContentColor, | ||
onClick = onCancel, | ||
modifier = Modifier | ||
.weight(1f) | ||
.padding(end = 8.dp), | ||
) | ||
DialogButton( | ||
text = confirmText, | ||
containerColor = confirmButtonContainerColor, | ||
contentColor = confirmButtonContentColor, | ||
onClick = onConfirm, | ||
modifier = Modifier | ||
.weight(1f) | ||
.padding(start = 8.dp), | ||
) | ||
} | ||
} else { | ||
DialogButton( | ||
text = confirmText, | ||
containerColor = confirmButtonContainerColor, | ||
contentColor = confirmButtonContentColor, | ||
onClick = onConfirm, | ||
modifier = Modifier.fillMaxWidth(), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun DialogButton( | ||
text: String, | ||
containerColor: Color, | ||
contentColor: Color, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Button( | ||
onClick = onClick, | ||
modifier = modifier.height(48.dp), | ||
colors = ButtonDefaults.buttonColors( | ||
containerColor = containerColor, | ||
contentColor = contentColor, | ||
), | ||
shape = RoundedCornerShape(16.dp), | ||
) { | ||
Text( | ||
text = text, | ||
style = OrbitTheme.typography.body1SemiBold, | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewCustomDialogSingleButton() { | ||
var isDialogOpen by remember { mutableStateOf(true) } | ||
|
||
OrbitTheme { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(OrbitTheme.colors.gray_900), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
OrbitButton( | ||
label = "알림창 열기", | ||
enabled = true, | ||
onClick = { | ||
isDialogOpen = true | ||
}, | ||
) | ||
|
||
if (isDialogOpen) { | ||
OrbitDialog( | ||
title = "받은 운세가 없어요", | ||
message = "알람이 울린 후 미션을 수행하면\n오늘의 운세를 받을 수 있어요.", | ||
confirmText = "닫기", | ||
onConfirm = { | ||
isDialogOpen = false | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewCustomDialogDoubleButton() { | ||
var isDialogOpen by remember { mutableStateOf(true) } | ||
|
||
OrbitTheme { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(OrbitTheme.colors.gray_900), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
OrbitButton( | ||
label = "알림창 열기", | ||
enabled = true, | ||
onClick = { | ||
isDialogOpen = true | ||
}, | ||
) | ||
|
||
if (isDialogOpen) { | ||
OrbitDialog( | ||
title = "나가면 운세를 받을 수 없어요", | ||
message = "미션을 수행하지 않고 나가시겠어요?", | ||
confirmText = "나가기", | ||
cancelText = "취소", | ||
onConfirm = {}, | ||
onCancel = { | ||
isDialogOpen = false | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3
취소랑 확인을
onDismissRequest
하나로 취합하고 있는 구조 인가요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인만 있는 Dialog의 경우 다른 영역을 눌러서
onDismissRequest
를 호출할 때 onCofirm()을 호출하는 구조며확인/취소가 있는 Dialog라면 다른 영역을 눌렀을 때 onCancel()을 호출하는 구조입니다.
부자연스러운 흐름인 것 같다면 말씀해주세요!