NTP-54510 | Divyesh | add recharge cta and remove mutablesnapshot flow (#15733)
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.navi.bbps.feature.category
|
||||
|
||||
import androidx.compose.runtime.snapshots.Snapshot
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.google.gson.Gson
|
||||
@@ -104,6 +103,7 @@ import com.ramcosta.composedestinations.spec.Direction
|
||||
import dagger.Lazy
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.take
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -342,18 +342,17 @@ constructor(
|
||||
pendingBillsShowMoreLessButtonState.value
|
||||
is PendingBillsShowMoreLessButtonState.ShowMore
|
||||
) {
|
||||
Snapshot.withMutableSnapshot { _unpaidBills.value.refresh(getTotalUnpaidBills()) }
|
||||
_unpaidBills.update { getTotalUnpaidBills().toMutableList() }
|
||||
updatePendingBillsShowMoreLessButtonState(
|
||||
PendingBillsShowMoreLessButtonState.ShowLess(
|
||||
totalPendingBillsCount = totalPendingBillsCount
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
||||
Snapshot.withMutableSnapshot {
|
||||
_unpaidBills.value.refresh(
|
||||
getTotalUnpaidBills().take(naviBbpsDefaultConfig.initialVisiblePendingBills)
|
||||
)
|
||||
_unpaidBills.update {
|
||||
getTotalUnpaidBills()
|
||||
.take(naviBbpsDefaultConfig.initialVisiblePendingBills)
|
||||
.toMutableList()
|
||||
}
|
||||
updatePendingBillsShowMoreLessButtonState(
|
||||
PendingBillsShowMoreLessButtonState.ShowMore(
|
||||
@@ -590,12 +589,11 @@ constructor(
|
||||
initialSource = initialSource,
|
||||
sessionAttribute = getNaviBbpsSessionAttributes(),
|
||||
)
|
||||
// to ensure that state is modified in a snapshot-aware context
|
||||
if (
|
||||
pendingBillsShowMoreLessButtonState.value
|
||||
is PendingBillsShowMoreLessButtonState.ShowLess
|
||||
) {
|
||||
Snapshot.withMutableSnapshot { _unpaidBills.value.refresh(unpaidBills) }
|
||||
_unpaidBills.update { unpaidBills.toMutableList() }
|
||||
if (unpaidBills.size > naviBbpsDefaultConfig.initialVisiblePendingBills) {
|
||||
updatePendingBillsShowMoreLessButtonState(
|
||||
PendingBillsShowMoreLessButtonState.ShowLess(
|
||||
@@ -611,10 +609,8 @@ constructor(
|
||||
}
|
||||
return
|
||||
}
|
||||
Snapshot.withMutableSnapshot {
|
||||
_unpaidBills.value.refresh(
|
||||
unpaidBills.take(naviBbpsDefaultConfig.initialVisiblePendingBills)
|
||||
)
|
||||
_unpaidBills.update {
|
||||
unpaidBills.take(naviBbpsDefaultConfig.initialVisiblePendingBills).toMutableList()
|
||||
}
|
||||
updateShowMoreLessButtonState(totalPendingBills = unpaidBills.size)
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.navi.bbps.common.ui.NaviBbpsModalBottomSheetLayout
|
||||
import com.navi.bbps.common.ui.SetStatusBarColor
|
||||
import com.navi.bbps.common.utils.BbpsSnackBarPredefinedConfig
|
||||
import com.navi.bbps.common.utils.NaviBbpsCommonUtils.closeKeyboardOnScroll
|
||||
import com.navi.bbps.common.utils.NaviBbpsCommonUtils.isPayNowClickExperimentEnabled
|
||||
import com.navi.bbps.common.utils.NaviBbpsCommonUtils.isValidContactNumber
|
||||
import com.navi.bbps.common.utils.launchPermissionSettingsScreen
|
||||
import com.navi.bbps.customHide
|
||||
@@ -125,6 +126,7 @@ fun ContactListScreen(
|
||||
val context = LocalContext.current
|
||||
val view = LocalView.current
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
val isPayNowClickExperimentEnabled = remember { isPayNowClickExperimentEnabled() }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
contactListViewModel.fetchOffersAndCoinBurnForProduct(
|
||||
@@ -430,6 +432,7 @@ fun ContactListScreen(
|
||||
openSheet()
|
||||
},
|
||||
multipleOffersDataList = multipleOffersDataList,
|
||||
isPayNowClickExperimentEnabled = isPayNowClickExperimentEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -25,6 +27,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -35,6 +38,7 @@ import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
@@ -98,6 +102,7 @@ fun RenderContactListScreen(
|
||||
offerData: List<OfferData>?,
|
||||
coinBurnData: CoinBurnData?,
|
||||
multipleOffersDataList: Map<String, List<OfferData>>?,
|
||||
isPayNowClickExperimentEnabled: Boolean,
|
||||
) {
|
||||
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
@@ -193,6 +198,7 @@ fun RenderContactListScreen(
|
||||
onDeleteRecentBillClicked = onDeleteRecentBillClicked,
|
||||
isDeleteMenuButtonEnabled = isDeleteMenuButtonEnabled,
|
||||
multipleOffersDataList = multipleOffersDataList,
|
||||
isPayNowClickExperimentEnabled = isPayNowClickExperimentEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -261,6 +267,7 @@ fun RecentBillsSection(
|
||||
onDeleteRecentBillClicked: (MyBillEntity) -> Unit,
|
||||
isDeleteMenuButtonEnabled: Boolean,
|
||||
multipleOffersDataList: Map<String, List<OfferData>>?,
|
||||
isPayNowClickExperimentEnabled: Boolean,
|
||||
) {
|
||||
animatedRecentBills.forEachIndexed { index, billItem ->
|
||||
key(billItem.billId) {
|
||||
@@ -296,6 +303,7 @@ fun RecentBillsSection(
|
||||
billId = billItem.billId,
|
||||
),
|
||||
primaryCustomerParamValue = billItem.primaryCustomerParamValue,
|
||||
isPayNowClickExperimentEnabled = isPayNowClickExperimentEnabled,
|
||||
)
|
||||
if (index < recentBills.size - 1) {
|
||||
BbpsListDivider(
|
||||
@@ -433,6 +441,7 @@ fun RecentBillItem(
|
||||
getContactNameFromPhoneNumber: (String) -> String,
|
||||
isDeleteMenuButtonEnabled: Boolean,
|
||||
offerData: OfferData?,
|
||||
isPayNowClickExperimentEnabled: Boolean,
|
||||
) {
|
||||
Box(modifier = modifier) {
|
||||
Row(
|
||||
@@ -553,6 +562,38 @@ fun RecentBillItem(
|
||||
}
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
|
||||
if (myBillEntity.isBillPaid) {
|
||||
Row(
|
||||
modifier =
|
||||
Modifier.clip(RoundedCornerShape(4.dp))
|
||||
.clickableDebounce { onRecentBillItemClicked() }
|
||||
.border(
|
||||
width = 1.dp,
|
||||
color = NaviBbpsColor.ctaPrimary,
|
||||
shape = RoundedCornerShape(4.dp),
|
||||
)
|
||||
.background(
|
||||
color =
|
||||
if (isPayNowClickExperimentEnabled) NaviBbpsColor.ctaPrimary
|
||||
else NaviBbpsColor.ctaWhite,
|
||||
shape = RoundedCornerShape(4.dp),
|
||||
)
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
) {
|
||||
NaviText(
|
||||
text = myBillEntity.nextActionCtaText,
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 18.sp,
|
||||
fontFamily = naviFontFamily,
|
||||
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD),
|
||||
color =
|
||||
if (isPayNowClickExperimentEnabled) NaviBbpsColor.textWhite
|
||||
else NaviBbpsColor.textLinkAndCta,
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
}
|
||||
Image(
|
||||
painter = painterResource(id = CommonR.drawable.ic_three_dots_option_icon),
|
||||
contentDescription = stringResource(id = R.string.bbps_show_more),
|
||||
|
||||
@@ -564,7 +564,6 @@ private fun RenderPayBillDetailSectionOthers(
|
||||
placeholderIconResId = CommonR.drawable.navi_common_ic_biller_placeholder,
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
|
||||
if (billDetailsEntity?.accountHolderName.isNotNullAndNotEmpty()) {
|
||||
NaviText(
|
||||
text = billDetailsEntity?.accountHolderName.orEmpty(),
|
||||
|
||||
Reference in New Issue
Block a user