-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.kt
More file actions
39 lines (35 loc) · 1.18 KB
/
MainActivity.kt
File metadata and controls
39 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.songlib
import android.os.*
import androidx.activity.*
import androidx.activity.compose.setContent
import androidx.annotation.*
import androidx.compose.foundation.*
import androidx.compose.ui.*
import androidx.hilt.navigation.compose.hiltViewModel
import com.songlib.domain.repos.ThemeMode
import com.songlib.domain.repos.ThemeRepository
import com.songlib.presentation.navigation.*
import com.songlib.presentation.theme.*
import dagger.hilt.android.AndroidEntryPoint
@ExperimentalComposeUiApi
@ExperimentalFoundationApi
@Keep
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@RequiresApi(Build.VERSION_CODES.S)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val themeRepo: ThemeRepository = hiltViewModel()
val themeMode = themeRepo.selectedTheme
val isDarkTheme = when (themeMode) {
ThemeMode.DARK -> true
ThemeMode.LIGHT -> false
ThemeMode.SYSTEM -> isSystemInDarkTheme()
}
AppTheme(useDarkTheme = isDarkTheme) {
AppNavHost(themeRepo = themeRepo)
}
}
}
}