package org.lsposed.lspatch.ui.theme import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.ViewCompat @Composable fun LSPTheme( isDarkTheme: Boolean = isSystemInDarkTheme(), enableDynamicColor: Boolean = true, content: @Composable () -> Unit ) { val colorScheme = when { enableDynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (isDarkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } isDarkTheme -> darkColorScheme() else -> lightColorScheme() } val view = LocalView.current if (!view.isInEditMode) { SideEffect { (view.context as Activity).window.statusBarColor = colorScheme.background.toArgb() ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = !isDarkTheme } } MaterialTheme( colorScheme = colorScheme, typography = Typography, content = content ) }