TP-63188 | UPI | amount chip selection fix (#10361)

This commit is contained in:
Shaurya Rehan
2024-04-09 14:22:33 +05:30
committed by GitHub
parent f8dc4675fe
commit c55ef7205c
2 changed files with 20 additions and 7 deletions

View File

@@ -152,6 +152,8 @@ fun UPILiteSection(
val nonOnboardedDescriptionList by
upiLiteViewModel.nonOnboardedDescriptionList.collectAsStateWithLifecycle()
val amountChipEntityList by upiLiteViewModel.amountChipEntityList.collectAsStateWithLifecycle()
val isAmountChipClickEnabled by
upiLiteViewModel.isAmountChipClickEnabled.collectAsStateWithLifecycle()
val alphaAdjusted by remember { derivedStateOf { if (enableClickOnSelection) 1f else 0.5f } }
@@ -423,7 +425,7 @@ fun UPILiteSection(
modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp),
onAmountChipClicked = onAmountChipClicked,
isAmountTextFieldEnabled = enableClickOnSelection,
isClickEnabled = hideFooterAndShowNudge,
isClickEnabled = isAmountChipClickEnabled,
amountChipEntityList = amountChipEntityList
)
}
@@ -651,19 +653,19 @@ private fun RowScope.RenderAmountChipItem(
) {
val alphaAdjusted by
remember(key1 = isAmountTextFieldEnabled, key2 = isClickEnabled) {
derivedStateOf { if (isAmountTextFieldEnabled || !isClickEnabled) 1f else 0.5f }
derivedStateOf { if (isAmountTextFieldEnabled || isClickEnabled) 1f else 0.5f }
}
val isChipSelected by
remember(key1 = isSelected, key2 = isClickEnabled) {
derivedStateOf { isSelected && !isClickEnabled }
derivedStateOf { isSelected && isClickEnabled }
}
Spacer(modifier = Modifier.width(4.dp))
NaviPayCard(
modifier =
Modifier.width(IntrinsicSize.Min)
.conditional(!isClickEnabled) {
.conditional(isClickEnabled) {
clickable { onAmountChipClicked(amount, isMaxAmountChip) }
}
.alpha(alpha = alphaAdjusted),

View File

@@ -416,10 +416,23 @@ constructor(
private var activeLiteAccountInfoFromSharedPref = UpiLiteActiveAccountInfo()
val isAmountChipClickEnabled =
combine(hideFooterAndShowNudge, bankAccountsState) {
hideFooterAndShowNudge,
bankAccountsState ->
!hideFooterAndShowNudge && bankAccountsState is BankAccountsState.AccountList
}
.flowOn(coroutineDispatcherProvider.default)
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(),
initialValue = false
)
init {
fetchNaviPayUPILiteConfig()
getUpiLiteScreenInfo()
updateNaviPaySessionId()
fetchNaviPayUPILiteConfig()
getActiveLiteAccountInfoFromSharedPref()
}
@@ -1187,8 +1200,6 @@ constructor(
)
)
updateEnteredAmount(amount = getPreFilledTopUpAmount(balance = balance))
naviPayAnalytics.onDevGenericEvent(
event = ::checkAndUpdateUiIfLiteAccountExists.name,
params =