Some UI updates

This commit is contained in:
Henry Hiles 2023-12-25 14:51:27 -05:00
parent 3b456682f6
commit 01358325bf

View file

@ -2,6 +2,10 @@ package com.henryhiles.qweather.presentation.components.weather
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.material.icons.filled.ArrowUpward
import androidx.compose.material.icons.outlined.WaterDrop
import androidx.compose.material3.Card import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -11,7 +15,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.henryhiles.qweather.R import com.henryhiles.qweather.R
import com.henryhiles.qweather.presentation.components.VerticalDivider
import com.henryhiles.qweather.presentation.screenmodel.HourlyWeatherState import com.henryhiles.qweather.presentation.screenmodel.HourlyWeatherState
import com.henryhiles.qweather.presentation.screenmodel.LocationPreferenceManager import com.henryhiles.qweather.presentation.screenmodel.LocationPreferenceManager
import org.koin.compose.koinInject import org.koin.compose.koinInject
@ -24,7 +27,10 @@ fun WeatherToday(state: HourlyWeatherState) {
Card( Card(
shape = RoundedCornerShape(8.dp), shape = RoundedCornerShape(8.dp),
) { ) {
Column(modifier = Modifier.padding(8.dp), horizontalAlignment = Alignment.CenterHorizontally) { Column(
modifier = Modifier.padding(8.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text( Text(
text = stringResource(id = R.string.today_in, with(locationPreferenceManager) { text = stringResource(id = R.string.today_in, with(locationPreferenceManager) {
locations.getOrNull(selectedIndex)?.location?.split(",")?.first() locations.getOrNull(selectedIndex)?.location?.split(",")?.first()
@ -37,18 +43,25 @@ fun WeatherToday(state: HourlyWeatherState) {
modifier = Modifier modifier = Modifier
.height(24.dp) .height(24.dp)
.fillMaxWidth(), .fillMaxWidth(),
horizontalArrangement = Arrangement.Center horizontalArrangement = Arrangement.SpaceEvenly,
) { ) {
Text( WeatherDataDisplay(
text = stringResource(R.string.weather_high, it.highTemperature), value = it.highTemperature,
unit = "°C",
icon = Icons.Default.ArrowUpward,
description = stringResource(R.string.weather_high, it.highTemperature)
) )
VerticalDivider(modifier = Modifier.padding(horizontal = 8.dp)) WeatherDataDisplay(
Text( value = it.lowTemperature,
text = stringResource(id = R.string.weather_low, it.lowTemperature) unit = "°C",
icon = Icons.Default.ArrowDownward,
description = stringResource(id = R.string.weather_low, it.lowTemperature)
) )
VerticalDivider(modifier = Modifier.padding(horizontal = 8.dp)) WeatherDataDisplay(
Text( value = it.precipitationProbability,
text = it.precipitationProbability?.let { unit = "%",
icon = Icons.Outlined.WaterDrop,
description = it.precipitationProbability?.let {
stringResource( stringResource(
id = R.string.weather_precipitation, id = R.string.weather_precipitation,
it it