Last active
May 24, 2021 14:26
-
-
Save marenovakovic/c19beef87e2f7d3e9e5aaf1a3d9e6988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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