-
Notifications
You must be signed in to change notification settings - Fork 0
[feat/#12] SnackBar 컴포넌트 구현 #13
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
Changes from all commits
0bec3e4
30e2256
31d9e61
05b8c24
5eb93f9
2973f59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.kiero.core.designsystem.component | ||
|
|
||
| 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.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.kiero.core.designsystem.theme.KieroTheme | ||
|
|
||
| @Composable | ||
| fun KieroSnackbar( | ||
| message: String, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| Box( | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .clip(RoundedCornerShape(12.dp)) | ||
| .background(KieroTheme.colors.gray900) | ||
| .padding(16.dp), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| Text( | ||
| text = message, | ||
| style = KieroTheme.typography.regular.body4, | ||
| color = KieroTheme.colors.schedule1, | ||
| textAlign = TextAlign.Center | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun KieroSnackbarPreview() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| KieroTheme { | ||
| Column( | ||
| modifier = Modifier.fillMaxSize(), | ||
| verticalArrangement = Arrangement.Bottom, | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| ) { | ||
| KieroSnackbar( | ||
| message = "이 메세지는 토스트 메세지 입니다", | ||
| modifier = Modifier.padding(16.dp), | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1) AppState 를 통해 navigation 상태 관리를 하는게 저도 처음이라, 사실 보고 좀 생각을 해봤습니다. @Composable
fun AuthScreen(
paddingValues: PaddingValues,
navigateUp: () -> Unit,
navigateToParent: () -> Unit,
navigateToKid: () -> Unit,
modifier: Modifier = Modifier,
) {
val showSnackbar = SnackbarController.Local.current또한, snackBar 와 더불어 저희 프로젝트에서는 dialog 또한 사용하고 있는데 추후 사용될 dialog 까지 생각하면 CompositionLocalProvider(
// 여기서 전역으로 provide 해주고
AppController.SnackbarLocal provides appState::showSnackbar,
AppController.DialogLocal provides dialogController::show,
) {
KieroNavHost(
// NavHost 내부에서는 navigation 로직만을 명시적 전달
navigateToParent = appState::navigateToParent,
navigateToKid = appState::navigateToKid,
)
}이러한 구조도 나쁘지 않을 것 같다는 생각인데, 팀원들의 의견을 듣고 싶네용
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 확장성까지 고려했을 때, CompositionLocal 방식도 괜찮을 것 같습니다! 현재 파라미터 전달 방식은 모든 중간 레이어에 파라미터를 전달해야 하고,
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CompositionLocalProvider 이 더 나을 것 같습니다 ! 현재 어디서 어느 뷰에서 사용될지는 모르겠으나 MainAppState 부터 시작해서 feature의 기능 발생까지 내려 가야하는데 이 방식은 보일러플레이트가 존재할 뿐더러 파라미터로 넘어가는 단계마다 비교 비용이 발생하게됩니다 따라서 CompositionLocalProvider을 적용해서 중앙 집중화와 일관성을 통해 단일 진실 소스를 보장하게 하는 방식이 더 좋을 것 같다고 생각합니다.
우려하시는 부분은 이해합니다 파라미터로 흐름을 파악 가능 했어서 우려하신 것 같은데
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CompositionLocalProvider를 활용하면 현재보다 훨씬 깔끔하게 관리될 것 같아 좋은 것 같습니다! |
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) 굳굳슨, 공통 컴포넌트 작업시에 컴포져블 함수 네이밍은
Kiero+컴포넌트명으로 통일할까요?서비스명을 안붙히고
역할+컴포넌트명으로 하는 상황도 많이 봤어서 통일하고 가는게 좋을 것 같습니당@seungjae708 @sonms @dmp100
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.
괜찮다고 생각합니다 ! 공통 컴포넌트로 쓰기엔 적합한거같아요 !
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.
공통이라는 것을 한눈에 알기쉬워서 키어로+컴포넌트명으로 통일하는 것으로 하는 것이 좋을 것 같아요!