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

[fix] textfield bug fix #386

Merged
merged 3 commits into from
Sep 23, 2024
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 @@ -9,6 +9,7 @@ import `in`.koreatech.koin.domain.usecase.business.changepassword.ChangePassword
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.Container
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand Down Expand Up @@ -45,7 +46,7 @@ class ChangePasswordViewModel @Inject constructor(
}
}

fun insertPassword(password: String) = intent{
fun insertPassword(password: String) = blockingIntent{
reduce { state.copy(password = password) }
coincidePasswordReset()
fillAllPasswords()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand Down Expand Up @@ -49,7 +50,7 @@ class PasswordAuthenticationViewModel @Inject constructor(
}
}

fun insertPhoneNumber(phoneNumber: String) = intent {
fun insertPhoneNumber(phoneNumber: String) = blockingIntent {
reduce {
state.copy(
phoneNumber = phoneNumber,
Expand All @@ -59,7 +60,7 @@ class PasswordAuthenticationViewModel @Inject constructor(
}
}

fun insertAuthCode(authCode: String) = intent {
fun insertAuthCode(authCode: String) = blockingIntent {
reduce {
state.copy(
authenticationCode = authCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import `in`.koreatech.business.feature.insertstore.insertmaininfo.InsertBasicInfoScreenState
import org.orbitmvi.orbit.Container
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand Down Expand Up @@ -60,21 +61,21 @@ class InsertDetailInfoScreenViewModel @Inject constructor(
}
}

fun onChangePhoneNumber(phoneNumber: String) = intent{
fun onChangePhoneNumber(phoneNumber: String) = blockingIntent{
reduce {
state.copy(storePhoneNumber = phoneNumber)
}
isDetailInfoValid()
}

fun onChangeDeliveryFee(deliveryFee: String) = intent{
fun onChangeDeliveryFee(deliveryFee: String) = blockingIntent{
reduce {
state.copy(storeDeliveryFee = deliveryFee)
}
isDetailInfoValid()
}

fun onChangeOtherInfo(otherInfo: String) = intent{
fun onChangeOtherInfo(otherInfo: String) = blockingIntent{
reduce {
state.copy(storeOtherInfo = otherInfo)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import `in`.koreatech.koin.domain.usecase.presignedurl.GetMarketPreSignedUrlUseC
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.Container
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand All @@ -29,14 +30,14 @@ class InsertBasicInfoScreenViewModel @Inject constructor(
getCategoryId(categoryId)
}

fun insertStoreName(storeName: String) = intent {
fun insertStoreName(storeName: String) = blockingIntent {
reduce {
state.copy(storeName = storeName)
}
isBasicInfoValidate()
}

fun insertStoreAddress(storeAddress: String) = intent{
fun insertStoreAddress(storeAddress: String) = blockingIntent{
reduce {
state.copy(storeAddress = storeAddress)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import `in`.koreatech.business.ui.theme.ColorUnarchived
import `in`.koreatech.business.ui.theme.Gray1
import `in`.koreatech.business.ui.theme.Gray2
import `in`.koreatech.business.ui.theme.KOIN_ANDROIDTheme
import `in`.koreatech.koin.domain.error.owner.OwnerError
import `in`.koreatech.koin.domain.state.signup.SignupContinuationState
import org.orbitmvi.orbit.compose.collectAsState
import org.orbitmvi.orbit.compose.collectSideEffect
Expand Down Expand Up @@ -133,6 +134,7 @@ fun AccountSetupScreen(

Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 24.dp)
.verticalScroll(scrollState),
verticalArrangement = Arrangement.Center,
Expand All @@ -159,29 +161,33 @@ fun AccountSetupScreen(
modifier = Modifier.width(203.dp),
label = stringResource(id = R.string.enter_phone_number),
textStyle = TextStyle.Default.copy(fontSize = 15.sp),
errorText = if (state.phoneNumberState is SignupContinuationState.Failed) state.phoneNumberState.message else stringResource(
R.string.error_network_unknown
),
errorText = when (state.sendCodeError) {
OwnerError.ExistsPhoneNumberException -> stringResource(
id = R.string.error_account_duplicated
)
OwnerError.NotValidPhoneNumberException -> stringResource(
id = R.string.error_invalid_phone_number
)
else -> stringResource(id = R.string.error_network_unknown)
},
successText = stringResource(R.string.success_send_sms_code),
isError = state.phoneNumberState is SignupContinuationState.Failed,
isError = state.sendCodeError != null,
isSuccess = state.phoneNumberState == SignupContinuationState.RequestedSmsValidation,
)

Button(modifier = Modifier
.width(115.dp)
.height(41.dp),
shape = RoundedCornerShape(4.dp),
enabled = state.phoneNumber.isNotEmpty() && state.phoneNumberState !is SignupContinuationState.Failed,
enabled = state.phoneNumber.isNotEmpty() && state.phoneNumberState !is SignupContinuationState.RequestedSmsValidation,
colors = ButtonDefaults.buttonColors(
backgroundColor = ColorPrimary,
backgroundColor = if(state.sendCodeError == null) ColorPrimary else ColorSecondary,
contentColor = Color.White,
disabledBackgroundColor = Gray2,
disabledContentColor = Gray1,
),
onClick = {
viewModel.checkExistsAccount(state.phoneNumber)

}) {
onClick = viewModel::checkExistsAccount
) {
Text(
text = stringResource(id = R.string.send_authentication_code),
fontWeight = Bold,
Expand Down Expand Up @@ -274,14 +280,11 @@ fun AccountSetupScreen(
errorText = stringResource(id = R.string.password_mismatch),
isError = state.isPasswordConfirmError,
)




Spacer(modifier = Modifier.height(55.dp))
Spacer(modifier = Modifier.weight(1f))
Button(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 24.dp)
.height(44.dp),
shape = RectangleShape,
enabled = state.isButtonEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ data class AccountSetupState(
val isPasswordConfirmError: Boolean = false,
val verifyState : SignupContinuationState = SignupContinuationState.AvailablePhoneNumber,
val phoneNumberState: SignupContinuationState = SignupContinuationState.AvailablePhoneNumber,
val verifyError:Throwable? = null,
val sendCodeError:Throwable? = null,
val isButtonEnabled: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand Down Expand Up @@ -88,20 +89,22 @@ class AccountSetupViewModel @Inject constructor(
}
}

fun onPhoneNumChanged(phoneNumber: String) = intent {
fun onPhoneNumChanged(phoneNumber: String) = blockingIntent {
reduce {
state.copy(
phoneNumber = phoneNumber,
phoneNumberState = SignupContinuationState.AvailablePhoneNumber
phoneNumberState = SignupContinuationState.AvailablePhoneNumber,
sendCodeError = null,
)
}
}

fun onAuthCodeChanged(authCode: String) = intent {
fun onAuthCodeChanged(authCode: String) = blockingIntent {
reduce {
state.copy(
authCode = authCode,
verifyState = SignupContinuationState.AvailablePhoneNumber
verifyState = SignupContinuationState.AvailablePhoneNumber,
verifyError = null,
)
}
}
Expand Down Expand Up @@ -138,38 +141,42 @@ class AccountSetupViewModel @Inject constructor(
}
}

private fun sendSmsVerificationCode(phoneNumber: String) {
viewModelScope.launch {
sendSignupSmsCodeUseCase(phoneNumber).let { error ->
intent {
private fun sendSmsVerificationCode() {
intent {
viewModelScope.launch {
sendSignupSmsCodeUseCase(state.phoneNumber).onSuccess {
reduce {
state.copy(
phoneNumberState = if (error == null) SignupContinuationState.RequestedSmsValidation else SignupContinuationState.Failed(
error.message
),
phoneNumberState = SignupContinuationState.RequestedSmsValidation,
sendCodeError = null,
)
}
}.onFailure {
reduce {
state.copy(
sendCodeError = it,
)
}

}
}
}
}

fun checkExistsAccount(phoneNumber: String) {
fun checkExistsAccount() {
viewModelScope.launch {
getOwnerExistsAccountUseCase(phoneNumber).onSuccess {
intent {
intent {
getOwnerExistsAccountUseCase(state.phoneNumber).onSuccess {
reduce {
state.copy(phoneNumberState = SignupContinuationState.AvailablePhoneNumber)
state.copy(
phoneNumberState = SignupContinuationState.AvailablePhoneNumber,
sendCodeError = null,
)
}
sendSmsVerificationCode(phoneNumber)
}

}.onFailure {
intent {
sendSmsVerificationCode()
}.onFailure {
reduce {
state.copy(
phoneNumberState = SignupContinuationState.Failed(it.message),
sendCodeError = it,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import `in`.koreatech.koin.domain.util.onFailure
import `in`.koreatech.koin.domain.util.onSuccess
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand All @@ -30,25 +31,25 @@ class BusinessAuthViewModel @Inject constructor(
override val container =
container<BusinessAuthState, BusinessAuthSideEffect>(BusinessAuthState())

fun onNameChanged(name: String) = intent {
fun onNameChanged(name: String) = blockingIntent {
reduce {
state.copy(name = name)
}
}

fun onShopNameChanged(storeName: String) = intent {
fun onShopNameChanged(storeName: String) = blockingIntent {
reduce {
state.copy(shopName = storeName)
}
}

fun onShopIdChanged(shopId: Int?) = intent {
fun onShopIdChanged(shopId: Int?) = blockingIntent {
reduce {
state.copy(shopId = shopId)
}
}

fun onStoreNumberChanged(storeNumber: String) = intent {
fun onStoreNumberChanged(storeNumber: String) = blockingIntent {
reduce {
state.copy(
shopNumber = storeNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import `in`.koreatech.koin.domain.usecase.business.SearchStoresUseCase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.blockingIntent
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
Expand All @@ -30,7 +31,7 @@ class SearchStoreViewModel @Inject constructor(
}
}

fun onSearchChanged(search: String) = intent {
fun onSearchChanged(search: String) = blockingIntent {
reduce {
state.copy(search = search)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -137,7 +138,7 @@ fun CheckTermScreen(
}

Column(
modifier = Modifier
modifier = Modifier.fillMaxSize()
.padding(horizontal = 24.dp)
.verticalScroll(scrollState),
verticalArrangement = Arrangement.Center,
Expand Down Expand Up @@ -260,11 +261,11 @@ fun CheckTermScreen(
Text(text = stringResource(R.string.term_2), fontSize = 10.sp, color = Color.Black)
}

Spacer(modifier = Modifier.height(50.dp))

Spacer(modifier = Modifier.weight(1f))
Button(
modifier = modifier
.fillMaxWidth()
.padding(bottom = 24.dp)
.height(44.dp),
onClick = { viewModel.onNextButtonClicked() },
shape = RoundedCornerShape(4.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ fun CompleteSignupScreen(
fontSize = 16.sp,
color = ColorDescription,
)

Spacer(modifier = Modifier.height(51.dp))
Spacer(modifier = Modifier.weight(1f))
Button(modifier = Modifier
.fillMaxWidth()
.padding(bottom = 24.dp)
.height(44.dp),
shape = RoundedCornerShape(4.dp),
colors = ButtonDefaults.buttonColors(
Expand Down
Loading
Loading