diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel3ViewModel.kt b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel3ViewModel.kt index f2b9b415d..63c1ab190 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel3ViewModel.kt +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel3ViewModel.kt @@ -2,6 +2,8 @@ package org.mifos.mobilewallet.mifospay.kyc.presenter import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow import org.mifos.mobilewallet.core.base.UseCaseHandler import org.mifos.mobilewallet.mifospay.data.local.LocalRepository import javax.inject.Inject @@ -11,5 +13,16 @@ class KYCLevel3ViewModel @Inject constructor( private val mUseCaseHandler: UseCaseHandler, private val mLocalRepository: LocalRepository ) : ViewModel() { + private val _kyc3uiState = + MutableStateFlow(KYCLevel3UiState.Loading) + val kyc3uiState: StateFlow = _kyc3uiState + //Todo: Implement KYCLevel3ViewModel flow + +} + +sealed interface KYCLevel3UiState { + data object Loading : KYCLevel3UiState + data object Success : KYCLevel3UiState + data object Error : KYCLevel3UiState } \ No newline at end of file diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Fragment.kt b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Fragment.kt index 4437f2a05..db5e8fa03 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Fragment.kt +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Fragment.kt @@ -4,34 +4,30 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import butterknife.ButterKnife +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy import dagger.hilt.android.AndroidEntryPoint -import org.mifos.mobilewallet.mifospay.R import org.mifos.mobilewallet.mifospay.base.BaseFragment -import org.mifos.mobilewallet.mifospay.kyc.KYCContract -import org.mifos.mobilewallet.mifospay.kyc.KYCContract.KYCLevel3View -import org.mifos.mobilewallet.mifospay.kyc.presenter.KYCLevel3Presenter -import javax.inject.Inject +import org.mifos.mobilewallet.mifospay.theme.MifosTheme /** * Created by ankur on 17/May/2018 */ @AndroidEntryPoint -class KYCLevel3Fragment : BaseFragment(), KYCLevel3View { - @JvmField - @Inject - var mPresenter: KYCLevel3Presenter? = null - var mKYCLevel3Presenter: KYCContract.KYCLevel3Presenter? = null +class KYCLevel3Fragment : BaseFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { - val rootView = inflater.inflate(R.layout.fragment_kyc_lvl3, container, false) - ButterKnife.bind(this, rootView) - mPresenter!!.attachView(this) - //setToolbarTitle(Constants.KYC_REGISTRATION_LEVEL_3); - return rootView + ): View { + return ComposeView(requireContext()).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MifosTheme { + KYCLevel3Screen() + } + } + } } companion object { @@ -43,8 +39,4 @@ class KYCLevel3Fragment : BaseFragment(), KYCLevel3View { return fragment } } - - override fun setPresenter(presenter: KYCContract.KYCLevel3Presenter?) { - mKYCLevel3Presenter = presenter - } } \ No newline at end of file diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Screen.kt b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Screen.kt index f647292e5..b293d4ea6 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Screen.kt +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/ui/KYCLevel3Screen.kt @@ -17,12 +17,52 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import org.mifos.mobilewallet.mifospay.R +import org.mifos.mobilewallet.mifospay.designsystem.component.MfOverlayLoadingWheel import org.mifos.mobilewallet.mifospay.designsystem.component.MifosOutlinedTextField +import org.mifos.mobilewallet.mifospay.kyc.presenter.KYCLevel3UiState +import org.mifos.mobilewallet.mifospay.kyc.presenter.KYCLevel3ViewModel import org.mifos.mobilewallet.mifospay.theme.MifosTheme @Composable fun KYCLevel3Screen( + viewModel: KYCLevel3ViewModel = hiltViewModel() +){ + val kyc3uiState by viewModel.kyc3uiState.collectAsStateWithLifecycle() + + KYCLevel3Screen( + uiState = kyc3uiState + ) +} + +@Composable +fun KYCLevel3Screen( + uiState: KYCLevel3UiState +){ + + Kyc3Form( + modifier = Modifier + ) + + when (uiState) { + KYCLevel3UiState.Loading -> { + MfOverlayLoadingWheel(stringResource(id = R.string.submitting)) + } + + KYCLevel3UiState.Error -> { + //Todo : Implement Error state + } + + KYCLevel3UiState.Success -> { + //Todo : Implement Success state + } + } +} + +@Composable +fun Kyc3Form( modifier: Modifier ) { var panIdValue by rememberSaveable { mutableStateOf("") } @@ -31,7 +71,7 @@ fun KYCLevel3Screen( modifier = Modifier .fillMaxSize() .padding(20.dp), - verticalArrangement = Arrangement.spacedBy(20.dp) + verticalArrangement = Arrangement.spacedBy(10.dp) ) { MifosOutlinedTextField( @@ -60,6 +100,6 @@ fun KYCLevel3Screen( @Composable fun KYCLevel3ScreenPreview() { MifosTheme { - KYCLevel3Screen(modifier = Modifier) + Kyc3Form(modifier = Modifier) } } \ No newline at end of file