Lucca Beurmann
10/20/2021, 8:52 PMDanish Ansari
10/20/2021, 9:05 PMLazyVerticalGrid. Wherever you're using your list just put some kind of isEmpty() or contains() check according to your needLucca Beurmann
10/20/2021, 9:07 PMif (photos.isEmpty()) {
    SearchPhotosEmpty(Modifier.align(Alignment.Center))
} else {
    SearchPhotosList(
        photos = photos,
        listState = listState,
        onLoadMorePhotos = loadMorePhotos,
        isPreview = isPreview,
        modifier = Modifier.fillMaxSize()
    )
}Chris Miller
10/20/2021, 10:17 PMphotos threadsafe? And does the LazyGrid know to recompose when the photos change?Lucca Beurmann
10/20/2021, 10:24 PMLucca Beurmann
10/20/2021, 10:26 PMLucca Beurmann
10/20/2021, 10:27 PMwhen (screenState) {
    is ViewState.Idle -> {
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(horizontal = 20.dp),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            Icon(
                imageVector = Icons.Default.ImageSearch,
                contentDescription = null,
                modifier = Modifier
                    .size(60.dp)
                    .padding()
                    .padding(bottom = 10.dp),
                tint = MaterialTheme.colors.onBackground
            )
            Text(
                text = "Whoops nothing to see here yet, try to search for something cute like fluffy cats.",
                style = AppTypoGraph.roboto_bold().copy(
                    fontSize = 18.sp,
                    textAlign = TextAlign.Center
                )
            )
        }
    }
    is ViewState.Loading -> {
        Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
            ProgressIndicator()
        }
    }
    is ViewState.Ready -> Box(Modifier.fillMaxSize()) {
        if (photos.isEmpty()) {
            SearchPhotosEmpty(Modifier.align(Alignment.Center))
        } else {
            SearchPhotosList(
                photos = photos,
                listState = listState,
                onLoadMorePhotos = loadMorePhotos,
                isPreview = isPreview,
                modifier = Modifier.fillMaxSize()
            )
            if (isMorePhotosLoading) MorePhotosLoader(
                modifier = Modifier
                    .align(Alignment.BottomCenter)
                    .padding()
                    .padding(20.dp)
                    .zIndex(1f)
            )
        }
    }
    is ViewState.Error -> Unit
}
I'm using a when statement to set the correct layout and for some reason this is why the exception is occurringLucca Beurmann
10/20/2021, 10:28 PMLucca Beurmann
10/20/2021, 10:28 PMLucca Beurmann
10/20/2021, 10:32 PMLucca Beurmann
10/20/2021, 10:33 PMLucca Beurmann
10/20/2021, 10:33 PMLucca Beurmann
10/20/2021, 10:34 PMTobias Suchalla
10/21/2021, 5:39 AMAndrey Kulikov
10/21/2021, 11:58 AM