TP-63081 | Compose bom bugfix (#10333)

This commit is contained in:
Sangaraboina Rishvik Vardhan
2024-04-05 19:22:02 +05:30
committed by GitHub
parent e5c26baa74
commit 5fee265123
3 changed files with 17 additions and 5 deletions

View File

@@ -49,6 +49,8 @@ import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
@@ -516,7 +518,12 @@ fun Counter(countData: CounterDropDownData?, onSelection: (CounterDropDownData)
fontSize = 16.sp,
textAlign = TextAlign.Center,
fontFamily = ttComposeFontFamily,
fontWeight = FontWeight.Medium
fontWeight = FontWeight.Medium,
style = TextStyle(
platformStyle = PlatformTextStyle(
includeFontPadding = true
)
)
)
IconButton(
onClick = {

View File

@@ -213,3 +213,4 @@ const val COBALT_BLUE = "#002E8B"
const val DODGER_BLUE = "#3C7DFF"
const val PALE_BLUE = "#BED7FF"
const val LIGHT_PASTEL_BLUE = "#EAF2FF"
const val PRE_DIABETIC_CAROUSEL_CARD_COUNT = 20

View File

@@ -64,6 +64,7 @@ import com.navi.naviwidgets.models.response.AutoCarouselCardsPDWidget
import com.navi.naviwidgets.models.response.AutoCarouselCardsPDWidgetData
import com.navi.naviwidgets.models.response.TextFieldData
import com.navi.naviwidgets.utils.DEFAULT_CAROUSEL_TRANSITION_DELAY
import com.navi.naviwidgets.utils.PRE_DIABETIC_CAROUSEL_CARD_COUNT
import kotlin.math.abs
import kotlin.math.absoluteValue
import kotlinx.coroutines.delay
@@ -84,13 +85,15 @@ fun AutoCarouselPreDiabeticWidgetComposable(
val totalItems = data.widgetData?.carouselItems?.size ?: 0
Card(modifier = Modifier.fillMaxWidth().wrapContentHeight()) {
val currentPageIndex = remember { mutableIntStateOf(0) }
val startIndex = (Int.MAX_VALUE / 2 - ((Int.MAX_VALUE / 2) % (10 ?: 1)))
val startIndex =
(totalItems * PRE_DIABETIC_CAROUSEL_CARD_COUNT / 2 -
((totalItems * PRE_DIABETIC_CAROUSEL_CARD_COUNT / 2) % (10 ?: 1)))
val startIndexState = remember { mutableIntStateOf(startIndex) }
val pagerState =
rememberPagerState(
initialPage = startIndex,
initialPageOffsetFraction = 0f,
pageCount = { Int.MAX_VALUE },
pageCount = { totalItems * PRE_DIABETIC_CAROUSEL_CARD_COUNT },
)
val isDraggedState = pagerState.interactionSource.collectIsDraggedAsState()
LaunchedEffect(isDraggedState.value) {
@@ -102,7 +105,7 @@ fun AutoCarouselPreDiabeticWidgetComposable(
rememberPagerState(
initialPage = startIndex,
initialPageOffsetFraction = 0f,
pageCount = { Int.MAX_VALUE }
pageCount = { totalItems * PRE_DIABETIC_CAROUSEL_CARD_COUNT }
)
Column(
modifier =
@@ -203,7 +206,8 @@ internal fun AnimatedViewPager(
LaunchedEffect(autoCarouselEnabledState.value) {
while (autoCarouselEnabledState.value) {
delay(carouselTransitionDelay)
val nextPage = (pagerState.currentPage + 1) % (Int.MAX_VALUE)
val nextPage =
(pagerState.currentPage + 1) % (totalItems * PRE_DIABETIC_CAROUSEL_CARD_COUNT)
pagerState.animateScrollToPage(nextPage)
}
}