git.iko.soy/opencode-android
on e37d1bb help sign in
34 lines 1.4 kB history raw
1package soy.iko.opencode
3import android.os.Bundle
4import androidx.activity.ComponentActivity
5import androidx.activity.compose.setContent
6import androidx.activity.enableEdgeToEdge
7import androidx.compose.foundation.isSystemInDarkTheme
8import androidx.compose.runtime.getValue
9import androidx.lifecycle.compose.collectAsStateWithLifecycle
10import soy.iko.opencode.data.repo.ThemeMode
11import soy.iko.opencode.ui.OpencodeApp as OpencodeAppUi
12import soy.iko.opencode.ui.theme.OpencodeTheme
14class MainActivity : ComponentActivity() {
15 override fun onCreate(savedInstanceState: Bundle?) {
16 super.onCreate(savedInstanceState)
17 enableEdgeToEdge()
18 val container = (application as OpencodeApp).container
19 setContent {
20 val themeMode by container.settingsStore.themeMode
21 .collectAsStateWithLifecycle(initialValue = ThemeMode.SYSTEM)
22 val dynamicColor by container.settingsStore.dynamicColor
23 .collectAsStateWithLifecycle(initialValue = true)
24 val dark = when (themeMode) {
25 ThemeMode.SYSTEM -> isSystemInDarkTheme()
26 ThemeMode.LIGHT -> false
27 ThemeMode.DARK -> true
28 }
29 OpencodeTheme(darkTheme = dark, dynamicColor = dynamicColor) {
30 OpencodeAppUi(container = container)
31 }
32 }
33 }