Skip to content
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

[HOTFIX/#91] 차단스크린 닉네임 불러오기 수정 #94

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -38,18 +40,18 @@ 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

@Composable
fun BlockUserRoute(
padding: PaddingValues,
navigateToPreviousScreen: () -> Unit,
viewModel: BlcokUserViewModel = hiltViewModel()
viewModel: BlockUserViewModel = hiltViewModel()
) {
BlockUserScreen(
padding = padding,
Expand All @@ -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) }
Expand All @@ -77,6 +79,7 @@ fun BlockUserScreen(
.background(colors.White)
.padding(padding)
.fillMaxSize()
.imePadding()
) {
SubTopNavBar(
text = stringResource(R.string.block_screen_title),
Expand All @@ -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)
)
}
Expand All @@ -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,
Expand Down Expand Up @@ -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()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import com.sopt.withsuhyeon.core.util.KeyStorage.EMPTY_STRING

data class BlockUserState(
val blockNumber: String = EMPTY_STRING,
val blockNumbers: List<String> = emptyList()
val blockNumbers: List<String> = emptyList(),
val nickname: String = EMPTY_STRING
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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
)
}
}
Expand Down Expand Up @@ -66,7 +66,5 @@ class BlcokUserViewModel @Inject constructor(
}
getBlockUser()
}


}
}