-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor/#143] 등록 뷰 리팩토링 #144
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 4 commits
91db928
f6c3017
e4a931d
b8cf38a
da1dfb0
5b2b728
51edf7a
84879be
b540b42
cc8bab0
c19f866
35377de
606aa79
b1c88fa
ef1c311
2145421
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,116 @@ | ||
| package com.poti.android.presentation.party.component | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.lazy.grid.GridCells | ||
| import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
| import androidx.compose.foundation.lazy.grid.items | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.rememberModalBottomSheetState | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.poti.android.R | ||
| import com.poti.android.core.common.util.screenWidthDp | ||
| import com.poti.android.core.designsystem.component.bottomsheet.PotiBottomSheet | ||
| import com.poti.android.core.designsystem.component.button.ChipButtonType | ||
| import com.poti.android.core.designsystem.component.button.PotiChipButton | ||
| import com.poti.android.core.designsystem.theme.PotiTheme | ||
|
|
||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| fun <T> MemberSelectBottomSheet( | ||
| title: String, | ||
| mainBtnText: String, | ||
| subBtnText: String, | ||
| onDismiss: () -> Unit, | ||
| onMainBtnClick: () -> Unit, | ||
| onSubBtnClick: () -> Unit, | ||
| allMembers: List<T>, | ||
| selectedMembers: List<T>, | ||
| onMemberClick: (T) -> Unit, | ||
| memberToName: (T) -> String, | ||
| memberToId: (T) -> Long, | ||
| mainEnabled: Boolean, | ||
| subEnabled: Boolean, | ||
| autoCloseSubBtn: Boolean = true, | ||
| ) { | ||
| val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) | ||
|
|
||
| val selectedMemberIds = remember(selectedMembers) { | ||
| selectedMembers.map { memberToId(it) }.toSet() | ||
| } | ||
|
|
||
| PotiBottomSheet( | ||
| onDismissRequest = onDismiss, | ||
| text = mainBtnText, | ||
| onClick = onMainBtnClick, | ||
| subText = subBtnText, | ||
| onSubClick = onSubBtnClick, | ||
| subEnabled = subEnabled, | ||
| enabled = mainEnabled, | ||
| sheetState = sheetState, | ||
| autoCloseSub = autoCloseSubBtn, | ||
| ) { | ||
| Text( | ||
| text = title, | ||
| modifier = Modifier | ||
| .padding(top = 12.dp, bottom = 16.dp, start = screenWidthDp(16.dp)) | ||
| .background(PotiTheme.colors.white), | ||
| color = PotiTheme.colors.black, | ||
| style = PotiTheme.typography.title18sb, | ||
| ) | ||
|
|
||
| LazyVerticalGrid( | ||
| columns = GridCells.Fixed(2), | ||
| modifier = Modifier | ||
| .height(492.dp) | ||
|
Contributor
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. P2: 고정 높이 안 쓰고 screenHeight 사용해주면 화면 비율에 맞출 수 있을 것 같습니당 |
||
| .fillMaxWidth(), | ||
| contentPadding = PaddingValues(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 40.dp), | ||
| horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp), | ||
| ) { | ||
| items( | ||
| items = allMembers, | ||
| key = { memberToId(it) }, | ||
| ) { member -> | ||
| val isSelected = memberToId(member) in selectedMemberIds | ||
|
|
||
| PotiChipButton( | ||
| text = memberToName(member), | ||
| onClick = { onMemberClick(member) }, | ||
| modifier = Modifier.fillMaxWidth(), | ||
| type = if (isSelected) ChipButtonType.SELECTED else ChipButtonType.DEFAULT, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun MemberSelectBottomSheetPreview() { | ||
| MemberSelectBottomSheet( | ||
| title = stringResource(R.string.action_button_continue), | ||
| onDismiss = {}, | ||
| mainBtnText = stringResource(R.string.action_button_continue), | ||
| onMainBtnClick = {}, | ||
| mainEnabled = true, | ||
| subBtnText = stringResource(R.string.action_button_continue), | ||
| onSubBtnClick = {}, | ||
| subEnabled = true, | ||
| allMembers = listOf("원영, 유진"), | ||
| selectedMembers = listOf("원영"), | ||
| onMemberClick = {}, | ||
| memberToName = { "" }, | ||
| memberToId = { 0L }, | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,8 @@ import com.poti.android.core.designsystem.theme.PotiTheme | |
| import com.poti.android.domain.model.artist.ArtistSearchResult | ||
| import com.poti.android.presentation.party.create.component.CreateDropdownField | ||
| import com.poti.android.presentation.party.create.component.ViewType | ||
| import com.poti.android.presentation.party.create.model.CreateUiEffect | ||
| import com.poti.android.presentation.party.create.model.CreateUiIntent | ||
| import com.poti.android.presentation.party.create.model.CreateUiEffect.* | ||
| import com.poti.android.presentation.party.create.model.CreateUiIntent.* | ||
| import com.poti.android.presentation.party.create.model.CreateUiState | ||
|
|
||
| @Composable | ||
|
|
@@ -39,17 +39,17 @@ fun PartyArtistSelectRoute( | |
|
|
||
| HandleSideEffects(viewModel.sideEffect) { effect -> | ||
| when (effect) { | ||
| CreateUiEffect.NavigateToBack -> onPopBackStack() | ||
| NavigateToBack -> onPopBackStack() | ||
| else -> Unit | ||
| } | ||
| } | ||
|
|
||
| PartyArtistSelectScreen( | ||
| uiState = uiState, | ||
| onSearchKeywordChange = { viewModel.processIntent(CreateUiIntent.OnArtistSearchKeywordChange(it)) }, | ||
| onArtistSelect = { viewModel.processIntent(CreateUiIntent.OnArtistSelect(it)) }, | ||
| onConfirmClick = { viewModel.processIntent(CreateUiIntent.OnBackToCreate) }, | ||
| onPopBackStack = { viewModel.processIntent(CreateUiIntent.OnBackToCreate) }, | ||
| onSearchKeywordChange = { viewModel.processIntent(OnArtistChange(it)) }, | ||
| onArtistSelect = { viewModel.processIntent(OnArtistSelect(it)) }, | ||
| onConfirmClick = { viewModel.processIntent(OnBackToCreate) }, | ||
| onPopBackStack = { viewModel.processIntent(OnBackToCreate) }, | ||
| modifier = modifier, | ||
| ) | ||
| } | ||
|
|
@@ -92,9 +92,9 @@ private fun PartyArtistSelectScreen( | |
| ) { | ||
| CreateDropdownField( | ||
| viewType = ViewType.ARTSIT_SELECT, | ||
| value = uiState.artistSearchKeyword, | ||
| value = uiState.artistQuery, | ||
|
Contributor
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. P3: 이름을 이렇게 바꾼 이유가 있나욤?? artistSearchKeyword가 뭔가 더 직관적인 것 같은데
Contributor
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. artistSearchKeyword가 넘 길다 싶어서 바꿔봤는대 artistSearchKeyword로 돌아가도록 하겟습니다 |
||
| onValueChanged = onSearchKeywordChange, | ||
| searchResults = uiState.artistSearchResultsState.getSuccessDataOrNull() ?: emptyList(), | ||
| searchResults = uiState.artistSearchState.getSuccessDataOrNull() ?: emptyList(), | ||
| resultToString = { it.name }, | ||
| onItemClick = { onArtistSelect(it) }, | ||
| placeholder = stringResource(R.string.create_placeholder_artist_search), | ||
|
|
||
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.
P2: 텍스트에는 따로 background 안 줘도 될 것 같아여