Skip to content

Commit

Permalink
Merge pull request #24 from Kotlin/dark-mode
Browse files Browse the repository at this point in the history
Add support for dark mode
  • Loading branch information
zsmb13 authored Sep 6, 2024
2 parents a6cd182 + 8c1df24 commit b899e54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 10 additions & 2 deletions composeApp/src/commonMain/kotlin/com/jetbrains/kmpapp/App.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.jetbrains.kmpapp

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import cafe.adriel.voyager.navigator.Navigator
import com.jetbrains.kmpapp.screens.list.ListScreen

@Composable
fun App() {
MaterialTheme {
Navigator(ListScreen)
MaterialTheme(
colors = if (isSystemInDarkTheme()) darkColors() else lightColors()
) {
Surface {
Navigator(ListScreen)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import kmp_app_template.composeapp.generated.resources.label_dimensions
import kmp_app_template.composeapp.generated.resources.label_medium
import kmp_app_template.composeapp.generated.resources.label_repository
import kmp_app_template.composeapp.generated.resources.label_title
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.stringResource

data class DetailScreen(val objectId: Int) : Screen {
Expand All @@ -68,7 +67,6 @@ data class DetailScreen(val objectId: Int) : Screen {
}
}

@OptIn(ExperimentalResourceApi::class)
@Composable
private fun ObjectDetails(
obj: MuseumObject,
Expand All @@ -77,7 +75,7 @@ private fun ObjectDetails(
) {
Scaffold(
topBar = {
TopAppBar(backgroundColor = Color.White) {
TopAppBar(backgroundColor = MaterialTheme.colors.background) {
IconButton(onClick = onBackClick) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, stringResource(Res.string.back))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
Expand Down Expand Up @@ -64,7 +63,6 @@ private fun ObjectGrid(
onObjectClick: (Int) -> Unit,
modifier: Modifier = Modifier,
) {
LazyRow() { }
LazyVerticalGrid(
columns = GridCells.Adaptive(180.dp),
modifier = modifier.fillMaxSize(),
Expand Down

0 comments on commit b899e54

Please sign in to comment.