NTP-13572 | Mehul | Coin util annotated null handling (#13696)

Co-authored-by: shaurya-rehan <shaurya.rehan@navi.com>
This commit is contained in:
Mehul Garg
2024-11-20 17:38:08 +05:30
committed by GitHub
parent 68cec34277
commit 24e189f3f4

View File

@@ -36,6 +36,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.constraintlayout.compose.ConstraintLayout
import com.navi.base.utils.EMPTY
import com.navi.base.utils.orZero
import com.navi.bbps.R
import com.navi.bbps.common.NAVI_BBPS_MAX_COIN_EARN
import com.navi.bbps.common.theme.NaviBbpsColor
@@ -164,17 +165,22 @@ fun additionalInfo(): AnnotatedString {
val wordToHighlight = stringResource(id = R.string.bbps_rupee_zero)
append(fullText)
addStyle(
style =
SpanStyle(
color = NaviBbpsColor.textSecondary,
fontFamily = ttComposeFontFamily,
fontSize = 12.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = fullText.indexOf(wordToHighlight),
end = fullText.indexOf(wordToHighlight) + wordToHighlight.length
)
val start = fullText.indexOf(wordToHighlight)
val end = start + wordToHighlight.length
if (start >= 0 && end <= fullText.length) {
addStyle(
style =
SpanStyle(
color = NaviBbpsColor.textSecondary,
fontFamily = ttComposeFontFamily,
fontSize = 12.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = start,
end = end
)
}
}
return descriptionText
}
@@ -308,7 +314,10 @@ fun rewardBurnCalloutDescription(rewardsDetails: RewardDataEntity): AnnotatedStr
)
append(fullText)
if (fullText != null) {
val start = fullText?.indexOf(wordToHighlight).orZero()
val end = start + wordToHighlight.length
if (fullText != null && start >= 0 && end <= fullText.length) {
addStyle(
style =
SpanStyle(
@@ -317,8 +326,8 @@ fun rewardBurnCalloutDescription(rewardsDetails: RewardDataEntity): AnnotatedStr
fontSize = 12.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = fullText.indexOf(wordToHighlight),
end = fullText.indexOf(wordToHighlight) + wordToHighlight.length
start = start,
end = end
)
}
}
@@ -470,17 +479,21 @@ fun burnNudgeTextWithDifferentStyle(rewardsDetails: RewardDataEntity): Annotated
)
.trim()
append(fullText)
addStyle(
style =
SpanStyle(
color = NaviBbpsColor.brandSecondaryGreen,
fontFamily = ttComposeFontFamily,
fontSize = 10.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = fullText.indexOf(wordToHighlight),
end = fullText.indexOf(wordToHighlight) + wordToHighlight.length
)
val start = fullText.indexOf(wordToHighlight)
val end = start + wordToHighlight.length
if (start >= 0 && end <= fullText.length) {
addStyle(
style =
SpanStyle(
color = NaviBbpsColor.brandSecondaryGreen,
fontFamily = ttComposeFontFamily,
fontSize = 10.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = start,
end = end
)
}
}
return burnNudgeText
}
@@ -575,17 +588,22 @@ fun earnStripTextWithDifferentStyle(rewardsDetails: RewardDataEntity): Annotated
val fullText = rewardsDetails.earnStripText
val wordToHighlight = stringResource(id = R.string.bbps_rupee_zero)
append(fullText)
addStyle(
style =
SpanStyle(
color = NaviBbpsColor.textWhite,
fontFamily = ttComposeFontFamily,
fontSize = 12.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = fullText.indexOf(wordToHighlight),
end = fullText.indexOf(wordToHighlight) + wordToHighlight.length
)
val start = fullText.indexOf(wordToHighlight)
val end = start + wordToHighlight.length
if (start >= 0 && end <= fullText.length) {
addStyle(
style =
SpanStyle(
color = NaviBbpsColor.textWhite,
fontFamily = ttComposeFontFamily,
fontSize = 12.sp,
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD)
),
start = start,
end = end
)
}
}
return burnNudgeText
}