mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 09:49:25 +02:00
Fix darkmode support
This commit is contained in:
parent
d080e26a2d
commit
4b1854f35e
1 changed files with 20 additions and 6 deletions
|
@ -15,7 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package io.timelimit.android.ui
|
package io.timelimit.android.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
|
import androidx.compose.material.darkColors
|
||||||
|
import androidx.compose.material.lightColors
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
@ -27,13 +30,24 @@ fun Theme(
|
||||||
) {
|
) {
|
||||||
val resources = LocalContext.current.resources
|
val resources = LocalContext.current.resources
|
||||||
|
|
||||||
|
val colors =
|
||||||
|
if (isSystemInDarkTheme())
|
||||||
|
darkColors(
|
||||||
|
primary = Color(resources.getColor(R.color.colorPrimary)),
|
||||||
|
primaryVariant = Color(resources.getColor(R.color.colorPrimaryDark)),
|
||||||
|
secondary = Color(resources.getColor(R.color.colorAccent)),
|
||||||
|
onSecondary = Color.White
|
||||||
|
)
|
||||||
|
else
|
||||||
|
lightColors(
|
||||||
|
primary = Color(resources.getColor(R.color.colorPrimary)),
|
||||||
|
primaryVariant = Color(resources.getColor(R.color.colorPrimaryDark)),
|
||||||
|
secondary = Color(resources.getColor(R.color.colorAccent)),
|
||||||
|
onSecondary = Color.White
|
||||||
|
)
|
||||||
|
|
||||||
MaterialTheme(
|
MaterialTheme(
|
||||||
content = content,
|
content = content,
|
||||||
colors = MaterialTheme.colors.copy(
|
colors = colors
|
||||||
primary = Color(resources.getColor(R.color.colorPrimary)),
|
|
||||||
primaryVariant = Color(resources.getColor(R.color.colorPrimaryDark)),
|
|
||||||
secondary = Color(resources.getColor(R.color.colorAccent)),
|
|
||||||
onSecondary = Color.White
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue