From 66bec9de35aec70c9b77f601f3c5d75bd321b137 Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Fri, 24 Jan 2025 21:37:39 +0900 Subject: [PATCH] =?UTF-8?q?#86=20[fix]=20:=20=EC=B0=A8=EB=8B=A8=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=B0=20=EB=8B=89=EB=84=A4=EC=9E=84=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=98=A4=EA=B8=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../withsuhyeon/feature/main/MainNavigator.kt | 1 + .../feature/onboarding/BlockUser.kt | 25 +++++++++++++------ .../{BlcokUserState.kt => BlockUserState.kt} | 3 ++- ...UserViewModel.kt => BlockUserViewModel.kt} | 8 +++--- 4 files changed, 24 insertions(+), 13 deletions(-) rename app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/{BlcokUserState.kt => BlockUserState.kt} (67%) rename app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/{BlcokUserViewModel.kt => BlockUserViewModel.kt} (91%) diff --git a/app/src/main/java/com/sopt/withsuhyeon/feature/main/MainNavigator.kt b/app/src/main/java/com/sopt/withsuhyeon/feature/main/MainNavigator.kt index 6b9b023..1b9e8c0 100644 --- a/app/src/main/java/com/sopt/withsuhyeon/feature/main/MainNavigator.kt +++ b/app/src/main/java/com/sopt/withsuhyeon/feature/main/MainNavigator.kt @@ -48,6 +48,7 @@ class MainNavigator( .currentBackStackEntryAsState().value?.destination val startDestination = Route.Splash +// val startDestination = Route.BlockUser val currentTab: MainTab? @Composable get() = MainTab.entries.find { tab -> diff --git a/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/BlockUser.kt b/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/BlockUser.kt index 2e1e963..3b297ac 100644 --- a/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/BlockUser.kt +++ b/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/BlockUser.kt @@ -1,6 +1,5 @@ package com.sopt.withsuhyeon.feature.onboarding -import android.util.Log import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -11,10 +10,12 @@ 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.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -29,6 +30,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -38,10 +40,10 @@ import com.sopt.withsuhyeon.core.component.button.LargeButton import com.sopt.withsuhyeon.core.component.listitem.BlockPhoneNumberItem import com.sopt.withsuhyeon.core.component.textfield.BasicShortTextField import com.sopt.withsuhyeon.core.component.topbar.SubTopNavBar +import com.sopt.withsuhyeon.core.util.KeyStorage.EMPTY_STRING import com.sopt.withsuhyeon.core.util.KeyStorage.SAVE_BUTTON_TEXT -import com.sopt.withsuhyeon.core.util.modifier.noRippleClickable import com.sopt.withsuhyeon.core.util.regex.checkValidPhoneNumber -import com.sopt.withsuhyeon.feature.onboarding.viewmodel.BlcokUserViewModel +import com.sopt.withsuhyeon.feature.onboarding.viewmodel.BlockUserViewModel import com.sopt.withsuhyeon.ui.theme.WithSuhyeonTheme.colors import com.sopt.withsuhyeon.ui.theme.WithSuhyeonTheme.typography @@ -49,7 +51,7 @@ import com.sopt.withsuhyeon.ui.theme.WithSuhyeonTheme.typography fun BlockUserRoute( padding: PaddingValues, navigateToPreviousScreen: () -> Unit, - viewModel: BlcokUserViewModel = hiltViewModel() + viewModel: BlockUserViewModel = hiltViewModel() ) { BlockUserScreen( padding = padding, @@ -62,7 +64,7 @@ fun BlockUserRoute( fun BlockUserScreen( padding: PaddingValues, onSaveButtonClick: () -> Unit, - viewModel: BlcokUserViewModel, + viewModel: BlockUserViewModel, modifier: Modifier = Modifier, ) { var isValid by remember { mutableStateOf(false) } @@ -77,6 +79,7 @@ fun BlockUserScreen( .background(colors.White) .padding(padding) .fillMaxSize() + .imePadding() ) { SubTopNavBar( text = stringResource(R.string.block_screen_title), @@ -96,7 +99,8 @@ fun BlockUserScreen( ) Spacer(modifier = Modifier.height(8.dp)) Text( - text = stringResource(R.string.block_screen_description), + text = "차단한 사용자는 ${state.nickname}님의 게시글을 볼 수 없어요", + // TODO - 닉네임 연동 style = typography.caption01_SB.merge(colors.Grey400) ) } @@ -115,13 +119,19 @@ fun BlockUserScreen( viewModel.selectBlockUserNumber(input) isValid = input.length == 11 && input.checkValidPhoneNumber() }, + keyboardOptions = KeyboardOptions.Default.copy( + keyboardType = KeyboardType.Number + ), hint = stringResource(R.string.block_screen_phone_number_hint), + maxLength = 11, trailingContent = { BasicButtonForTextField( text = stringResource(R.string.block_screen_block_text), onClick = { if (isValid) { viewModel.postBlockUser(state.blockNumber) + viewModel.selectBlockUserNumber(EMPTY_STRING) + isValid = false } }, modifier = Modifier, @@ -190,7 +200,8 @@ fun BlockUserScreen( LargeButton( onClick = onSaveButtonClick, text = SAVE_BUTTON_TEXT, - modifier = Modifier.padding(horizontal = 16.dp), + modifier = Modifier + .padding(start = 16.dp, end = 16.dp, bottom = 16.dp), isDisabled = state.blockNumbers.isEmpty() ) } diff --git a/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/BlcokUserState.kt b/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/BlockUserState.kt similarity index 67% rename from app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/BlcokUserState.kt rename to app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/BlockUserState.kt index d9151db..4f5d33a 100644 --- a/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/BlcokUserState.kt +++ b/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/state/BlockUserState.kt @@ -5,5 +5,6 @@ import com.sopt.withsuhyeon.core.util.KeyStorage.EMPTY_STRING data class BlockUserState( val blockNumber: String = EMPTY_STRING, - val blockNumbers: List = emptyList() + val blockNumbers: List = emptyList(), + val nickname: String = EMPTY_STRING ) \ No newline at end of file diff --git a/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/BlcokUserViewModel.kt b/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/BlockUserViewModel.kt similarity index 91% rename from app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/BlcokUserViewModel.kt rename to app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/BlockUserViewModel.kt index 32bcbd6..925bcc3 100644 --- a/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/BlcokUserViewModel.kt +++ b/app/src/main/java/com/sopt/withsuhyeon/feature/onboarding/viewmodel/BlockUserViewModel.kt @@ -3,7 +3,6 @@ package com.sopt.withsuhyeon.feature.onboarding.viewmodel import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.sopt.withsuhyeon.data.dto.request.RequestBlockUserDto import com.sopt.withsuhyeon.domain.repository.BlockUserRepository import com.sopt.withsuhyeon.feature.onboarding.state.BlockUserState import dagger.hilt.android.lifecycle.HiltViewModel @@ -14,7 +13,7 @@ import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel -class BlcokUserViewModel @Inject constructor( +class BlockUserViewModel @Inject constructor( private val blockUserRepository: BlockUserRepository ) : ViewModel() { private val _blockUserState = MutableStateFlow(BlockUserState()) @@ -34,7 +33,8 @@ class BlcokUserViewModel @Inject constructor( blockUserRepository.getBlockUser().onSuccess { response -> _blockUserState.update { current -> current.copy( - blockNumbers = response.phoneNumbers + blockNumbers = response.phoneNumbers, + nickname = response.nickname ) } } @@ -66,7 +66,5 @@ class BlcokUserViewModel @Inject constructor( } getBlockUser() } - - } }