@@ -2,6 +2,7 @@ package com.amrdeveloper.linkhub.ui.components
22
33import androidx.compose.animation.core.animateDpAsState
44import androidx.compose.foundation.background
5+ import androidx.compose.foundation.clickable
56import androidx.compose.foundation.layout.Arrangement
67import androidx.compose.foundation.layout.Box
78import androidx.compose.foundation.layout.Row
@@ -12,13 +13,15 @@ import androidx.compose.foundation.pager.PagerState
1213import androidx.compose.foundation.shape.CircleShape
1314import androidx.compose.runtime.Composable
1415import androidx.compose.runtime.getValue
16+ import androidx.compose.runtime.rememberCoroutineScope
1517import androidx.compose.ui.Alignment
1618import androidx.compose.ui.Modifier
1719import androidx.compose.ui.draw.clip
1820import androidx.compose.ui.graphics.Color
1921import androidx.compose.ui.res.colorResource
2022import androidx.compose.ui.unit.dp
2123import com.amrdeveloper.linkhub.R
24+ import kotlinx.coroutines.launch
2225
2326@Composable
2427fun PagerIndicator (
@@ -27,6 +30,7 @@ fun PagerIndicator(
2730 selectedIndicatorColor : Color = colorResource(R .color.light_blue_200),
2831 unSelectedIndicatorColor : Color = colorResource(R .color.light_blue_900),
2932) {
33+ val coroutineScope = rememberCoroutineScope()
3034 Row (
3135 modifier = modifier
3236 .fillMaxWidth()
@@ -40,7 +44,7 @@ fun PagerIndicator(
4044 else unSelectedIndicatorColor
4145
4246 val size by animateDpAsState(
43- targetValue = if (isCurrentPage) 10 .dp else 8 .dp, label = " Indicator dor color "
47+ targetValue = if (isCurrentPage) 10 .dp else 8 .dp, label = " Indicator dot size "
4448 )
4549
4650 Box (
@@ -49,7 +53,12 @@ fun PagerIndicator(
4953 .clip(CircleShape )
5054 .background(indicatorColor)
5155 .size(size)
56+ .clickable {
57+ coroutineScope.launch {
58+ pagerState.animateScrollToPage(iteration)
59+ }
60+ }
5261 )
5362 }
5463 }
55- }
64+ }
0 commit comments