NTP-48744 | Transaction history fix (#15759)
Co-authored-by: Shaurya Rehan <shaurya.rehan@navi.com>
This commit is contained in:
@@ -1843,6 +1843,7 @@ fun EmptyDataScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
@DrawableRes iconResId: Int,
|
||||
title: String? = null,
|
||||
verticalBias: Float = 0.4f,
|
||||
description: String? = null,
|
||||
titleFontSize: TextUnit = 14.sp,
|
||||
titleFontWeight: FontWeightEnum = FontWeightEnum.NAVI_BODY_REGULAR,
|
||||
@@ -1857,7 +1858,7 @@ fun EmptyDataScreen(
|
||||
modifier =
|
||||
Modifier.constrainAs(image) {
|
||||
centerHorizontallyTo(parent)
|
||||
centerVerticallyTo(parent, 0.4f)
|
||||
centerVerticallyTo(parent, verticalBias)
|
||||
}
|
||||
.layoutId(image),
|
||||
)
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.pay.management.transactionhistory.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.navi.common.R as CommonR
|
||||
import com.navi.pay.R
|
||||
import com.navi.pay.common.ui.NaviPayHeader
|
||||
import com.navi.pay.utils.shimmerEffect
|
||||
|
||||
@Composable
|
||||
fun PayeeLevelTransactionHistoryShimmer(onBackClick: () -> Unit) {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
NaviPayHeader(
|
||||
navigationIcon = CommonR.drawable.ic_arrow_left_black_v2,
|
||||
title = stringResource(id = R.string.np_view_history),
|
||||
onNavigationIconClick = onBackClick,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
repeat(times = 9) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp)
|
||||
.height(68.dp)
|
||||
.shimmerEffect()
|
||||
)
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
@@ -119,7 +120,6 @@ import com.navi.pay.destinations.OrderDetailsScreenDestination
|
||||
import com.navi.pay.entry.NaviPayActivity
|
||||
import com.navi.pay.management.common.sendmoney.model.view.PayeeTransactionHistoryEntity
|
||||
import com.navi.pay.management.transactionhistory.model.view.TransactionTagHolder
|
||||
import com.navi.pay.management.transactionhistory.ui.PayeeLevelTransactionHistoryShimmer
|
||||
import com.navi.pay.management.transactionhistory.ui.TransactionHistoryShimmer
|
||||
import com.navi.pay.tstore.list.model.view.OrderHistoryBottomSheetType
|
||||
import com.navi.pay.tstore.list.model.view.UpiSpendAnalyzerInfoBottomSheetData
|
||||
@@ -321,6 +321,10 @@ fun OrderHistoryScreenContent(
|
||||
val orderHistoryItems = orderHistoryViewModel.orderHistoryPager.collectAsLazyPagingItems()
|
||||
val orderHistoryItemsListState = rememberLazyListState()
|
||||
|
||||
LaunchedEffect(orderHistoryItems.loadState.refresh) {
|
||||
isLoading = orderHistoryItems.loadState.refresh is LoadState.Loading
|
||||
}
|
||||
|
||||
val showBottomBarBasedOnItemCount by
|
||||
remember(orderHistoryItems) {
|
||||
derivedStateOf {
|
||||
@@ -363,7 +367,7 @@ fun OrderHistoryScreenContent(
|
||||
|
||||
val onFilterOptionClicked = {
|
||||
keyboardController?.customHide(context = context, view = view)
|
||||
if (searchQuery.isEmpty()) {
|
||||
if (searchQuery.text.isEmpty()) {
|
||||
orderHistoryViewModel.updateEnabledStateForTags()
|
||||
}
|
||||
orderHistoryViewModel.updateSelectedTabIndex(selectedIndex = MONTHS_FILTER_TAB_INDEX)
|
||||
@@ -410,11 +414,6 @@ fun OrderHistoryScreenContent(
|
||||
}
|
||||
|
||||
if (
|
||||
payeeTransactionHistoryEntity?.isPayeeLevelTransactionHistory == true &&
|
||||
orderHistoryItems.loadState.refresh is LoadState.Loading
|
||||
) {
|
||||
PayeeLevelTransactionHistoryShimmer(onBackClick = navigateBack)
|
||||
} else if (
|
||||
payeeTransactionHistoryEntity?.isPayeeLevelTransactionHistory == true &&
|
||||
orderHistoryItems.isEmpty() &&
|
||||
!isAnyTagActive &&
|
||||
@@ -458,7 +457,7 @@ fun OrderHistoryScreenContent(
|
||||
NaviPayHeader(
|
||||
navigationIcon = CommonR.drawable.ic_arrow_left_black_v2,
|
||||
title =
|
||||
if (!isHeaderTitleVisible) {
|
||||
if (!(isHeaderTitleVisible)) {
|
||||
stringResource(
|
||||
id =
|
||||
if (
|
||||
@@ -476,275 +475,266 @@ fun OrderHistoryScreenContent(
|
||||
}
|
||||
},
|
||||
content = { padding ->
|
||||
Box(modifier = Modifier.padding(padding).fillMaxSize()) {
|
||||
if (orderHistoryItems.isEmpty()) {
|
||||
|
||||
EmptyDataScreen(
|
||||
iconResId = R.drawable.ic_empty_transaction_list_screen,
|
||||
title =
|
||||
stringResource(id = R.string.np_transaction_list_empty_title),
|
||||
titleFontSize = 16.sp,
|
||||
titleFontWeight =
|
||||
if (!isFilterTagActive && (searchQuery.isEmpty())) {
|
||||
FontWeightEnum.NAVI_BODY_DEMI_BOLD
|
||||
} else {
|
||||
FontWeightEnum.NAVI_BODY_REGULAR
|
||||
},
|
||||
titleFontColor =
|
||||
if (!isFilterTagActive && (searchQuery.isEmpty())) {
|
||||
NaviPayColor.textSecondary
|
||||
} else {
|
||||
NaviPayColor.inputFieldDefault
|
||||
},
|
||||
description =
|
||||
if (!isFilterTagActive && (searchQuery.isEmpty())) {
|
||||
stringResource(
|
||||
id = R.string.np_transaction_list_empty_description
|
||||
)
|
||||
} else null,
|
||||
)
|
||||
} else {
|
||||
LaunchedEffect(orderHistoryItems.loadState.refresh) {
|
||||
isLoading = orderHistoryItems.loadState.refresh is LoadState.Loading
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(padding).fillMaxSize(),
|
||||
flingBehavior = maxScrollFlingBehavior(),
|
||||
state = orderHistoryItemsListState,
|
||||
userScrollEnabled = !orderHistoryItems.isEmpty(),
|
||||
) {
|
||||
item { // Fix laggy animateScrollToItem by using workaround
|
||||
// suggested in https://youtrack.jetbrains.com/issue/CMP-6937
|
||||
Spacer(modifier = Modifier.height(0.dp))
|
||||
}
|
||||
if (!isFromHomeBottomBar) {
|
||||
item(key = headerTitleComposableKey) {
|
||||
HeaderTitleComposable(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
payeeTransactionHistoryEntity = payeeTransactionHistoryEntity,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
flingBehavior = maxScrollFlingBehavior(),
|
||||
state = orderHistoryItemsListState,
|
||||
) {
|
||||
item { // Fix laggy animateScrollToItem by using workaround
|
||||
// suggested in https://youtrack.jetbrains.com/issue/CMP-6937
|
||||
Spacer(modifier = Modifier.height(0.dp))
|
||||
}
|
||||
if (!isFromHomeBottomBar) {
|
||||
item(key = headerTitleComposableKey) {
|
||||
HeaderTitleComposable(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
payeeTransactionHistoryEntity =
|
||||
payeeTransactionHistoryEntity,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
if (payeeTransactionHistoryEntity == null) {
|
||||
stickyHeader {
|
||||
NaviPayCard(
|
||||
}
|
||||
if (payeeTransactionHistoryEntity == null) {
|
||||
stickyHeader {
|
||||
NaviPayCard(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().conditional(!isHeaderTitleVisible) {
|
||||
shadow(
|
||||
elevation = 32.dp,
|
||||
shape = RoundedCornerShape(0.dp),
|
||||
ambientColor = NaviPayColor.gray,
|
||||
spotColor = NaviPayColor.gray,
|
||||
)
|
||||
},
|
||||
elevation = 0.dp,
|
||||
shadowElevation = 0.dp,
|
||||
) {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.background(NaviPayColor.bgDefault)
|
||||
) {
|
||||
if (isFromHomeBottomBar) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
HeaderTitleComposable(
|
||||
modifier = Modifier.padding(horizontal = 16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
SearchAndFilterSection(
|
||||
searchQuery = searchQuery,
|
||||
onSearchQueryChange =
|
||||
orderHistoryViewModel::updateSearchQuery,
|
||||
onFilterOptionClicked = onFilterOptionClicked,
|
||||
isFilterTagActive = isFilterTagActive,
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().conditional(
|
||||
!isHeaderTitleVisible
|
||||
) {
|
||||
shadow(
|
||||
elevation = 32.dp,
|
||||
shape = RoundedCornerShape(0.dp),
|
||||
ambientColor = NaviPayColor.gray,
|
||||
spotColor = NaviPayColor.gray,
|
||||
)
|
||||
},
|
||||
elevation = 0.dp,
|
||||
shadowElevation = 0.dp,
|
||||
) {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.background(NaviPayColor.bgDefault)
|
||||
) {
|
||||
if (isFromHomeBottomBar) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
HeaderTitleComposable(
|
||||
modifier =
|
||||
Modifier.padding(horizontal = 16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
SearchAndFilterSection(
|
||||
searchQuery = searchQuery,
|
||||
onSearchQueryChange =
|
||||
orderHistoryViewModel::updateSearchQuery,
|
||||
onFilterOptionClicked = onFilterOptionClicked,
|
||||
isFilterTagActive = isFilterTagActive,
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
isSearchBarActive = isSearchBarActive,
|
||||
onSearchBarClicked = {
|
||||
if (!isSearchBarActive) {
|
||||
orderHistoryViewModel
|
||||
.updateSearchBarState(
|
||||
searchBarActive = true
|
||||
)
|
||||
}
|
||||
},
|
||||
focusRequester = focusRequester,
|
||||
)
|
||||
if (isFilterTagActive) {
|
||||
RenderActiveFilterTags(
|
||||
tags = activeTagsHolder,
|
||||
onRemoveActiveTag = onRemoveActiveTag,
|
||||
Modifier.fillMaxWidth().padding(horizontal = 16.dp),
|
||||
isSearchBarActive = isSearchBarActive,
|
||||
onSearchBarClicked = {
|
||||
if (!isSearchBarActive) {
|
||||
orderHistoryViewModel.updateSearchBarState(
|
||||
searchBarActive = true
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
focusRequester = focusRequester,
|
||||
)
|
||||
if (isFilterTagActive) {
|
||||
RenderActiveFilterTags(
|
||||
tags = activeTagsHolder,
|
||||
onRemoveActiveTag = onRemoveActiveTag,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
items(
|
||||
count = orderHistoryItems.itemCount,
|
||||
key = orderHistoryItems.itemKey { it.orderReferenceId },
|
||||
) { index ->
|
||||
val transactionHistoryItem = orderHistoryItems[index]
|
||||
}
|
||||
}
|
||||
|
||||
var showDivider by remember {
|
||||
mutableStateOf(index != orderHistoryItems.itemCount - 1)
|
||||
}
|
||||
transactionHistoryItem?.let {
|
||||
val currentMonthYearDateAsString =
|
||||
if (orderHistoryItems.isEmpty()) {
|
||||
item {
|
||||
EmptyDataScreen(
|
||||
modifier = Modifier.fillParentMaxSize(),
|
||||
verticalBias = 0.3f,
|
||||
iconResId = R.drawable.ic_empty_transaction_list_screen,
|
||||
title =
|
||||
stringResource(
|
||||
id = R.string.np_transaction_list_empty_title
|
||||
),
|
||||
titleFontSize = 16.sp,
|
||||
titleFontWeight =
|
||||
if (!isFilterTagActive && (searchQuery.text.isEmpty())) {
|
||||
FontWeightEnum.NAVI_BODY_DEMI_BOLD
|
||||
} else {
|
||||
FontWeightEnum.NAVI_BODY_REGULAR
|
||||
},
|
||||
titleFontColor =
|
||||
if (!isFilterTagActive && (searchQuery.text.isEmpty())) {
|
||||
NaviPayColor.textSecondary
|
||||
} else {
|
||||
NaviPayColor.inputFieldDefault
|
||||
},
|
||||
description =
|
||||
if (!isFilterTagActive && (searchQuery.text.isEmpty())) {
|
||||
stringResource(
|
||||
id = R.string.np_transaction_list_empty_description
|
||||
)
|
||||
} else null,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
items(
|
||||
count = orderHistoryItems.itemCount,
|
||||
key = orderHistoryItems.itemKey { it.orderReferenceId },
|
||||
) { index ->
|
||||
val transactionHistoryItem = orderHistoryItems[index]
|
||||
|
||||
var showDivider by remember {
|
||||
mutableStateOf(index != orderHistoryItems.itemCount - 1)
|
||||
}
|
||||
transactionHistoryItem?.let {
|
||||
val currentMonthYearDateAsString =
|
||||
DateUtils.getFormattedDateTimeAsStringFromDateTimeObject(
|
||||
dateTime = transactionHistoryItem.orderTimestamp,
|
||||
format =
|
||||
DATE_TIME_FORMAT_MONTH_YEAR_WITH_SPACE_SEPARATOR,
|
||||
)
|
||||
if (index != orderHistoryItems.itemCount - 1) {
|
||||
|
||||
val nextTransactionMonthYearDateAsString =
|
||||
DateUtils
|
||||
.getFormattedDateTimeAsStringFromDateTimeObject(
|
||||
dateTime =
|
||||
transactionHistoryItem.orderTimestamp,
|
||||
orderHistoryItems[index + 1]?.orderTimestamp
|
||||
?: transactionHistoryItem
|
||||
.orderTimestamp,
|
||||
format =
|
||||
DATE_TIME_FORMAT_MONTH_YEAR_WITH_SPACE_SEPARATOR,
|
||||
)
|
||||
if (index != orderHistoryItems.itemCount - 1) {
|
||||
|
||||
val nextTransactionMonthYearDateAsString =
|
||||
DateUtils
|
||||
.getFormattedDateTimeAsStringFromDateTimeObject(
|
||||
dateTime =
|
||||
orderHistoryItems[index + 1]
|
||||
?.orderTimestamp
|
||||
?: transactionHistoryItem
|
||||
.orderTimestamp,
|
||||
format =
|
||||
DATE_TIME_FORMAT_MONTH_YEAR_WITH_SPACE_SEPARATOR,
|
||||
)
|
||||
if (
|
||||
currentMonthYearDateAsString !=
|
||||
nextTransactionMonthYearDateAsString
|
||||
) {
|
||||
showDivider = false
|
||||
}
|
||||
if (
|
||||
currentMonthYearDateAsString !=
|
||||
nextTransactionMonthYearDateAsString
|
||||
) {
|
||||
showDivider = false
|
||||
}
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
if (index == 0) {
|
||||
NewMonthView(
|
||||
date = currentMonthYearDateAsString,
|
||||
amount =
|
||||
orderSummaryAmountMapData[
|
||||
transactionHistoryItem.monthTag],
|
||||
showMonthlySummaryAmount = showMonthlySummaryAmount,
|
||||
showInfoIcon =
|
||||
upiTxnHistorySpendAnalysisData != null &&
|
||||
upiSpendAnalysisWidgetVariant != CONTROL,
|
||||
) {
|
||||
upiTransactionHistorySpendAnalyserEventTracker
|
||||
.onMonthlyViewInfoIconClicked()
|
||||
orderHistoryViewModel.updateBottomSheetUiState(
|
||||
showBottomSheet = true,
|
||||
bottomSheetType =
|
||||
OrderHistoryBottomSheetType
|
||||
.UpiSpendAnalyzerInfo(
|
||||
UpiSpendAnalyzerInfoBottomSheetData(
|
||||
date = currentMonthYearDateAsString,
|
||||
amount =
|
||||
orderSummaryAmountMapData[
|
||||
transactionHistoryItem
|
||||
.monthTag],
|
||||
)
|
||||
),
|
||||
)
|
||||
}
|
||||
UpiSpendAnalysisWidget(
|
||||
data = upiTxnHistorySpendAnalysisData,
|
||||
variant = upiSpendAnalysisWidgetVariant,
|
||||
activity = activity,
|
||||
dismissWidget = {
|
||||
upiTransactionHistorySpendAnalyserEventTracker
|
||||
.onUpiSpendAnalyserWidgetCrossIconClicked()
|
||||
orderHistoryViewModel
|
||||
.dismissUpiSpendAnalysisWidget()
|
||||
},
|
||||
upiTransactionHistorySpendAnalyserEventTracker =
|
||||
upiTransactionHistorySpendAnalyserEventTracker,
|
||||
)
|
||||
} else {
|
||||
val previousMonthYearDateAsString =
|
||||
DateUtils
|
||||
.getFormattedDateTimeAsStringFromDateTimeObject(
|
||||
dateTime =
|
||||
orderHistoryItems[index - 1]?.orderTimestamp
|
||||
?: transactionHistoryItem
|
||||
.orderTimestamp,
|
||||
format =
|
||||
DATE_TIME_FORMAT_MONTH_YEAR_WITH_SPACE_SEPARATOR,
|
||||
)
|
||||
|
||||
if (
|
||||
previousMonthYearDateAsString !=
|
||||
currentMonthYearDateAsString
|
||||
) {
|
||||
NewMonthView(
|
||||
date = currentMonthYearDateAsString,
|
||||
amount =
|
||||
orderSummaryAmountMapData[
|
||||
transactionHistoryItem.monthTag],
|
||||
showMonthlySummaryAmount = showMonthlySummaryAmount,
|
||||
showInfoIcon =
|
||||
upiTxnHistorySpendAnalysisData != null &&
|
||||
upiSpendAnalysisWidgetVariant != CONTROL,
|
||||
) {
|
||||
upiTransactionHistorySpendAnalyserEventTracker
|
||||
.onMonthlyViewInfoIconClicked()
|
||||
orderHistoryViewModel.updateBottomSheetUiState(
|
||||
showBottomSheet = true,
|
||||
bottomSheetType =
|
||||
OrderHistoryBottomSheetType
|
||||
.UpiSpendAnalyzerInfo(
|
||||
UpiSpendAnalyzerInfoBottomSheetData(
|
||||
date =
|
||||
currentMonthYearDateAsString,
|
||||
amount =
|
||||
orderSummaryAmountMapData[
|
||||
transactionHistoryItem
|
||||
.monthTag],
|
||||
)
|
||||
),
|
||||
)
|
||||
}
|
||||
UpiSpendAnalysisWidget(
|
||||
data = upiTxnHistorySpendAnalysisData,
|
||||
variant = upiSpendAnalysisWidgetVariant,
|
||||
activity = activity,
|
||||
dismissWidget = {
|
||||
upiTransactionHistorySpendAnalyserEventTracker
|
||||
.onUpiSpendAnalyserWidgetCrossIconClicked()
|
||||
orderHistoryViewModel
|
||||
.dismissUpiSpendAnalysisWidget()
|
||||
},
|
||||
upiTransactionHistorySpendAnalyserEventTracker =
|
||||
upiTransactionHistorySpendAnalyserEventTracker,
|
||||
)
|
||||
} else {
|
||||
val previousMonthYearDateAsString =
|
||||
DateUtils
|
||||
.getFormattedDateTimeAsStringFromDateTimeObject(
|
||||
dateTime =
|
||||
orderHistoryItems[index - 1]
|
||||
?.orderTimestamp
|
||||
?: transactionHistoryItem
|
||||
.orderTimestamp,
|
||||
format =
|
||||
DATE_TIME_FORMAT_MONTH_YEAR_WITH_SPACE_SEPARATOR,
|
||||
)
|
||||
|
||||
if (
|
||||
previousMonthYearDateAsString !=
|
||||
currentMonthYearDateAsString
|
||||
) {
|
||||
NewMonthView(
|
||||
date = currentMonthYearDateAsString,
|
||||
amount =
|
||||
orderSummaryAmountMapData[
|
||||
transactionHistoryItem.monthTag],
|
||||
showMonthlySummaryAmount =
|
||||
showMonthlySummaryAmount,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
RenderOrderHistoryItemView(
|
||||
index = index,
|
||||
orderHistoryEntity = it,
|
||||
mandateTagEnabled = it.isOrderOfMandateType,
|
||||
onItemClicked = {
|
||||
orderHistoryViewModel.onTransactionItemClicked(
|
||||
orderHistoryEntity = it
|
||||
)
|
||||
naviPayAnalytics.onTransactionItemClicked(
|
||||
source = orderHistoryViewModel.screenSource
|
||||
)
|
||||
},
|
||||
coinsSavedMessage = coinsSavedMessage,
|
||||
upiAppLogoBaseUrl = upiAppLogoBaseUrl,
|
||||
vpaTpapMapping = vpaTpapMapping,
|
||||
showDivider = showDivider,
|
||||
cashToCoinsConversionAmount =
|
||||
cashToCoinsConversionAmount,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!showBottomBarBasedOnItemCount && (!isLoading)) {
|
||||
|
||||
item {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier.align(Alignment.BottomCenter)
|
||||
.padding(top = 24.dp, bottom = 40.dp)
|
||||
) {
|
||||
NaviPaySponsorView(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
when (orderHistoryItems.loadState.refresh) {
|
||||
is LoadState.Error -> {
|
||||
val errorState =
|
||||
(orderHistoryItems.loadState.refresh as LoadState.Error)
|
||||
errorState.notifyError(orderHistoryViewModel)
|
||||
}
|
||||
is LoadState.Loading -> {
|
||||
if (isLoading && orderHistoryItems.itemCount == 0) {
|
||||
item { TransactionHistoryShimmer() }
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
RenderOrderHistoryItemView(
|
||||
index = index,
|
||||
orderHistoryEntity = it,
|
||||
mandateTagEnabled = it.isOrderOfMandateType,
|
||||
onItemClicked = {
|
||||
orderHistoryViewModel.onTransactionItemClicked(
|
||||
orderHistoryEntity = it
|
||||
)
|
||||
naviPayAnalytics.onTransactionItemClicked(
|
||||
source = orderHistoryViewModel.screenSource
|
||||
)
|
||||
},
|
||||
coinsSavedMessage = coinsSavedMessage,
|
||||
upiAppLogoBaseUrl = upiAppLogoBaseUrl,
|
||||
vpaTpapMapping = vpaTpapMapping,
|
||||
showDivider = showDivider,
|
||||
cashToCoinsConversionAmount = cashToCoinsConversionAmount,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!showBottomBarBasedOnItemCount && (!isLoading)) {
|
||||
|
||||
item {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier.align(Alignment.BottomCenter)
|
||||
.padding(top = 24.dp, bottom = 40.dp)
|
||||
) {
|
||||
NaviPaySponsorView(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
when (orderHistoryItems.loadState.refresh) {
|
||||
is LoadState.Error -> {
|
||||
val errorState =
|
||||
(orderHistoryItems.loadState.refresh as LoadState.Error)
|
||||
errorState.notifyError(orderHistoryViewModel)
|
||||
}
|
||||
|
||||
is LoadState.Loading -> {
|
||||
if (isLoading && orderHistoryItems.itemCount == 0) {
|
||||
item { TransactionHistoryShimmer() }
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
},
|
||||
bottomBar = {
|
||||
@@ -828,8 +818,8 @@ private fun UpiSpendAnalysisWidget(
|
||||
|
||||
@Composable
|
||||
private fun SearchAndFilterSection(
|
||||
searchQuery: String,
|
||||
onSearchQueryChange: (String) -> Unit,
|
||||
searchQuery: TextFieldValue,
|
||||
onSearchQueryChange: (TextFieldValue) -> Unit,
|
||||
onFilterOptionClicked: () -> Unit,
|
||||
isFilterTagActive: Boolean,
|
||||
modifier: Modifier,
|
||||
@@ -883,8 +873,8 @@ private fun SearchAndFilterSection(
|
||||
onValueChangeListener = onSearchQueryChange,
|
||||
isLeadingIconEnabled = true,
|
||||
leadingIconId = CommonR.drawable.ic_search,
|
||||
isTrailingIconEnabled = searchQuery.isNotBlank(),
|
||||
onTrailingIconClicked = { onSearchQueryChange("") },
|
||||
isTrailingIconEnabled = searchQuery.text.isNotBlank(),
|
||||
onTrailingIconClicked = { onSearchQueryChange(TextFieldValue()) },
|
||||
placeHolderComposable = {
|
||||
NaviText(
|
||||
text =
|
||||
|
||||
@@ -14,6 +14,8 @@ package com.navi.pay.tstore.list.viewmodel
|
||||
*
|
||||
*/
|
||||
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.paging.Pager
|
||||
@@ -276,7 +278,7 @@ constructor(
|
||||
monthTagsHolder.map { list -> list.filter { it.isActive } }.distinctUntilChanged(),
|
||||
) { searchQuery, categoryTags, paymentModeTags, orderStatusTags, monthTags ->
|
||||
OrderHistorySearchHolder(
|
||||
searchQuery = "%${searchQuery.trim()}%",
|
||||
searchQuery = "%${searchQuery.text.trim()}%",
|
||||
categoryQueryList = getSearchQueryStringForActiveTags(tagList = categoryTags),
|
||||
paymentModeQueryList =
|
||||
getSearchQueryStringForActiveTags(tagList = paymentModeTags),
|
||||
@@ -357,7 +359,7 @@ constructor(
|
||||
isOnlyMonthTagActive ->
|
||||
// Either only month tag is active or no tag is active and search query is empty
|
||||
(!isAnyTagActive || isOnlyMonthTagActive) &&
|
||||
searchQuery.isBlank() &&
|
||||
searchQuery.text.isBlank() &&
|
||||
!isPayeeLevelTransactionHistory
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
@@ -422,7 +424,9 @@ constructor(
|
||||
// - Not in payee level transaction history mode.
|
||||
// - UPI spend analysis data has been synced at least once.
|
||||
val shouldShowEntrypoint =
|
||||
(!isAnyTagActive && searchQuery.isBlank() && !isPayeeLevelTransactionHistory) &&
|
||||
(!isAnyTagActive &&
|
||||
searchQuery.text.isBlank() &&
|
||||
!isPayeeLevelTransactionHistory) &&
|
||||
(upiSpendAnalysisFirstSyncCompleted || upiSpendAnalysisSyncCompleted)
|
||||
Pair(shouldShowEntrypoint, latestOrderTimestamp)
|
||||
}
|
||||
@@ -522,13 +526,16 @@ constructor(
|
||||
_isRefreshing.update { isRefreshing }
|
||||
}
|
||||
|
||||
private fun getDefaultSearchQuery(): String {
|
||||
return if (isPayeeLevelTransactionHistory) payeeTransactionHistoryEntity?.vpa ?: EMPTY
|
||||
else EMPTY
|
||||
private fun getDefaultSearchQuery(): TextFieldValue {
|
||||
val searchQueryText =
|
||||
if (isPayeeLevelTransactionHistory) payeeTransactionHistoryEntity?.vpa ?: EMPTY
|
||||
else EMPTY
|
||||
return TextFieldValue(text = searchQueryText, selection = TextRange(searchQueryText.length))
|
||||
}
|
||||
|
||||
fun updateSearchQuery(searchQuery: String) {
|
||||
_searchQuery.update { searchQuery.trimStart() }
|
||||
fun updateSearchQuery(searchQuery: TextFieldValue) {
|
||||
val searchQueryText = searchQuery.text
|
||||
_searchQuery.update { searchQuery.copy(text = searchQueryText.trimStart()) }
|
||||
}
|
||||
|
||||
fun updateSearchBarState(searchBarActive: Boolean) {
|
||||
@@ -690,7 +697,7 @@ constructor(
|
||||
fun onTransactionItemClicked(orderHistoryEntity: OrderHistoryEntity) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
_goToOrderDetailsScreen.emit(orderHistoryEntity.orderReferenceId)
|
||||
if (searchQuery.value.isBlank() && isSearchBarActive.value) {
|
||||
if (searchQuery.value.text.isBlank() && isSearchBarActive.value) {
|
||||
updateSearchBarState(searchBarActive = false)
|
||||
}
|
||||
}
|
||||
@@ -985,7 +992,7 @@ constructor(
|
||||
paymentModeQuery = paymentModeQuery,
|
||||
orderStatusQuery = orderStatusQuery,
|
||||
monthQuery = it,
|
||||
searchQuery = searchQuery.value,
|
||||
searchQuery = searchQuery.value.text,
|
||||
)
|
||||
}
|
||||
_monthTagsHolder.update { getUpdatedTagHolderForCountList(it, monthWiseCount) }
|
||||
@@ -1018,7 +1025,7 @@ constructor(
|
||||
paymentModeQuery = paymentModeQuery,
|
||||
orderStatusQuery = orderStatusQuery,
|
||||
monthQuery = monthQuery,
|
||||
searchQuery = searchQuery.value,
|
||||
searchQuery = searchQuery.value.text,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1057,7 +1064,7 @@ constructor(
|
||||
paymentModeQuery = it,
|
||||
orderStatusQuery = orderStatusQuery,
|
||||
monthQuery = monthQuery,
|
||||
searchQuery = searchQuery.value,
|
||||
searchQuery = searchQuery.value.text,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1096,7 +1103,7 @@ constructor(
|
||||
paymentModeQuery = paymentModeQuery,
|
||||
orderStatusQuery = it,
|
||||
monthQuery = monthQuery,
|
||||
searchQuery = searchQuery.value,
|
||||
searchQuery = searchQuery.value.text,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user