mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-05-15 01:42:11 +00:00
Properly set status bar icons color based on service themes
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -9,9 +9,13 @@ import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.newpipe.Constants
|
||||
import net.newpipe.app.navigation.Screen
|
||||
import net.newpipe.app.theme.currentService
|
||||
|
||||
/**
|
||||
* Entry point for compose-related UI components on Android
|
||||
@@ -28,7 +32,18 @@ class ComposeActivity : ComponentActivity() {
|
||||
intent.getStringExtra(Constants.INTENT_SCREEN_KEY)!!
|
||||
),
|
||||
onCloseRequest = ::finish
|
||||
)
|
||||
) {
|
||||
val view = LocalView.current
|
||||
val service = currentService()
|
||||
|
||||
DisposableEffect(service) {
|
||||
val windowController = WindowCompat.getInsetsController(window, view)
|
||||
windowController.isAppearanceLightStatusBars = service.isSchemeColorDensityLight
|
||||
onDispose {
|
||||
windowController.isAppearanceLightStatusBars = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,15 @@ import org.koin.plugin.module.dsl.koinConfiguration
|
||||
/**
|
||||
* Entry point for the multiplatform compose application
|
||||
* @param startDestination Starting destination for the activity/app, defaults to about
|
||||
* @param onCloseRequest Callback to close the app
|
||||
* @param withKoin Additional logic to execute after initialising Koin and setting content
|
||||
*/
|
||||
@Composable
|
||||
fun App(startDestination: Screen = Screen.About, onCloseRequest : () -> Unit) {
|
||||
fun App(
|
||||
startDestination: Screen = Screen.About,
|
||||
onCloseRequest : () -> Unit,
|
||||
withKoin: @Composable () -> Unit = {}
|
||||
) {
|
||||
KoinApplication(configuration = koinConfiguration<KoinApp>()) {
|
||||
AppTheme {
|
||||
NavDisplay(
|
||||
@@ -26,5 +32,6 @@ fun App(startDestination: Screen = Screen.About, onCloseRequest : () -> Unit) {
|
||||
onCloseRequest = onCloseRequest
|
||||
)
|
||||
}
|
||||
withKoin()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,16 @@ import net.newpipe.app.theme.youTubeLightScheme
|
||||
* Supported services in the NewPipe app and minor information about them for UI decisions.
|
||||
* @property serviceId ID of the service as defined in NewPipeExtractor
|
||||
* @property serviceName Name of the service as defined in NewPipeExtractor
|
||||
* @property lightScheme Light color scheme to reflect the brand
|
||||
* @property darkScheme Dark color scheme to reflect the brand
|
||||
* @property isSchemeColorDensityLight Whether this brand's color schemes are of lighter density.
|
||||
*/
|
||||
enum class Service(
|
||||
val serviceId: Int,
|
||||
val serviceName: String,
|
||||
val lightScheme: ColorScheme,
|
||||
val darkScheme: ColorScheme
|
||||
val darkScheme: ColorScheme,
|
||||
val isSchemeColorDensityLight: Boolean = false
|
||||
) {
|
||||
YOUTUBE(
|
||||
serviceId = 0,
|
||||
|
||||
Reference in New Issue
Block a user