Skip to content

Instantly share code, notes, and snippets.

@marenovakovic
Last active May 24, 2021 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marenovakovic/c19beef87e2f7d3e9e5aaf1a3d9e6988 to your computer and use it in GitHub Desktop.
Save marenovakovic/c19beef87e2f7d3e9e5aaf1a3d9e6988 to your computer and use it in GitHub Desktop.
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.coil.rememberCoilPainter
import your.app.data.images
private val randomImageUrl: String
get() = images.random()
@Composable
fun CollapsableParallaxScreen() {
val scrollState by rememberScrollState()
var imageUrl by remember { mutableStateOf(randomImageUrl) }
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(state = scrollState),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Image(
modifier = Modifier
.height(250.dp)
.fillMaxWidth(),
painter = rememberCoilPainter(imageUrl),
contentScale = ContentScale.FillWidth,
contentDescription = null)
Spacer(modifier = Modifier.height(32.dp))
Button(onClick = { imageUrl = randomImageUrl }) {
Text(text = "Next please!")
}
Spacer(modifier = Modifier.height(32.dp))
Text(text = stringResource(id = R.string.lorem_ipsum))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment