CarInfo and CarSensors
This commit is contained in:
@@ -1,13 +1,31 @@
|
||||
package com.kouros.navigation.model
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import com.kouros.data.R
|
||||
import org.maplibre.compose.style.BaseStyle
|
||||
|
||||
class BaseStyleModel {
|
||||
fun readStyle(context: Context): BaseStyle.Json {
|
||||
println("Read Style")
|
||||
val liberty = context.resources.openRawResource(R.raw.liberty)
|
||||
|
||||
fun isDarkTheme(context: Context): Boolean {
|
||||
return context.resources.configuration.uiMode and
|
||||
Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
|
||||
fun readStyle(context: Context, darkModeSettings: Int, isCarDarkMode: Boolean): BaseStyle.Json {
|
||||
println("BaseStyle ${isDarkTheme(context)}")
|
||||
val liberty = when(darkModeSettings) {
|
||||
0 -> context.resources.openRawResource(R.raw.liberty)
|
||||
1 -> context.resources.openRawResource(R.raw.liberty_night)
|
||||
else -> {
|
||||
if (isDarkTheme(context) || isCarDarkMode) {
|
||||
context.resources.openRawResource(R.raw.liberty_night)
|
||||
} else {
|
||||
context.resources.openRawResource(R.raw.liberty)
|
||||
}
|
||||
}
|
||||
}
|
||||
val libertyString = liberty.bufferedReader().use { it.readText() }
|
||||
val baseStyle = BaseStyle.Json(libertyString)
|
||||
return baseStyle
|
||||
|
||||
Reference in New Issue
Block a user