Skip to content

Commit

Permalink
feat: EmptyUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Mar 8, 2023
1 parent 3cbb952 commit 25bfeea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/main/java/com/m3u/ui/LocalProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.m3u.ui.model.*

@Composable
fun M3ULocalProvider(
utils: Utils,
utils: Utils = EmptyUtils,
content: @Composable () -> Unit
) {
val theme = if (isSystemInDarkTheme()) NightTheme
Expand Down
14 changes: 13 additions & 1 deletion ui/src/main/java/com/m3u/ui/model/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ interface Utils {
fun showSystemUI()
}

val LocalUtils = staticCompositionLocalOf<Utils> { error("No utils provided.") }
val EmptyUtils = object : Utils {
override fun enterPipMode(size: Rect) = error("Cannot enterPipMode")

override fun setTitle(title: String) = error("Cannot setTitle")

override fun setActions(actions: List<AppAction>) = error("Cannot setActions")

override fun hideSystemUI() = error("Cannot hideSystemUI")

override fun showSystemUI() = error("Cannot showSystemUI")
}

val LocalUtils = staticCompositionLocalOf { EmptyUtils }

0 comments on commit 25bfeea

Please sign in to comment.