Colorize speed and tailwind background instead of text (#74)
This commit is contained in:
parent
836fb5d05f
commit
0dfd31c5eb
@ -3,7 +3,6 @@ package de.timklge.karooheadwind.datatypes
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -13,6 +12,7 @@ import androidx.glance.GlanceModifier
|
||||
import androidx.glance.Image
|
||||
import androidx.glance.ImageProvider
|
||||
import androidx.glance.appwidget.background
|
||||
import androidx.glance.appwidget.cornerRadius
|
||||
import androidx.glance.color.ColorProvider
|
||||
import androidx.glance.layout.Alignment
|
||||
import androidx.glance.layout.Box
|
||||
@ -26,7 +26,6 @@ import androidx.glance.text.FontFamily
|
||||
import androidx.glance.text.FontWeight
|
||||
import androidx.glance.text.Text
|
||||
import androidx.glance.text.TextStyle
|
||||
import de.timklge.karooheadwind.KarooHeadwindExtension
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
fun getArrowBitmapByBearing(baseBitmap: Bitmap, bearing: Int): Bitmap {
|
||||
@ -54,10 +53,10 @@ fun getArrowBitmapByBearing(baseBitmap: Bitmap, bearing: Int): Bitmap {
|
||||
fun HeadwindDirection(
|
||||
baseBitmap: Bitmap, bearing: Int, fontSize: Int,
|
||||
overlayText: String, overlaySubText: String? = null,
|
||||
dayColor: Color = Color.Black, nightColor: Color = Color.White
|
||||
nightColor: Color = Color.Black, dayColor: Color = Color.White
|
||||
) {
|
||||
Box(
|
||||
modifier = GlanceModifier.fillMaxSize().padding(5.dp),
|
||||
modifier = GlanceModifier.fillMaxSize().padding(5.dp).background(dayColor, nightColor).cornerRadius(10.dp),
|
||||
contentAlignment = Alignment(
|
||||
vertical = Alignment.Vertical.CenterVertically,
|
||||
horizontal = Alignment.Horizontal.CenterHorizontally,
|
||||
@ -70,14 +69,14 @@ fun HeadwindDirection(
|
||||
provider = ImageProvider(getArrowBitmapByBearing(baseBitmap, bearing)),
|
||||
contentDescription = "Relative wind direction indicator",
|
||||
contentScale = ContentScale.Fit,
|
||||
colorFilter = ColorFilter.tint(ColorProvider(dayColor, nightColor))
|
||||
colorFilter = ColorFilter.tint(ColorProvider(Color.Black, Color.White))
|
||||
)
|
||||
|
||||
Text(
|
||||
overlayText,
|
||||
maxLines = 1,
|
||||
style = TextStyle(ColorProvider(dayColor, nightColor), fontSize = (0.6 * fontSize).sp, fontFamily = FontFamily.Monospace),
|
||||
modifier = GlanceModifier.background(Color(1f, 1f, 1f, 0.4f), Color(0f, 0f, 0f, 0.4f)).padding(1.dp)
|
||||
style = TextStyle(color = ColorProvider(Color.Black, Color.White), fontSize = (0.6 * fontSize).sp, fontFamily = FontFamily.Monospace),
|
||||
modifier = GlanceModifier.padding(1.dp)
|
||||
)
|
||||
} else {
|
||||
Row(modifier = GlanceModifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
|
||||
@ -87,7 +86,7 @@ fun HeadwindDirection(
|
||||
provider = ImageProvider(getArrowBitmapByBearing(baseBitmap, bearing)),
|
||||
contentDescription = "Relative wind direction indicator",
|
||||
contentScale = ContentScale.Fit,
|
||||
colorFilter = ColorFilter.tint(ColorProvider(dayColor, nightColor))
|
||||
colorFilter = ColorFilter.tint(ColorProvider(Color.Black, Color.White))
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -96,16 +95,16 @@ fun HeadwindDirection(
|
||||
Text(
|
||||
overlayText,
|
||||
maxLines = 1,
|
||||
style = TextStyle(ColorProvider(dayColor, nightColor), fontSize = (0.65 * fontSize).sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Bold),
|
||||
modifier = GlanceModifier.background(Color(1f, 1f, 1f, 0.4f), Color(0f, 0f, 0f, 0.4f)).padding(1.dp)
|
||||
style = TextStyle(color = ColorProvider(Color.Black, Color.White), fontSize = (0.65 * fontSize).sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Bold),
|
||||
modifier = GlanceModifier.padding(1.dp)
|
||||
)
|
||||
|
||||
Row(){
|
||||
Text(
|
||||
overlaySubText,
|
||||
maxLines = 1,
|
||||
style = TextStyle(ColorProvider(dayColor, nightColor), fontSize = (0.4 * fontSize).sp, fontFamily = FontFamily.Monospace),
|
||||
modifier = GlanceModifier.background(Color(1f, 1f, 1f, 0.4f), Color(0f, 0f, 0f, 0.4f)).padding(1.dp)
|
||||
style = TextStyle(color = ColorProvider(Color.Black, Color.White), fontSize = (0.4 * fontSize).sp, fontFamily = FontFamily.Monospace),
|
||||
modifier = GlanceModifier.padding(1.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user