neumorphic-compose icon indicating copy to clipboard operation
neumorphic-compose copied to clipboard

Using it in Pager causes the slide to lag, I don't understand what's happening

Open hurist opened this issue 4 years ago • 4 comments

Hi! I'm using it in Pager and it causes sliding jams, I don't understand what's happening

hurist avatar Oct 12 '21 05:10 hurist

Hi, Could you please share a video or your code snippet reproducing the issue? It would help to understand me better Thanks.

CuriousNikhil avatar Oct 12 '21 05:10 CuriousNikhil

A simple example I wrote, here is the code

@OptIn(ExperimentalPagerApi::class)
@Composable
fun GuideScreen() {
    Column {
        val pagerState = rememberPagerState()
        HorizontalPager(
            count = 6,
            state = pagerState,
            modifier = Modifier.fillMaxHeight(),
        ) { page ->
            ExamplePage(page)
        }
    }
}

@Composable
fun ExamplePage(currentPage: Int) {
    Card(
        elevation = 0.dp,
        shape = RoundedCornerShape(20.dp),
        backgroundColor = MaterialTheme.colors.backgroundColor,
        modifier = Modifier
            .padding(horizontal = 20.dp, vertical = 28.dp)
            .neumorphic(neuShape = Punched.Rounded(20.dp))
    ) {
        Box(contentAlignment = Alignment.Center) {
            Image(
                painter = painterResource(id = R.drawable.ic_launcher_foreground),
                contentDescription = "",
                modifier = Modifier
                    .fillMaxWidth()
                    .wrapContentHeight()
                    .padding(5.dp)
                    .clip(
                        RoundedCornerShape(20.dp)
                    ),
                contentScale = ContentScale.FillWidth
            )

            Text(
                text = "Page $currentPage",
                fontSize = 40.sp,
                textAlign = TextAlign.Center,
            )
        }

    }
}

Here is the actual effect link

hurist avatar Oct 12 '21 06:10 hurist

I used this library Pager Layout @CuriousNikhil

hurist avatar Oct 12 '21 06:10 hurist

@hurist, Thanks for sharing. I'll take a look. Meanwhile, if you figure it out, I would be happy to appreciate PR.

CuriousNikhil avatar Oct 13 '21 05:10 CuriousNikhil