Last active
March 12, 2021 19:21
-
-
Save pablobaldez/9435a58b495ce28f936962df4c75d329 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
@Composable | |
fun RegularRow( | |
modifier: Modifier = Modifier, | |
leftIcon: @Composable (RowScope.() -> Unit)? = null, | |
detail: @Composable (() -> Unit)? = null, | |
rightIcon: @Composable (RowScope.() -> Unit)? = null, | |
title: @Composable () -> Unit | |
) { | |
FoundationRow( | |
modifier = modifier.wrapContentHeight() | |
) { | |
leftIcon?.let { | |
leftIcon() | |
Spacer(modifier = Modifier.width(ContentSpacing)) | |
} | |
Box(modifier = Modifier.weight(1F),) { | |
title() | |
} | |
detail?.let { | |
Box( | |
modifier = Modifier.wrapContentWidth(), | |
contentAlignment = Alignment.CenterEnd | |
) { | |
detail() | |
} | |
} | |
rightIcon?.let { | |
Spacer(modifier = Modifier.width(ContentSpacing)) | |
rightIcon() | |
} | |
} | |
} | |
@Composable | |
fun FoundationRow( | |
modifier: Modifier = Modifier, | |
content: @Composable RowScope.() -> Unit | |
) { | |
Surface { | |
Row( | |
modifier = modifier.composed { | |
wrapContentHeight() | |
.fillMaxWidth() | |
.padding( | |
horizontal = RowDefaults.HorizontalPadding, | |
vertical = RowDefaults.VerticalPadding | |
) | |
} | |
) { | |
content() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment