Last active
May 24, 2021 11:35
-
-
Save marenovakovic/f594895165d35d1c1512d517f549eaa6 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.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 yourApp.data.images | |
private val randomImageUrl: String | |
get() = images.random() | |
@Composable | |
fun CollapsableParallaxScreen() { | |
var imageUrl by remember { mutableStateOf(randomImageUrl) } | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
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