Created
April 19, 2021 21:27
-
-
Save fvilarino/9236b156ad67410db442c4388ef40aa9 to your computer and use it in GitHub Desktop.
Compose Forecast Card
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 ForecastWeatherCard( | |
state: ForecastItem.ForecastCard, | |
modifier: Modifier = Modifier, | |
elevation: Dp = CardElevation, | |
) { | |
Card(modifier = modifier, elevation = elevation) { | |
Column(modifier = Modifier.fillMaxWidth().padding(MarginSingle)) { | |
Row(verticalAlignment = Alignment.CenterVertically) { | |
Icon( | |
painter = painterResource(id = state.iconId), | |
contentDescription = null, | |
modifier = Modifier.width(64.dp).height(64.dp), | |
) | |
Text( | |
text = state.header, | |
style = MaterialTheme.typography.body1, | |
modifier = Modifier.fillMaxWidth(), | |
textAlign = TextAlign.Center, | |
) | |
} | |
Row(modifier = Modifier.fillMaxWidth()) { | |
InfoLabels(modifier = Modifier.weight(1f)) { | |
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { | |
Text( | |
text = stringResource(id = R.string.min_temperature_label), | |
style = MaterialTheme.typography.overline, | |
) | |
} | |
Text( | |
text = state.minTemperature, | |
style = MaterialTheme.typography.caption, | |
modifier = Modifier.padding(start = MarginSingle), | |
) | |
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { | |
Text( | |
text = stringResource(id = R.string.max_temperature_label), | |
style = MaterialTheme.typography.overline, | |
) | |
} | |
Text( | |
text = state.maxTemperature, | |
style = MaterialTheme.typography.caption, | |
modifier = Modifier.padding(start = MarginSingle), | |
) | |
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { | |
Text( | |
text = stringResource(id = R.string.feels_like_label), | |
style = MaterialTheme.typography.overline, | |
) | |
} | |
Text( | |
text = state.feelsLikeTemperature, | |
style = MaterialTheme.typography.caption, | |
modifier = Modifier.padding(start = MarginSingle), | |
) | |
} | |
InfoLabels(modifier = Modifier.weight(1f)) { | |
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { | |
Text( | |
text = stringResource(id = R.string.wind_speed_label), | |
style = MaterialTheme.typography.overline, | |
) | |
} | |
Text( | |
text = state.windSpeed, | |
style = MaterialTheme.typography.caption, | |
modifier = Modifier.padding(start = MarginSingle), | |
) | |
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { | |
Text( | |
text = stringResource(id = R.string.humidity_label), | |
style = MaterialTheme.typography.overline, | |
) | |
} | |
Text( | |
text = state.humidity, | |
style = MaterialTheme.typography.caption, | |
modifier = Modifier.padding(start = MarginSingle), | |
) | |
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { | |
Text( | |
text = stringResource(id = R.string.visibility_label), | |
style = MaterialTheme.typography.overline, | |
) | |
} | |
Text( | |
text = state.visibility, | |
style = MaterialTheme.typography.caption, | |
modifier = Modifier.padding(start = MarginSingle), | |
) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment