Skip to content

Commit

Permalink
Remove usage of Experimental APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstyl committed Oct 17, 2024
1 parent 4ab728b commit 699f9d3
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 25 deletions.
6 changes: 1 addition & 5 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ kotlin {

jvm()

@OptIn(ExperimentalWasmDsl::class) wasmJs {
wasmJs {
browser()
}

Expand All @@ -58,10 +58,6 @@ kotlin {
}

sourceSets {
all {
languageSettings.optIn("androidx.compose.foundation.ExperimentalFoundationApi")
languageSettings.optIn("androidx.compose.ui.ExperimentalComposeUiApi")
}
val commonMain by getting {
dependencies {
implementation(compose.foundation)
Expand Down
2 changes: 2 additions & 0 deletions core/src/androidMain/kotlin/ScrollArea.android.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.composables.core

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollConfiguration
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider

@OptIn(ExperimentalFoundationApi::class)
@Composable
internal actual fun NoOverscroll(content: @Composable () -> Unit) {
CompositionLocalProvider(
Expand Down
2 changes: 2 additions & 0 deletions core/src/appleMain/kotlin/Modal.apple.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -13,6 +14,7 @@ import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.window.DialogProperties

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal actual fun Modal(
protectNavBars: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion core/src/commonMain/kotlin/Dialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public fun rememberDialogState(initiallyVisible: Boolean): DialogState {
public fun Dialog(
state: DialogState,
properties: DialogProperties = DialogProperties(),
content: @Composable() (DialogScope.() -> Unit)
content: @Composable (DialogScope.() -> Unit)
) {
val scope = remember { DialogScope(state) }
scope.visibleState.targetState = state.visible
Expand Down
18 changes: 5 additions & 13 deletions core/src/commonMain/kotlin/Menu.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:OptIn(InternalComposeUiApi::class)

package com.composables.core

import androidx.compose.animation.AnimatedVisibility
Expand All @@ -25,8 +23,6 @@ import androidx.compose.ui.unit.*
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupPositionProvider
import androidx.compose.ui.window.PopupProperties
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Deprecated("This signature is going away in a future version", ReplaceWith("Menu(state,modifier,contents)"))
@Composable
Expand All @@ -42,24 +38,19 @@ public fun Menu(
@Composable
public fun Menu(state: MenuState, modifier: Modifier = Modifier, content: @Composable MenuScope.() -> Unit) {
val scope = remember(state.expanded) { MenuScope(state) }
val coroutineScope = rememberCoroutineScope()

Box(modifier.onKeyEvent { event ->
if (event.type != KeyEventType.KeyDown) return@onKeyEvent false
when (event.key) {
Key.DirectionDown -> {
if (scope.menuState.expanded.not()) {
scope.menuState.expanded = true
coroutineScope.launch {
// wait for the Popup to be displayed.
// There is no official API to wait for this to happen
delay(50)
state.menuFocusRequester.requestFocus()
state.currentFocusManager?.moveFocus(FocusDirection.Enter)
}
true
} else false
} else {
false
}
}

else -> false
}
}) {
Expand Down Expand Up @@ -202,6 +193,7 @@ public fun MenuScope.MenuContent(
menuState.expanded = false
true
}

else -> false
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/commonMain/kotlin/ModalBottomSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private val LocalModalProperties = compositionLocalOf<ModalSheetProperties> {
public fun ModalBottomSheet(
state: ModalBottomSheetState,
properties: ModalSheetProperties = ModalSheetProperties(),
content: @Composable() (ModalBottomSheetScope.() -> Unit),
content: @Composable (ModalBottomSheetScope.() -> Unit),
) {
CompositionLocalProvider(LocalModalProperties provides properties) {
val scope = remember { ModalBottomSheetScope(state, state.bottomSheetState) }
Expand Down Expand Up @@ -189,7 +189,7 @@ public fun ModalBottomSheetScope.Scrim(
public fun ModalBottomSheetScope.Sheet(
modifier: Modifier = Modifier,
enabled: Boolean = true,
content: @Composable() (BottomSheetScope.() -> Unit)
content: @Composable (BottomSheetScope.() -> Unit)
) {
var hasBeenIntroduced by remember { mutableStateOf(false) }

Expand Down
7 changes: 3 additions & 4 deletions core/src/commonMain/kotlin/ScrollArea.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ package com.composables.core
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.foundation.OverscrollEffect
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.*
import androidx.compose.foundation.gestures.*
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.grid.LazyGridItemInfo
import androidx.compose.foundation.lazy.grid.LazyGridState
import androidx.compose.foundation.overscroll
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -76,6 +73,7 @@ fun ScrollArea(
modifier: Modifier = Modifier,
content: @Composable ScrollAreaScope.() -> Unit
) {
@OptIn(ExperimentalFoundationApi::class)
ScrollArea(
state = state,
modifier = modifier,
Expand All @@ -85,6 +83,7 @@ fun ScrollArea(
)
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ScrollArea(
state: ScrollAreaState,
Expand Down
2 changes: 2 additions & 0 deletions core/src/jsMain/kotlin/Modal.js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -13,6 +14,7 @@ import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.window.DialogProperties

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal actual fun Modal(
protectNavBars: Boolean,
Expand Down
2 changes: 2 additions & 0 deletions core/src/jvmMain/kotlin/Modal.jvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -13,6 +14,7 @@ import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.window.DialogProperties

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal actual fun Modal(
protectNavBars: Boolean,
Expand Down
2 changes: 2 additions & 0 deletions core/src/wasmJsMain/kotlin/Modal.wasmJs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -13,6 +14,7 @@ import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.window.DialogProperties

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal actual fun Modal(
protectNavBars: Boolean,
Expand Down

0 comments on commit 699f9d3

Please sign in to comment.