Skip to content

Commit

Permalink
Use InternalComposeUiApi for APIs in UI module (#1335)
Browse files Browse the repository at this point in the history
`InternalComposeApi` is for the runtime.

Test: `gw :compose:ui:ui:cKUA :compose:foundation:foundation:cKUA`
  • Loading branch information
JakeWharton authored May 2, 2024
1 parent 6695376 commit 65e913b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package androidx.compose.foundation.layout

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.platform.LocalLayoutMargins
import androidx.compose.ui.platform.LocalSafeArea
import androidx.compose.ui.platform.PlatformInsets
Expand All @@ -41,15 +41,15 @@ private fun PlatformInsets.toWindowInsets() = WindowInsets(
*/
private val WindowInsets.Companion.iosSafeArea: WindowInsets
@Composable
@OptIn(InternalComposeApi::class, ExperimentalComposeUiApi::class)
@OptIn(InternalComposeUiApi::class, ExperimentalComposeUiApi::class)
get() = LocalSafeArea.current.toWindowInsets()

/**
* This insets represents iOS layoutMargins.
*/
private val WindowInsets.Companion.layoutMargins: WindowInsets
@Composable
@OptIn(InternalComposeApi::class, ExperimentalComposeUiApi::class)
@OptIn(InternalComposeUiApi::class, ExperimentalComposeUiApi::class)
get() = LocalLayoutMargins.current.toWindowInsets()

/**
Expand All @@ -64,7 +64,7 @@ actual val WindowInsets.Companion.captionBar: WindowInsets
*/
actual val WindowInsets.Companion.displayCutout: WindowInsets
@Composable
@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
get() = when (LocalInterfaceOrientation.current) {
InterfaceOrientation.Portrait -> iosSafeArea.only(WindowInsetsSides.Top)
InterfaceOrientation.PortraitUpsideDown -> iosSafeArea.only(WindowInsetsSides.Bottom)
Expand All @@ -78,7 +78,7 @@ actual val WindowInsets.Companion.displayCutout: WindowInsets
*/
actual val WindowInsets.Companion.ime: WindowInsets
@Composable
@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
get() = WindowInsets(bottom = LocalKeyboardOverlapHeight.current)

/**
Expand All @@ -101,7 +101,7 @@ actual val WindowInsets.Companion.navigationBars: WindowInsets
*/
actual val WindowInsets.Companion.statusBars: WindowInsets
@Composable
@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
get() = when (LocalInterfaceOrientation.current) {
InterfaceOrientation.Portrait -> iosSafeArea.only(WindowInsetsSides.Top)
else -> ZeroInsets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package androidx.compose.foundation

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.SystemTheme

Expand All @@ -43,7 +43,7 @@ import androidx.compose.ui.SystemTheme
*
* @return `true` if the system is considered to be in 'dark theme'.
*/
@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
@Composable
@ReadOnlyComposable
internal actual fun _isSystemInDarkTheme(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ package androidx.compose.ui

import androidx.compose.runtime.staticCompositionLocalOf
import org.jetbrains.skiko.SystemTheme as SkikoSystemTheme
import androidx.compose.runtime.InternalComposeApi
import org.jetbrains.skiko.currentSystemTheme

enum class SystemTheme {
Dark, Light, Unknown
}

@InternalComposeApi
@InternalComposeUiApi
val LocalSystemTheme = staticCompositionLocalOf {
currentSystemTheme.asComposeSystemTheme()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@ package androidx.compose.ui.platform

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.uikit.LocalKeyboardOverlapHeight
import androidx.compose.ui.unit.dp

/**
* Composition local for SafeArea of ComposeUIViewController
*/
@InternalComposeApi
@InternalComposeUiApi
val LocalSafeArea = staticCompositionLocalOf { PlatformInsets.Zero }

/**
* Composition local for layoutMargins of ComposeUIViewController
*/
@InternalComposeApi
@InternalComposeUiApi
val LocalLayoutMargins = staticCompositionLocalOf { PlatformInsets.Zero }

@OptIn(InternalComposeApi::class)
private object SafeAreaInsetsConfig : InsetsConfig {
override val safeInsets: PlatformInsets
@Composable get() = LocalSafeArea.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package androidx.compose.ui.scene
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.geometry.Offset
Expand Down Expand Up @@ -485,7 +484,6 @@ internal class ComposeSceneMediator(
layoutMarginsState.value = calcLayoutMargin()
}

@OptIn(InternalComposeApi::class)
@Composable
private fun ProvideComposeSceneMediatorCompositionLocals(content: @Composable () -> Unit) =
CompositionLocalProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
package androidx.compose.ui.uikit

import androidx.compose.runtime.Immutable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.InternalComposeUiApi
import platform.UIKit.*

/**
* Wraps valid layout values for iOS UIInterfaceOrientation
*/
@InternalComposeApi
@InternalComposeUiApi
@Immutable
enum class InterfaceOrientation(private val rawValue: UIInterfaceOrientation) {
Portrait(UIInterfaceOrientationPortrait),
Expand All @@ -44,5 +44,5 @@ enum class InterfaceOrientation(private val rawValue: UIInterfaceOrientation) {
/**
* Composition local for [InterfaceOrientation]
*/
@InternalComposeApi
@InternalComposeUiApi
val LocalInterfaceOrientation = staticCompositionLocalOf { InterfaceOrientation.Portrait }
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package androidx.compose.ui.uikit

import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.unit.dp


/**
* Composition local for height that is overlapped with keyboard over Compose view.
*/
@InternalComposeApi
@InternalComposeUiApi
val LocalKeyboardOverlapHeight = compositionLocalOf { 0.dp }
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionContext
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.LocalSystemTheme
Expand Down Expand Up @@ -93,7 +92,6 @@ import platform.darwin.dispatch_get_main_queue
private val coroutineDispatcher = Dispatchers.Main

// TODO: Move to androidx.compose.ui.scene
@OptIn(InternalComposeApi::class)
@ExportObjCClass
internal class ComposeContainer(
private val configuration: ComposeUIViewControllerConfiguration,
Expand Down Expand Up @@ -432,7 +430,6 @@ private fun getLayoutDirection() =
else -> LayoutDirection.Ltr
}

@OptIn(InternalComposeApi::class)
@Composable
internal fun ProvideContainerCompositionLocals(
composeContainer: ComposeContainer,
Expand Down

0 comments on commit 65e913b

Please sign in to comment.