Weather widget: use buttons for day/time selectors
For consistency with other widgets
This commit is contained in:
parent
41096e7ca6
commit
577ac7e28c
@ -87,7 +87,7 @@ fun WeatherWidget() {
|
|||||||
CurrentWeather(forecast, imperialUnits)
|
CurrentWeather(forecast, imperialUnits)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
val dailyForecasts by viewModel.dailyForecasts.observeAsState(emptyList())
|
val dailyForecasts by viewModel.dailyForecasts.observeAsState(emptyList())
|
||||||
@ -99,7 +99,7 @@ fun WeatherWidget() {
|
|||||||
onDaySelected = {
|
onDaySelected = {
|
||||||
viewModel.selectDay(it)
|
viewModel.selectDay(it)
|
||||||
},
|
},
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f).padding(horizontal = 4.dp),
|
||||||
imperialUnits = imperialUnits
|
imperialUnits = imperialUnits
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -110,7 +110,8 @@ fun WeatherWidget() {
|
|||||||
imperialUnits = imperialUnits,
|
imperialUnits = imperialUnits,
|
||||||
onTimeSelected = {
|
onTimeSelected = {
|
||||||
viewModel.selectForecast(it)
|
viewModel.selectForecast(it)
|
||||||
}
|
},
|
||||||
|
modifier = Modifier.weight(1f).padding(horizontal = 4.dp),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,15 +248,12 @@ fun WeatherDaySelector(
|
|||||||
) {
|
) {
|
||||||
val menuExpanded = remember { mutableStateOf(false) }
|
val menuExpanded = remember { mutableStateOf(false) }
|
||||||
val dateFormat = SimpleDateFormat("EEE")
|
val dateFormat = SimpleDateFormat("EEE")
|
||||||
Row(modifier = modifier) {
|
Box(modifier = modifier, contentAlignment = Alignment.CenterStart) {
|
||||||
Row(
|
TextButton(
|
||||||
modifier = Modifier
|
onClick = {
|
||||||
.clickable(onClick = {
|
menuExpanded.value = true
|
||||||
menuExpanded.value = true
|
},
|
||||||
})
|
colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.onSurface)
|
||||||
.padding(16.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.Start
|
|
||||||
) {
|
) {
|
||||||
WeatherIcon(icon = weatherIconById(selectedDay.icon))
|
WeatherIcon(icon = weatherIconById(selectedDay.icon))
|
||||||
Text(
|
Text(
|
||||||
@ -301,7 +299,6 @@ fun WeatherDaySelector(
|
|||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
softWrap = false,
|
softWrap = false,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
.padding(start = 16.dp, end = 8.dp)
|
.padding(start = 16.dp, end = 8.dp)
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
)
|
)
|
||||||
@ -314,7 +311,6 @@ fun WeatherDaySelector(
|
|||||||
}° / ${convertTemperature(imperialUnits, d.maxTemp)}°",
|
}° / ${convertTemperature(imperialUnits, d.maxTemp)}°",
|
||||||
softWrap = false,
|
softWrap = false,
|
||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
modifier = Modifier.align(Alignment.CenterVertically)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,20 +332,19 @@ fun WeatherTimeSelector(
|
|||||||
|
|
||||||
val dateFormat = remember { DateFormat.getTimeInstance(DateFormat.SHORT) }
|
val dateFormat = remember { DateFormat.getTimeInstance(DateFormat.SHORT) }
|
||||||
|
|
||||||
Row(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier,
|
||||||
|
contentAlignment = Alignment.CenterEnd
|
||||||
) {
|
) {
|
||||||
Row(
|
TextButton(
|
||||||
modifier = Modifier
|
onClick = {
|
||||||
.clickable(onClick = {
|
menuExpanded.value = true
|
||||||
menuExpanded.value = true
|
},
|
||||||
})
|
colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.onSurface)
|
||||||
.padding(16.dp)
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = dateFormat.format(selectedForecast.timestamp),
|
text = dateFormat.format(selectedForecast.timestamp),
|
||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
modifier = Modifier.align(Alignment.CenterVertically)
|
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Rounded.ArrowDropDown,
|
imageVector = Icons.Rounded.ArrowDropDown,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user