Better use available space in forecast widget for icon, center columns
This commit is contained in:
parent
d1cf6aa6d6
commit
ebb073b351
@ -109,7 +109,12 @@ class WeatherDataType(
|
|||||||
precipitationUnit = if (userProfile?.preferredUnit?.distance != UserProfile.PreferredUnit.UnitType.IMPERIAL) PrecipitationUnit.MILLIMETERS else PrecipitationUnit.INCH,
|
precipitationUnit = if (userProfile?.preferredUnit?.distance != UserProfile.PreferredUnit.UnitType.IMPERIAL) PrecipitationUnit.MILLIMETERS else PrecipitationUnit.INCH,
|
||||||
temperature = data.current.temperature.roundToInt(),
|
temperature = data.current.temperature.roundToInt(),
|
||||||
temperatureUnit = if (userProfile?.preferredUnit?.temperature != UserProfile.PreferredUnit.UnitType.IMPERIAL) TemperatureUnit.CELSIUS else TemperatureUnit.FAHRENHEIT,
|
temperatureUnit = if (userProfile?.preferredUnit?.temperature != UserProfile.PreferredUnit.UnitType.IMPERIAL) TemperatureUnit.CELSIUS else TemperatureUnit.FAHRENHEIT,
|
||||||
timeLabel = formattedTime
|
timeLabel = formattedTime,
|
||||||
|
rowAlignment = when (config.alignment){
|
||||||
|
ViewConfig.Alignment.LEFT -> Alignment.Horizontal.Start
|
||||||
|
ViewConfig.Alignment.CENTER -> Alignment.Horizontal.CenterHorizontally
|
||||||
|
ViewConfig.Alignment.RIGHT -> Alignment.Horizontal.End
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,16 +51,14 @@ fun getWeatherIcon(interpretation: WeatherInterpretation): Int {
|
|||||||
@Composable
|
@Composable
|
||||||
fun Weather(baseBitmap: Bitmap, current: WeatherInterpretation, windBearing: Int, windSpeed: Int, windGusts: Int, windSpeedUnit: WindUnit,
|
fun Weather(baseBitmap: Bitmap, current: WeatherInterpretation, windBearing: Int, windSpeed: Int, windGusts: Int, windSpeedUnit: WindUnit,
|
||||||
precipitation: Double, precipitationProbability: Int?, precipitationUnit: PrecipitationUnit,
|
precipitation: Double, precipitationProbability: Int?, precipitationUnit: PrecipitationUnit,
|
||||||
temperature: Int, temperatureUnit: TemperatureUnit, timeLabel: String? = null) {
|
temperature: Int, temperatureUnit: TemperatureUnit, timeLabel: String? = null, rowAlignment: Alignment.Horizontal = Alignment.Horizontal.CenterHorizontally) {
|
||||||
|
|
||||||
val fontSize = 14f
|
val fontSize = 14f
|
||||||
|
|
||||||
Column(modifier = GlanceModifier.fillMaxHeight().padding(2.dp), horizontalAlignment = Alignment.End) {
|
Column(modifier = GlanceModifier.fillMaxHeight().padding(2.dp).width(85.dp), horizontalAlignment = rowAlignment) {
|
||||||
Row(modifier = GlanceModifier.defaultWeight(), horizontalAlignment = Alignment.End) {
|
Row(modifier = GlanceModifier.defaultWeight(), horizontalAlignment = rowAlignment, verticalAlignment = Alignment.CenterVertically) {
|
||||||
val imageW = 60
|
|
||||||
val imageH = (imageW * (280.0 / 400)).toInt()
|
|
||||||
Image(
|
Image(
|
||||||
modifier = GlanceModifier.height(imageH.dp).width(imageW.dp),
|
modifier = GlanceModifier.defaultWeight(),
|
||||||
provider = ImageProvider(getWeatherIcon(current)),
|
provider = ImageProvider(getWeatherIcon(current)),
|
||||||
contentDescription = "Current weather information",
|
contentDescription = "Current weather information",
|
||||||
contentScale = ContentScale.Fit,
|
contentScale = ContentScale.Fit,
|
||||||
@ -68,7 +66,7 @@ fun Weather(baseBitmap: Bitmap, current: WeatherInterpretation, windBearing: Int
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically, horizontalAlignment = rowAlignment) {
|
||||||
if (timeLabel != null){
|
if (timeLabel != null){
|
||||||
Text(
|
Text(
|
||||||
text = timeLabel,
|
text = timeLabel,
|
||||||
@ -93,7 +91,7 @@ fun Weather(baseBitmap: Bitmap, current: WeatherInterpretation, windBearing: Int
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically, horizontalAlignment = rowAlignment) {
|
||||||
/* Image(
|
/* Image(
|
||||||
modifier = GlanceModifier.height(20.dp).width(12.dp),
|
modifier = GlanceModifier.height(20.dp).width(12.dp),
|
||||||
provider = ImageProvider(R.drawable.water_regular),
|
provider = ImageProvider(R.drawable.water_regular),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user