NTP-5471 | ABHA Prod issues (#13955)

This commit is contained in:
Balrambhai Sharma
2024-12-05 14:36:14 +05:30
committed by GitHub
parent e7f16d42b0
commit 6da8b6492f
5 changed files with 45 additions and 24 deletions

View File

@@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Scaffold
import androidx.compose.material.ScaffoldState
import androidx.compose.material.rememberScaffoldState
@@ -29,6 +30,7 @@ import com.navi.base.model.CtaData
import com.navi.base.model.CtaType
import com.navi.base.model.NaviClickAction
import com.navi.base.utils.orFalse
import com.navi.base.utils.orZero
import com.navi.common.network.models.ErrorMessage
import com.navi.common.ui.errorview.FullScreenErrorComposeView
import com.navi.common.upi.NAME
@@ -96,16 +98,22 @@ class ABHAFragment : GiBaseFragment(), WidgetCallback {
}
},
content = { it ->
Column(modifier = Modifier.padding(it)) {
(state.value as ABHAFragmentVM.ViewState.Success<ABHAPageResponse?>)
.data
?.content
?.forEach {
GenericComposableWidgetFactory(
data = it,
widgetCallback = this@ABHAFragment
)
LazyColumn(modifier = Modifier.padding(it)) {
val pageResponse =
state.value
as ABHAFragmentVM.ViewState.Success<ABHAPageResponse?>
items(
pageResponse.data?.content?.size.orZero(),
key = {
pageResponse.data?.content?.get(it)?.widgetId.orEmpty()
}
) { index: Int ->
val data = pageResponse.data?.content?.get(index)
GenericComposableWidgetFactory(
data = data,
widgetCallback = this@ABHAFragment
)
}
}
},
bottomBar = {

View File

@@ -15,6 +15,7 @@ import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollConfiguration
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
@@ -26,11 +27,14 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.fragment.app.viewModels
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.base.model.CtaData
@@ -132,8 +136,13 @@ class ABHAOtpFragment : BaseFragment(), WidgetCallback {
@Composable
fun AbhaOtpContentScreen(data: ABHAPageResponse) {
val widgetCallback: WidgetCallback = this
val keyboardController = LocalSoftwareKeyboardController.current
LaunchedEffect(Unit) { keyboardController?.show() }
Scaffold(
modifier = Modifier.fillMaxSize().background(color = Color.White),
modifier =
Modifier.fillMaxSize().background(color = Color.White).pointerInput(Unit) {
detectTapGestures(onPress = { keyboardController?.hide() })
},
topBar = {
data.header?.getOrNull(0)?.let { data ->
GenericComposableWidgetFactory(data = data, this)

View File

@@ -15,6 +15,7 @@ import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollConfiguration
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
@@ -30,7 +31,9 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.fragment.app.viewModels
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.base.model.CtaData
@@ -133,8 +136,12 @@ class ABHAaadharFragment : BaseFragment(), WidgetCallback {
fun AbhaAadharContentScreen(data: ABHAPageResponse) {
val errorIndex = viewModel.errorState.collectAsState()
val widgetCallback: WidgetCallback = this
val keyboardController = LocalSoftwareKeyboardController.current
Scaffold(
modifier = Modifier.fillMaxSize().background(color = Color.White),
modifier =
Modifier.fillMaxSize().background(color = Color.White).pointerInput(Unit) {
detectTapGestures(onPress = { keyboardController?.hide() })
},
topBar = {
data.header?.getOrNull(0)?.let { data ->
GenericComposableWidgetFactory(data = data, this)

View File

@@ -35,7 +35,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
@@ -58,7 +57,6 @@ import com.navi.naviwidgets.extensions.getComposeTextStyling
import com.navi.naviwidgets.extensions.setWidgetLayoutParams
import com.navi.naviwidgets.models.response.TextFieldData
import kotlinx.coroutines.delay
import timber.log.Timber
@Composable
fun OTPWidgetComposable(
@@ -141,15 +139,7 @@ fun OtpTextField(
onOtpTextChange: (String, Boolean) -> Unit
) {
val focusRequester = remember { FocusRequester() }
val keyboardController = LocalSoftwareKeyboardController.current
LaunchedEffect(Unit) {
if (otpText.length > otpCount) {
Timber.e("OTP length is greater than the limit")
}
focusRequester.requestFocus()
keyboardController?.show()
}
LaunchedEffect(Unit) { focusRequester.requestFocus() }
BasicTextField(
modifier = modifier.focusRequester(focusRequester),
value = TextFieldValue(otpText, selection = TextRange(otpText.length)),

View File

@@ -9,6 +9,8 @@ package com.navi.naviwidgets.composewidget.widgets
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import com.navi.naviwidgets.callbacks.WidgetCallback
import com.navi.naviwidgets.composewidget.model.RedirectionCtaWidgetData
@@ -17,9 +19,14 @@ fun RedirectionCtaWidgetComposable(
redirectionCtaWidgetComposable: RedirectionCtaWidgetData?,
widgetCallback: WidgetCallback?
) {
val shouldDoCallback =
rememberSaveable(redirectionCtaWidgetComposable?.widgetId) { mutableStateOf(true) }
LaunchedEffect(key1 = redirectionCtaWidgetComposable) {
redirectionCtaWidgetComposable?.widgetData?.cta?.let { ctaData ->
widgetCallback?.onClick(ctaData)
if (shouldDoCallback.value) {
redirectionCtaWidgetComposable?.widgetData?.cta?.let { ctaData ->
widgetCallback?.onClick(ctaData)
}
shouldDoCallback.value = false
}
}
}