diff --git a/presentation/src/main/java/com/fakedevelopers/presentation/ui/productRegistration/ProductRegistrationFragment.kt b/presentation/src/main/java/com/fakedevelopers/presentation/ui/productRegistration/ProductRegistrationFragment.kt index 4ec04fd6..65859c34 100644 --- a/presentation/src/main/java/com/fakedevelopers/presentation/ui/productRegistration/ProductRegistrationFragment.kt +++ b/presentation/src/main/java/com/fakedevelopers/presentation/ui/productRegistration/ProductRegistrationFragment.kt @@ -16,6 +16,7 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.PermissionChecker import androidx.core.content.PermissionChecker.checkCallingOrSelfPermission +import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs @@ -31,6 +32,7 @@ import com.fakedevelopers.presentation.ui.productRegistration.PriceTextWatcher.C import com.fakedevelopers.presentation.ui.productRegistration.PriceTextWatcher.Companion.MAX_TICK_LENGTH import com.fakedevelopers.presentation.ui.util.ApiErrorHandler import com.fakedevelopers.presentation.ui.util.KeyboardVisibilityUtils +import com.fakedevelopers.presentation.ui.util.priceToLong import com.fakedevelopers.presentation.ui.util.repeatOnStarted import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest @@ -42,7 +44,13 @@ class ProductRegistrationFragment : BaseFragment + private val args: ProductRegistrationFragmentArgs by navArgs() private val viewModel: ProductRegistrationViewModel by viewModels() + private val expirationFilter by lazy { + InputFilter { source, _, _, _, dstart, _ -> + if (source == "0" && dstart == 0) "" else source.replace(IS_NOT_NUMBER.toRegex(), "") + } + } private val backPressedCallback by lazy { object : OnBackPressedCallback(true) { @@ -55,7 +63,6 @@ class ProductRegistrationFragment : BaseFragment - if (source == "0" && dstart == 0) "" else source.replace(IS_NOT_NUMBER.toRegex(), "") - } // 만료 시간 필터 등록 binding.edittextProductRegistrationExpiration.apply { addTextChangedListener(object : TextWatcher { @@ -143,16 +149,16 @@ class ProductRegistrationFragment : BaseFragment - viewModel.setContentLengthVisibility(hasFocus) + binding.textviewProductRegistrationContentLength.isVisible = hasFocus } } // 툴바 뒤로가기 버튼 @@ -207,13 +213,6 @@ class ProductRegistrationFragment : BaseFragment>() val productRegistrationResponse = _productRegistrationResponse.asEventFlow() - private val _contentLengthVisible = MutableStateFlow(false) - val contentLengthVisible: StateFlow get() = _contentLengthVisible - private val _condition = MutableStateFlow(false) val condition: StateFlow get() = _condition @@ -182,12 +179,6 @@ class ProductRegistrationViewModel @Inject constructor( categoryID ) - fun setContentLengthVisibility(state: Boolean) { - viewModelScope.launch { - _contentLengthVisible.emit(state) - } - } - fun setProductCategory(list: List) { category = list } diff --git a/presentation/src/main/res/layout/fragment_product_registration.xml b/presentation/src/main/res/layout/fragment_product_registration.xml index 29075dd2..2961fc80 100644 --- a/presentation/src/main/res/layout/fragment_product_registration.xml +++ b/presentation/src/main/res/layout/fragment_product_registration.xml @@ -189,7 +189,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" - android:visibility="@{vm.contentLengthVisible ? View.VISIBLE : View.INVISIBLE}" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.95"