Last active
April 3, 2022 08:24
-
-
Save alexstyl/3b0780a927938b8079595a2983abb848 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
// instead of a LinearLayout (horizontal) use: | |
Row { | |
Text("Main Header") | |
Spacer(Modifier.weight(1f)) | |
Text("23 mins ago") | |
} | |
// instead of FrameLayout use: | |
Box { | |
Image( | |
painter = painterResource(R.drawable.landscape_horizontal), | |
contentDescription = null | |
) | |
Text( | |
"Preview", | |
modifier = Modifier | |
.padding(4.dp) | |
.clip(RoundedCornerShape(14.dp)) | |
.background(Color.DarkGray) | |
.padding( | |
horizontal = 8.dp, | |
vertical = 4.dp | |
) | |
.align(Alignment.BottomEnd), | |
color = Color.White | |
) | |
} | |
// instead of RecyclerView (vertical) use: | |
Box { | |
val desertNames = listOf("...") | |
LazyColumn(Modifier.fillMaxSize()) { | |
stickyHeader { | |
Text( | |
"Desert names", | |
modifier = Modifier | |
.fillMaxWidth() | |
.shadow(4.dp) | |
.background(Color.White) | |
.padding( | |
vertical = 20.dp, | |
horizontal = 16.dp | |
) | |
) | |
} | |
desertNames.forEach { item -> | |
item { | |
Text( | |
item, | |
modifier = Modifier.padding( | |
vertical = 20.dp, | |
horizontal = 16.dp | |
) | |
) | |
} | |
} | |
} | |
// suggested parameter ordering | |
@Composable | |
fun MyComposable( | |
requiredValue: String, | |
modifier: Modifier = Modifier, | |
onClick: () -> Unit, | |
optionalValue: String = "", | |
content: @Composable () -> Unit | |
) { | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment