Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package com.lagradost.cloudstream4.compose

import android.app.Activity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.view.WindowCompat
import com.lagradost.cloudstream4.rememberAppSettings
import com.lagradost.cloudstream4.theme.CloudStreamTheme
import com.lagradost.cloudstream4.theme.perfToColor
Expand Down Expand Up @@ -40,6 +46,22 @@ fun Screen.createComposeView(
"No OnBackPressedDispatcherOwner was provided via LocalOnBackPressedDispatcherOwner"
}.onBackPressedDispatcher

/** Sync status bar and background color with optional HasStatusBarColor
* or else colors might be messed up. */
val statusBarColor = (this@createComposeView as? HasStatusBarColor)?.statusBarColor()
if (statusBarColor != null) {
SideEffect {
setBackgroundColor(statusBarColor.toArgb())
(context as? Activity)?.window?.let {
WindowCompat.getInsetsController(
it,
this@apply
).isAppearanceLightStatusBars =
statusBarColor.luminance() > 0.5f
}
}
}

CompositionLocalProvider(
LocalBackPress provides backDispatcher::onBackPressed,
DeviceLayout.LocalLayout provides layoutFlag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package com.lagradost.cloudstream4.compose
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

// https://github.com/adrielcafe/voyager
interface Screen {
@Composable
fun Content()
}

/** Use to sync status bar color with top app bar. */
interface HasStatusBarColor {
@Composable
fun statusBarColor(): Color = MaterialTheme.colorScheme.surface
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package com.mihon.presentation.settings
import androidx.compose.foundation.layout.RowScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import com.lagradost.cloudstream4.compose.HasStatusBarColor
import com.lagradost.cloudstream4.compose.Screen
import com.mihon.presentation.LocalBackPress

interface SearchableSettings : Screen {
interface SearchableSettings : Screen, HasStatusBarColor {
@Composable
@ReadOnlyComposable
fun getTitleRes(): String
Expand Down
Loading