minor ui changes
This commit is contained in:
@@ -118,15 +118,17 @@ fun CalendarWidget(
|
||||
) {
|
||||
for ((i, date) in availableDates.withIndex()) {
|
||||
DropdownMenuItem(
|
||||
shape = if (availableDates.size == 1) MenuDefaults.standaloneItemShape
|
||||
else when (i) {
|
||||
0 -> MenuDefaults.leadingItemShape
|
||||
availableDates.lastIndex -> MenuDefaults.trailingItemShape
|
||||
else -> MenuDefaults.middleItemShape
|
||||
},
|
||||
shapes = MenuDefaults.itemShape(i, availableDates.size),
|
||||
selected = date == selectedDate,
|
||||
text = {
|
||||
Text(formatDay(context, date, LocalCalendarSystems.current[0]!!))
|
||||
},
|
||||
selectedLeadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.check_24px),
|
||||
null,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
viewModel.selectDate(date)
|
||||
showDropdown = false
|
||||
|
||||
@@ -34,7 +34,6 @@ import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
@@ -408,14 +407,35 @@ private fun CurrentWeatherDetails(
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.secondary,
|
||||
)
|
||||
} to if (forecast.precipProbability != null) {
|
||||
formatPercent(forecast.precipProbability!!.toFloat())
|
||||
} else {
|
||||
formatPrecipitation(
|
||||
context,
|
||||
forecast.precipitation?.toFloat() ?: 0f,
|
||||
measurementSystem
|
||||
)
|
||||
} to when {
|
||||
forecast.precipProbability != null
|
||||
&& forecast.precipitation != null
|
||||
&& forecast.precipitation!! >= 0.05 -> {
|
||||
"${
|
||||
formatPercent(
|
||||
forecast.precipProbability!!.toFloat()
|
||||
)
|
||||
} • ${
|
||||
formatPrecipitation(
|
||||
context,
|
||||
forecast.precipitation?.toFloat() ?: 0f,
|
||||
measurementSystem
|
||||
)
|
||||
}"
|
||||
|
||||
}
|
||||
|
||||
forecast.precipProbability != null -> {
|
||||
formatPercent(forecast.precipProbability!!.toFloat())
|
||||
}
|
||||
|
||||
else -> {
|
||||
formatPrecipitation(
|
||||
context,
|
||||
forecast.precipitation?.toFloat() ?: 0f,
|
||||
measurementSystem
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -263,11 +263,11 @@ private fun formatMillimeters(
|
||||
.withLocale(
|
||||
Locale.getDefault()
|
||||
).unitWidth(NumberFormatter.UnitWidth.NARROW)
|
||||
.precision(Precision.maxFraction(0))
|
||||
.precision(Precision.maxFraction(1))
|
||||
.format(Measure(millimeters, MeasureUnit.MILLIMETER)).toString()
|
||||
} else {
|
||||
val formatted = NumberFormat.getInstance().apply {
|
||||
maximumFractionDigits = 0
|
||||
maximumFractionDigits = 1
|
||||
}.format(millimeters)
|
||||
return "$formatted ${context.getString(R.string.unit_millimeter_symbol)}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user