NTP-45915 | RCBP | One-CC Fixes & Refactoring (#15853)

This commit is contained in:
Shivam Goyal
2025-04-18 15:51:59 +05:30
committed by GitHub
parent d0ce68c4dd
commit 7b3cc96fdb
6 changed files with 109 additions and 176 deletions

View File

@@ -1283,54 +1283,6 @@ class NaviBbpsAnalytics private constructor() {
),
)
}
fun onAppliedDiscountClicked(
offerDataList: List<OfferData>?,
source: String,
initialSource: String,
coinBurnData: CoinBurnData?,
sessionAttribute: Map<String, String>,
billCategoryEntity: BillCategoryEntity,
) {
NaviTrackEvent.trackEventOnClickStream(
eventName = "NaviBBPS_Bill_AppliedDiscount_Clicked",
eventValues =
mapOf(
NAVI_BBPS_COIN_CALLOUT_VISIBLE to
isEligibleForCoinBurn(coinBurnData).toString(),
NAVI_BBPS_OFFER_LIST_SIZE to offerDataList?.size.toString(),
NAVI_BBPS_SESSION_ID to sessionAttribute[NAVI_BBPS_SESSION_ID].orEmpty(),
NAVI_BBPS_SOURCE to source,
NAVI_BBPS_INITIAL_SOURCE to initialSource,
NAVI_BBPS_CATEGORY_NAME to billCategoryEntity.title,
NAVI_BBPS_CATEGORY_ID to billCategoryEntity.categoryId,
),
)
}
fun onRemoveDiscountClicked(
offerDataList: List<OfferData>?,
source: String,
initialSource: String,
coinBurnData: CoinBurnData?,
sessionAttribute: Map<String, String>,
billCategoryEntity: BillCategoryEntity,
) {
NaviTrackEvent.trackEventOnClickStream(
eventName = "NaviBBPS_Bill_RemoveDiscount_Clicked",
eventValues =
mapOf(
NAVI_BBPS_COIN_CALLOUT_VISIBLE to
isEligibleForCoinBurn(coinBurnData).toString(),
NAVI_BBPS_OFFER_LIST_SIZE to offerDataList?.size.toString(),
NAVI_BBPS_SESSION_ID to sessionAttribute[NAVI_BBPS_SESSION_ID].orEmpty(),
NAVI_BBPS_SOURCE to source,
NAVI_BBPS_INITIAL_SOURCE to initialSource,
NAVI_BBPS_CATEGORY_NAME to billCategoryEntity.title,
NAVI_BBPS_CATEGORY_ID to billCategoryEntity.categoryId,
),
)
}
}
inner class ContactList {

View File

@@ -269,7 +269,7 @@ fun BottomSheetContentWithIconHeaderPrimarySecondaryButton(
) {
Image(
painter = painterResource(id = iconId),
modifier = Modifier.size(20.dp),
modifier = Modifier.size(24.dp),
contentDescription = null,
)

View File

@@ -650,7 +650,7 @@ fun PayBillScreen(
Modifier.fillMaxSize()
.verticalScroll(state = scrollState)
.background(NaviBbpsColor.textWhite)
.padding(bottom = 108.dp, start = 16.dp, end = 16.dp)
.padding(horizontal = 16.dp)
) {
if (isBillLoading)
if (isCreditCardCategory) RenderCreditCardPayBillScreenLoading()
@@ -896,6 +896,7 @@ fun RenderPayBillPrepaidBox(
Row(
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
NaviText(
text = stringResource(id = R.string.bbps_view_other_plans),
@@ -905,15 +906,14 @@ fun RenderPayBillPrepaidBox(
fontSize = 12.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD),
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(0.8f),
)
Spacer(modifier = Modifier.weight(1f))
Spacer(modifier = Modifier.width(16.dp))
Image(
painter = painterResource(id = R.drawable.ic_bbps_chevron_black_right),
contentDescription = "",
modifier = Modifier.size(24.dp),
modifier = Modifier.size(24.dp).weight(weight = 1f, fill = false),
)
}
}

View File

@@ -42,6 +42,7 @@ import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.navi.base.utils.EMPTY
import com.navi.base.utils.SPACE
import com.navi.bbps.R
import com.navi.bbps.common.ACTION_CIRCLE_OPERATOR_SELECTION
import com.navi.bbps.common.DASH
@@ -198,8 +199,6 @@ fun PrepaidRechargeScreen(
LaunchedEffect(bottomSheetState.currentValue) {
scope.launch {
// If there is nothing in screen i.e. no plans, then navigate back on bottom sheet
// close.
delay(50)
if (bottomSheetState.currentValue == ModalBottomSheetValue.Hidden) {
if (
@@ -212,24 +211,12 @@ fun PrepaidRechargeScreen(
}
}
LaunchedEffect(bottomSheetState.currentValue) {
delay(50)
if (bottomSheetState.currentValue == ModalBottomSheetValue.Hidden) {
val isPlanListEmpty =
prepaidRechargeState is PrepaidRechargeState.Loaded &&
(prepaidRechargeState as PrepaidRechargeState.Loaded).planGroups.isEmpty()
if (isPlanListEmpty) {
onBackClick()
}
}
}
LaunchedEffect(Unit) {
prepaidRechargeViewModel.fetchOffersAndCoinBurnForProduct(
attributes = mapOf(RCBP_CATEGORY to billCategoryEntity.categoryId)
)
}
BackHandler { onBackClick() }
LaunchedEffect(Unit) {
@@ -362,15 +349,11 @@ fun PrepaidRechargeScreen(
offerData = it,
coinBurnData = coinBurnData,
offerListHeading =
if (it.size == 1) {
it.size.toString() + " " + billCategoryEntity.title + " offer"
} else {
it.size.toString() + " " + billCategoryEntity.title + " offers"
},
// had to hardcode text as this is not composable function so cannot use
// string
// resource,
// also this is not in vm so resourceProvider cannot be used
it.size.toString() +
SPACE +
billCategoryEntity.title +
SPACE +
if (it.size == 1) "offer" else "offers",
),
)
}
@@ -447,11 +430,11 @@ fun PrepaidRechargeScreen(
NaviBbpsHeader(
title =
if (isScrolledFromTop) {
"${phoneNumberDetail.name} $DASH ${
getNormalisedPhoneNumber(
phoneNumberDetail.phoneNumber
)
}"
phoneNumberDetail.name +
SPACE +
DASH +
SPACE +
getNormalisedPhoneNumber(phoneNumberDetail.phoneNumber)
} else stringResource(id = R.string.bbps_select_recharge_plan),
modifier = Modifier.padding(horizontal = 0.dp),
onNavigationIconClick = { navigator.navigateUp() },
@@ -476,59 +459,56 @@ fun PrepaidRechargeScreen(
RenderPrepaidRechargeShimmerScreen()
}
is PrepaidRechargeState.Loaded -> {
when (
if (
(prepaidRechargeState as PrepaidRechargeState.Loaded)
.planGroups
.isNotEmpty()
) {
true -> {
Box(modifier = Modifier.fillMaxSize()) {
RenderPrepaidRechargeScreen(
focusManager = focusManager,
prepaidRechargeState =
prepaidRechargeState as PrepaidRechargeState.Loaded,
searchQuery = searchQuery,
isTrailingIconEnabled = isTrailingIconEnabled,
onTrailingIconClicked = onTrailingIconClicked,
isSearchQueryEmpty = isSearchQueryEmpty,
phoneNumberDetail = phoneNumberDetail,
selectedCircleEntity = selectedCircleEntity,
selectedOperatorEntity = selectedOperatorEntity,
updateSearchQueryStringState =
prepaidRechargeViewModel::updateSearchQueryStringState,
onPlanSelected = {
focusManager.clearFocus(force = true)
naviBbpsAnalytics.onPlanSelected(
planItemEntity = it,
searchQuery = searchQuery,
sessionAttribute =
prepaidRechargeViewModel
.getNaviBbpsSessionAttributes(),
source = source,
initialSource = initialSource,
)
prepaidRechargeViewModel.onPlanItemSelected(it)
},
rechargePlansState = rechargePlansState,
naviBbpsDefaultConfig =
prepaidRechargeViewModel.naviBbpsDefaultConfig,
naviBbpsAnalytics = naviBbpsAnalytics,
sessionAttribute =
prepaidRechargeViewModel.getNaviBbpsSessionAttributes(),
source = source,
initialSource = initialSource,
onManuallySelectOperatorCircleClicked =
onManuallySelectOperatorCircleClicked,
onPlansListScrolled = onPlansListScrolled,
onOfferRolodexClicked = onOfferRolodexClicked,
isScrolledFromTop = isScrolledFromTop,
offerData = offerDataList,
coinBurnData = coinBurnData,
isPlanSelectedLoaderVisible = isPlanSelectedLoaderVisible,
)
}
Box(modifier = Modifier.fillMaxSize()) {
RenderPrepaidRechargeScreen(
focusManager = focusManager,
prepaidRechargeState =
prepaidRechargeState as PrepaidRechargeState.Loaded,
searchQuery = searchQuery,
isTrailingIconEnabled = isTrailingIconEnabled,
onTrailingIconClicked = onTrailingIconClicked,
isSearchQueryEmpty = isSearchQueryEmpty,
phoneNumberDetail = phoneNumberDetail,
selectedCircleEntity = selectedCircleEntity,
selectedOperatorEntity = selectedOperatorEntity,
updateSearchQueryStringState =
prepaidRechargeViewModel::updateSearchQueryStringState,
onPlanSelected = {
focusManager.clearFocus(force = true)
naviBbpsAnalytics.onPlanSelected(
planItemEntity = it,
searchQuery = searchQuery,
sessionAttribute =
prepaidRechargeViewModel
.getNaviBbpsSessionAttributes(),
source = source,
initialSource = initialSource,
)
prepaidRechargeViewModel.onPlanItemSelected(it)
},
rechargePlansState = rechargePlansState,
naviBbpsDefaultConfig =
prepaidRechargeViewModel.naviBbpsDefaultConfig,
naviBbpsAnalytics = naviBbpsAnalytics,
sessionAttribute =
prepaidRechargeViewModel.getNaviBbpsSessionAttributes(),
source = source,
initialSource = initialSource,
onManuallySelectOperatorCircleClicked =
onManuallySelectOperatorCircleClicked,
onPlansListScrolled = onPlansListScrolled,
onOfferRolodexClicked = onOfferRolodexClicked,
isScrolledFromTop = isScrolledFromTop,
offerData = offerDataList,
coinBurnData = coinBurnData,
isPlanSelectedLoaderVisible = isPlanSelectedLoaderVisible,
)
}
else -> {}
}
}
else -> {}
@@ -582,7 +562,7 @@ private fun PlanDisclaimer(
modifier =
Modifier.fillMaxWidth()
.background(color = NaviBbpsColor.bgAlt2)
.padding(top = 8.dp, bottom = 16.dp, start = 16.dp, end = 16.dp),
.padding(horizontal = 16.dp, vertical = 8.dp),
text = annotatedString,
lineHeight = 18.sp,
)

View File

@@ -65,6 +65,7 @@ import androidx.compose.ui.unit.sp
import com.google.accompanist.pager.ExperimentalPagerApi
import com.google.accompanist.pager.HorizontalPager
import com.google.accompanist.pager.rememberPagerState
import com.navi.base.utils.SPACE
import com.navi.bbps.R
import com.navi.bbps.common.BULLET
import com.navi.bbps.common.DASH
@@ -234,9 +235,8 @@ fun RenderPrepaidRechargeScreen(
) {
if (isSearchQueryEmpty) {
ScrollableTabRow(
edgePadding = 0.dp,
edgePadding = 16.dp,
selectedTabIndex = 2 * pagerState.currentPage,
modifier = Modifier.padding(horizontal = 16.dp),
containerColor = NaviBbpsColor.transparent,
indicator = { tabPositions ->
TabIndicator(
@@ -285,15 +285,13 @@ fun RenderPrepaidRechargeScreen(
fontSize = 16.sp,
fontFamily = naviFontFamily,
fontWeight =
if (tabIndex == pagerState.currentPage) {
getFontWeight(
getFontWeight(
if (tabIndex == pagerState.currentPage) {
FontWeightEnum.NAVI_BODY_DEMI_BOLD
)
} else {
getFontWeight(
} else {
FontWeightEnum.NAVI_HEADLINE_REGULAR
)
},
}
),
color =
if (tabIndex == pagerState.currentPage) {
NaviBbpsColor.ctaPrimary
@@ -304,6 +302,7 @@ fun RenderPrepaidRechargeScreen(
)
Spacer(modifier = Modifier.height(4.dp))
}
if (tabIndex != pagerState.pageCount - 1) {
Spacer(modifier = Modifier.size(24.dp))
}
@@ -311,6 +310,7 @@ fun RenderPrepaidRechargeScreen(
}
Spacer(modifier = Modifier.height(24.dp))
if (isScrolledFromTop) {
ShadowStrip()
}
@@ -341,30 +341,31 @@ fun RenderPrepaidRechargeScreen(
Modifier.fillMaxSize().padding(horizontal = 8.dp),
userScrollEnabled = !pagerState.isScrollInProgress,
) {
when (pagerState.currentPage) {
in 0 until prepaidRechargeState.planGroups.size -> {
val selectedTabPlans =
prepaidRechargeState.planGroups[
pagerState.currentPage]
.plans
items(selectedTabPlans.size) { index ->
val plan = selectedTabPlans[index]
PlanItemBoxWithDivider(
naviBbpsAnalytics = naviBbpsAnalytics,
onPlanSelected = onPlanSelected,
plan = plan,
naviBbpsDefaultConfig =
naviBbpsDefaultConfig,
textWidth = textWidth,
sessionAttribute = sessionAttribute,
source = source,
initialSource = initialSource,
isScrollInProgress =
scrollState.isScrollInProgress,
isPlanSelectedLoaderVisible =
isPlanSelectedLoaderVisible,
)
}
if (
pagerState.currentPage in
0 until prepaidRechargeState.planGroups.size
) {
val selectedTabPlans =
prepaidRechargeState.planGroups[
pagerState.currentPage]
.plans
items(selectedTabPlans.size) { index ->
val plan = selectedTabPlans[index]
PlanItemBoxWithDivider(
naviBbpsAnalytics = naviBbpsAnalytics,
onPlanSelected = onPlanSelected,
plan = plan,
naviBbpsDefaultConfig = naviBbpsDefaultConfig,
textWidth = textWidth,
sessionAttribute = sessionAttribute,
source = source,
initialSource = initialSource,
isScrollInProgress =
scrollState.isScrollInProgress,
isPlanSelectedLoaderVisible =
isPlanSelectedLoaderVisible,
)
}
}
}
@@ -393,6 +394,7 @@ fun RenderPrepaidRechargeScreen(
} else {
prepaidRechargeState.planGroups.forEachIndexed { _, group ->
val plans = group.plans
items(plans.size) { planIndex ->
val plan = plans[planIndex]
PlanItemBoxWithDivider(
@@ -419,8 +421,8 @@ fun RenderPrepaidRechargeScreen(
}
is RechargePlansState.EmptyError -> {
RenderPrepaidRechargePlansEmptyScreen(
naviBbpsAnalytics,
"errorState",
naviBbpsAnalytics = naviBbpsAnalytics,
source = "errorState",
sessionAttribute = sessionAttribute,
initialSource = initialSource,
)
@@ -451,24 +453,23 @@ private fun ContactSelectedDetailsSection(
Column(modifier = Modifier.fillMaxWidth()) {
Row(modifier = Modifier.fillMaxWidth()) {
NaviText(
modifier = Modifier.widthIn(max = 130.dp),
text = phoneNumberDetail.name,
fontFamily = naviFontFamily,
fontWeight = getFontWeight(FontWeightEnum.NAVI_HEADLINE_REGULAR),
fontSize = 14.sp,
lineHeight = 22.sp,
color = NaviBbpsColor.textSecondary,
overflow = TextOverflow.Ellipsis,
lineHeight = 22.sp,
modifier = Modifier.widthIn(max = 130.dp),
maxLines = 1,
)
NaviText(
text =
" $DASH ${
getNormalisedPhoneNumber(
phoneNumberDetail.phoneNumber
)
}",
SPACE +
DASH +
SPACE +
getNormalisedPhoneNumber(phoneNumberDetail.phoneNumber),
fontFamily = naviFontFamily,
fontWeight = getFontWeight(FontWeightEnum.NAVI_HEADLINE_REGULAR),
fontSize = 14.sp,

View File

@@ -81,7 +81,7 @@
<string name="bbps_transaction_details">Bill payment details</string>
<string name="bbps_rupee_symbol_x">₹%s</string>
<string name="bbps_rupee_symbol"></string>
<string name="bbps_consumer_name">Consumer name</string>
<string name="bbps_consumer_name">Consumer name</string>
<string name="bbps_bill_number">Bill number</string>
<string name="bbps_bill_id">Bill ID</string>
<string name="bbps_bill_date">Bill date</string>
@@ -136,8 +136,8 @@
<string name="bbps_add_your_first_bill">Add your bill</string>
<string name="bbps_searching">Searching…</string>
<string name="bbps_paid">Paid</string>
<string name="bbps_recharge_plan_disclaimer_text">Disclaimer- We support most of the recharges, but please check with your operator before you proceed</string>
<string name="bbps_disclaimer_with_dash">Disclaimer-</string>
<string name="bbps_recharge_plan_disclaimer_text">Disclaimer - We support most of the recharges, but please check with your operator before you proceed.</string>
<string name="bbps_disclaimer_with_dash">Disclaimer -</string>
<string name="bbps_view_contacts">View contacts</string>
<string name="bbps_recents">Recents</string>
<string name="bbps_recent_recharges">Recent recharges</string>