From 2dfe18eaef881f484d523d45d529a0ea65d0e2a2 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Fri, 17 Jan 2025 21:08:28 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]#223=20:=20=EC=AA=BD=EC=A7=80=20?= =?UTF-8?q?=EC=88=98=EC=8B=A0=EC=9E=90=20=EC=84=A0=ED=83=9D=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EA=B3=B5=ED=86=B5=20=EB=B0=94=ED=85=80=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/send/ReceiverSelectionScreen.kt | 259 ++++++++---------- 1 file changed, 109 insertions(+), 150 deletions(-) diff --git a/feature/message/src/main/kotlin/com/bff/wespot/message/screen/send/ReceiverSelectionScreen.kt b/feature/message/src/main/kotlin/com/bff/wespot/message/screen/send/ReceiverSelectionScreen.kt index eef7099e..684e1057 100644 --- a/feature/message/src/main/kotlin/com/bff/wespot/message/screen/send/ReceiverSelectionScreen.kt +++ b/feature/message/src/main/kotlin/com/bff/wespot/message/screen/send/ReceiverSelectionScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -24,14 +23,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.layout.SubcomposeLayout import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalSoftwareKeyboardController -import androidx.compose.ui.platform.SoftwareKeyboardController import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.itemKey import coil.compose.AsyncImage @@ -46,12 +42,10 @@ import com.bff.wespot.designsystem.theme.WeSpotThemeManager import com.bff.wespot.message.R import com.bff.wespot.message.component.SendExitDialog import com.bff.wespot.message.state.send.SendAction -import com.bff.wespot.message.state.send.SendUiState import com.bff.wespot.message.viewmodel.SendViewModel import com.bff.wespot.model.common.KakaoContent -import com.bff.wespot.model.user.response.User import com.bff.wespot.navigation.Navigator -import com.bff.wespot.ui.component.ListBottomGradient +import com.bff.wespot.ui.component.BottomButtonLayout import com.bff.wespot.ui.component.NetworkDialog import com.bff.wespot.ui.component.WSListItem import com.bff.wespot.ui.util.handleSideEffect @@ -111,81 +105,129 @@ fun ReceiverSelectionScreen( ) }, ) { - Column( + BottomButtonLayout( modifier = Modifier .clickable( indication = null, interactionSource = interactionSource, onClick = { keyboard?.hide() }, ) - .padding(it) - .padding(horizontal = 20.dp), + .padding(it), + showGradient = true, + button = { + WSButton( + onClick = { + if (navArgs.isEditing) { + navigator.navigateUp() + return@WSButton + } + navigator.navigateMessageWriteScreen( + args = MessageWriteScreenArgs(isEditing = false), + ) + }, + enabled = state.selectedUser.name.isNotBlank(), + text = if (navArgs.isEditing) { + stringResource(R.string.edit_done) + } else { + stringResource(R.string.next) + }, + content = { it() }, + ) + }, ) { - Text( - modifier = Modifier - .padding(horizontal = 4.dp), - text = stringResource(R.string.receiver_screen_title, state.profile.name), - style = StaticTypeScale.Default.header1, - color = WeSpotThemeManager.colors.txtTitleColor, - ) + Column(modifier = Modifier.padding(horizontal = 20.dp)) { + Text( + modifier = Modifier + .padding(horizontal = 4.dp), + text = stringResource(R.string.receiver_screen_title, state.profile.name), + style = StaticTypeScale.Default.header1, + color = WeSpotThemeManager.colors.txtTitleColor, + ) - Spacer(modifier = Modifier.height(16.dp)) + Spacer(modifier = Modifier.height(16.dp)) - WsTextField( - value = state.nameInput, - onValueChange = { - action(SendAction.OnSearchContentChanged(it)) - }, - placeholder = stringResource(R.string.receiver_search_text_field_placeholder), - textFieldType = WsTextFieldType.Search, - focusRequester = focusRequester, - singleLine = true, - ) + WsTextField( + value = state.nameInput, + onValueChange = { + action(SendAction.OnSearchContentChanged(it)) + }, + placeholder = stringResource(R.string.receiver_search_text_field_placeholder), + textFieldType = WsTextFieldType.Search, + focusRequester = focusRequester, + singleLine = true, + ) - if (pagingData.itemCount == 0) { - Box( - modifier = Modifier - .fillMaxWidth() - .padding(top = 24.dp), - contentAlignment = Alignment.Center, - ) { - Text( + if (pagingData.itemCount == 0) { + Box( modifier = Modifier - .drawBehind { - drawLine( - strokeWidth = 1f * density, - color = Gray300, - start = Offset(0f, size.height), - end = Offset(size.width, size.height), - ) - } - .clickable { - if (state.kakaoContent != KakaoContent.EMPTY) { - activityNavigator.navigateToKakao( - context = context, - title = state.kakaoContent.title, - description = state.kakaoContent.description, - imageUrl = state.kakaoContent.imageUrl, - buttonText = state.kakaoContent.buttonText, - url = state.kakaoContent.url, + .fillMaxWidth() + .padding(top = 24.dp), + contentAlignment = Alignment.Center, + ) { + Text( + modifier = Modifier + .drawBehind { + drawLine( + strokeWidth = 1f * density, + color = Gray300, + start = Offset(0f, size.height), + end = Offset(size.width, size.height), ) } - }, - text = stringResource(R.string.invite_friend_text), - style = StaticTypeScale.Default.body5, - color = WeSpotThemeManager.colors.txtSubColor, - ) + .clickable { + if (state.kakaoContent != KakaoContent.EMPTY) { + activityNavigator.navigateToKakao( + context = context, + title = state.kakaoContent.title, + description = state.kakaoContent.description, + imageUrl = state.kakaoContent.imageUrl, + buttonText = state.kakaoContent.buttonText, + url = state.kakaoContent.url, + ) + } + }, + text = stringResource(R.string.invite_friend_text), + style = StaticTypeScale.Default.body5, + color = WeSpotThemeManager.colors.txtSubColor, + ) + } } - } - ReceiverSelectionLayout( - navigator = navigator, - isEditing = navArgs.isEditing, - keyboard = keyboard, - pagingData = pagingData, - state = state, - action = action, - ) + LazyColumn( + modifier = Modifier.padding(top = 16.dp), + ) { + items( + pagingData.itemCount, + key = pagingData.itemKey { key -> key.id }, + ) { index -> + val item = pagingData[index] + + item?.let { + WSListItem( + title = item.name, + subTitle = item.toSchoolInfo(), + selected = state.selectedUser.id == item.id, + backgroundColor = item.profileCharacter.backgroundColor, + onClick = { + keyboard?.hide() + action(SendAction.OnUserSelected(item)) + }, + imageContent = { + AsyncImage( + model = ImageRequest.Builder(LocalContext.current) + .data(item.profileCharacter.iconUrl) + .crossfade(true) + .build(), + contentDescription = stringResource( + com.bff.wespot.ui.R.string.user_character_image, + ), + ) + }, + ) + } + } + } + } } } @@ -212,86 +254,3 @@ fun ReceiverSelectionScreen( action(SendAction.OnReceiverScreenEntered) } } - -@Composable -private fun ReceiverSelectionLayout( - navigator: ReceiverSelectionNavigator, - isEditing: Boolean, - keyboard: SoftwareKeyboardController?, - pagingData: LazyPagingItems, - state: SendUiState, - action: (SendAction) -> Unit, -) { - SubcomposeLayout { constraints -> - val listGradientPlaceable = subcompose("listGradient") { - ListBottomGradient(height = 124) - }.first().measure(constraints) - - val selectButtonPlaceable = subcompose("selectButton") { - WSButton( - onClick = { - if (isEditing) { - navigator.navigateUp() - return@WSButton - } - navigator.navigateMessageWriteScreen( - args = MessageWriteScreenArgs(isEditing = false), - ) - }, - paddingValues = PaddingValues(vertical = 12.dp), - enabled = state.selectedUser.name.isNotBlank(), - text = if (isEditing) stringResource(R.string.edit_done) else stringResource(R.string.next), - content = { it() }, - ) - }.first().measure(constraints) - - val receiverListMaxHeight = constraints.maxHeight - selectButtonPlaceable.height - val receiverListPlaceable = subcompose("receiverList") { - LazyColumn(modifier = Modifier.padding(top = 16.dp)) { - items( - pagingData.itemCount, - key = pagingData.itemKey { it.id }, - ) { index -> - val item = pagingData[index] - - item?.let { - WSListItem( - title = item.name, - subTitle = item.toSchoolInfo(), - selected = state.selectedUser.id == item.id, - backgroundColor = item.profileCharacter.backgroundColor, - onClick = { - keyboard?.hide() - action(SendAction.OnUserSelected(item)) - }, - imageContent = { - AsyncImage( - model = ImageRequest.Builder(LocalContext.current) - .data(item.profileCharacter.iconUrl) - .crossfade(true) - .build(), - contentDescription = stringResource( - com.bff.wespot.ui.R.string.user_character_image, - ), - ) - }, - ) - } - } - } - }.first().measure(constraints.copy(maxHeight = receiverListMaxHeight)) - - var yPosition = 0 - layout(constraints.maxWidth, constraints.maxHeight) { - receiverListPlaceable.placeRelative(0, yPosition) - yPosition += receiverListMaxHeight - - listGradientPlaceable.placeRelative( - x = 0, - y = constraints.maxHeight - listGradientPlaceable.height, - ) - - selectButtonPlaceable.placeRelative(0, yPosition) - } - } -}