Skip to content

Commit

Permalink
suggest to simplify visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-avdeev-jb committed Dec 8, 2023
1 parent 24334fd commit 3016f93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ internal class ComposeContainer(
* Initial value is arbitrarily chosen to avoid propagating invalid value logic
* It's never the case in real usage scenario to reflect that in type system
*/
val interfaceOrientationState: MutableState<InterfaceOrientation> = mutableStateOf(
private val interfaceOrientationState: MutableState<InterfaceOrientation> = mutableStateOf(
InterfaceOrientation.Portrait
)
val systemThemeState: MutableState<SystemTheme> = mutableStateOf(SystemTheme.Unknown)
private val systemThemeState: MutableState<SystemTheme> = mutableStateOf(SystemTheme.Unknown)
private val focusStack: FocusStack<UIView> = FocusStackImpl()
private val windowInfo = WindowInfoImpl().also {
it.isWindowFocused = true
Expand Down Expand Up @@ -260,13 +260,25 @@ internal class ComposeContainer(
}
composeSceneMediator = mediator
mediator.setContent {
ProvideContainerCompositionLocals(this) {
ProvideContainerCompositionLocals {
content()
}
}
mediator.setLayout(SceneLayout.UseConstraintsToFillContainer)
}

@OptIn(InternalComposeApi::class)
@Composable
internal fun ProvideContainerCompositionLocals(content: @Composable () -> Unit) =
CompositionLocalProvider(
LocalUIViewController provides this,
LocalLayerContainer provides view,
LocalInterfaceOrientation provides interfaceOrientationState.value,
LocalSystemTheme provides systemThemeState.value,
content = content
)


private fun dispose() {
composeSceneMediator?.dispose()
composeSceneMediator = null
Expand Down Expand Up @@ -380,18 +392,3 @@ private fun getLayoutDirection() =
UIUserInterfaceLayoutDirection.UIUserInterfaceLayoutDirectionRightToLeft -> LayoutDirection.Rtl
else -> LayoutDirection.Ltr
}

@OptIn(InternalComposeApi::class)
@Composable
internal fun ProvideContainerCompositionLocals(
composeContainer: ComposeContainer,
content: @Composable () -> Unit,
) = with(composeContainer) {
CompositionLocalProvider(
LocalUIViewController provides this,
LocalLayerContainer provides view,
LocalInterfaceOrientation provides interfaceOrientationState.value,
LocalSystemTheme provides systemThemeState.value,
content = content
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal class UIViewComposeSceneLayer(

override fun setContent(content: @Composable () -> Unit) {
mediator.setContent {
ProvideContainerCompositionLocals(composeContainer) {
composeContainer.ProvideContainerCompositionLocals {
content()
}
}
Expand Down

0 comments on commit 3016f93

Please sign in to comment.