Skip to content

Commit a769530

Browse files
committed
Merge branch 'context-parameters'
2 parents dd789ed + 29c9690 commit a769530

10 files changed

Lines changed: 3375 additions & 34 deletions

File tree

build.gradle.kts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
2+
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag
3+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
4+
import org.jetbrains.kotlin.gradle.targets.wasm.nodejs.WasmNodeJsRootPlugin
5+
16
plugins {
27
kotlin("multiplatform") apply false
38
kotlin("plugin.serialization") apply false
@@ -7,3 +12,34 @@ plugins {
712

813
group = "dev.bnorm.storyboard"
914
version = "0.1-SNAPSHOT"
15+
16+
allprojects {
17+
plugins.withId("org.jetbrains.compose") {
18+
// Support local development with Compose Hot-Reload.
19+
extensions.configure<ComposeCompilerGradlePluginExtension> {
20+
featureFlags.add(ComposeFeatureFlag.OptimizeNonSkippingGroups)
21+
}
22+
}
23+
24+
plugins.withId("org.jetbrains.kotlin.multiplatform") {
25+
extensions.configure<KotlinMultiplatformExtension> {
26+
sourceSets.all {
27+
languageSettings {
28+
enableLanguageFeature("ContextParameters")
29+
enableLanguageFeature("WhenGuards")
30+
enableLanguageFeature("MultiDollarInterpolation")
31+
32+
optIn("androidx.compose.animation.core.ExperimentalTransitionApi")
33+
optIn("androidx.compose.animation.ExperimentalAnimationApi")
34+
optIn("androidx.compose.animation.ExperimentalSharedTransitionApi")
35+
}
36+
}
37+
}
38+
}
39+
}
40+
41+
plugins.withType(WasmNodeJsRootPlugin::class.java) {
42+
tasks.register("rootPackageJson") {
43+
dependsOn(tasks.named("wasmRootPackageJson"))
44+
}
45+
}

kotlin-js-store/wasm/yarn.lock

Lines changed: 2886 additions & 0 deletions
Large diffs are not rendered by default.

settings.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ pluginManagement {
55
mavenCentral()
66
google()
77
gradlePluginPortal()
8+
maven { setUrl("https://redirector.kotlinlang.org/maven/dev") }
9+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
810
}
911

1012
plugins {
11-
val kotlinVersion = "2.1.20"
13+
val kotlinVersion = "2.2.0-dev-12451"
1214

1315
kotlin("multiplatform") version kotlinVersion
1416
kotlin("plugin.serialization") version kotlinVersion
@@ -21,6 +23,8 @@ dependencyResolutionManagement {
2123
repositories {
2224
mavenCentral()
2325
google()
26+
maven { setUrl("https://redirector.kotlinlang.org/maven/dev") }
27+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
2428
}
2529
}
2630

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package dev.bnorm.storyboard.core
22

3+
import androidx.compose.animation.AnimatedVisibilityScope
4+
import androidx.compose.animation.SharedTransitionScope
35
import androidx.compose.runtime.Composable
46

5-
typealias SceneContent<T> = @Composable SceneScope<T>.() -> Unit
7+
typealias SceneContent<T> =
8+
@Composable
9+
context(AnimatedVisibilityScope, SharedTransitionScope)
10+
SceneScope<T>.() -> Unit

storyboard-core/src/commonMain/kotlin/dev/bnorm/storyboard/core/SceneScope.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package dev.bnorm.storyboard.core
22

3-
import androidx.compose.animation.AnimatedVisibilityScope
4-
import androidx.compose.animation.SharedTransitionScope
53
import androidx.compose.animation.core.Transition
64
import androidx.compose.runtime.Stable
75
import dev.bnorm.storyboard.core.Frame.*
86
import kotlinx.collections.immutable.ImmutableList
97

108
@Stable
11-
sealed interface SceneScope<T> : AnimatedVisibilityScope, SharedTransitionScope {
9+
sealed interface SceneScope<T> {
1210
val states: ImmutableList<T>
1311
val frame: Transition<out Frame<T>>
1412

@@ -32,22 +30,14 @@ sealed interface SceneScope<T> : AnimatedVisibilityScope, SharedTransitionScope
3230
internal class PreviewSceneScope<T>(
3331
override val states: ImmutableList<T>,
3432
override val frame: Transition<out Frame<T>>,
35-
animatedVisibilityScope: AnimatedVisibilityScope,
36-
sharedTransitionScope: SharedTransitionScope,
37-
) : SceneScope<T>,
38-
AnimatedVisibilityScope by animatedVisibilityScope,
39-
SharedTransitionScope by sharedTransitionScope {
33+
) : SceneScope<T> {
4034
override val direction: AdvanceDirection get() = AdvanceDirection.Forward
4135
}
4236

4337
internal class StoryboardSceneScope<T>(
4438
private val storyState: StoryState,
4539
override val states: ImmutableList<T>,
4640
override val frame: Transition<out Frame<T>>,
47-
animatedVisibilityScope: AnimatedVisibilityScope,
48-
sharedTransitionScope: SharedTransitionScope,
49-
) : SceneScope<T>,
50-
AnimatedVisibilityScope by animatedVisibilityScope,
51-
SharedTransitionScope by sharedTransitionScope {
41+
) : SceneScope<T> {
5242
override val direction: AdvanceDirection get() = storyState.currentDirection
5343
}

storyboard-core/src/commonMain/kotlin/dev/bnorm/storyboard/ui/Preview.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ internal fun <T> ScenePreview(
3333
val scope = PreviewSceneScope(
3434
states = scene.states,
3535
frame = updateTransition(Frame.State(scene.states[stateIndex])),
36-
animatedVisibilityScope = this@AnimatedVisibility,
37-
sharedTransitionScope = this@SceneWrapper
3836
)
3937
scene.content(scope)
4038
}
@@ -59,8 +57,6 @@ internal fun <T> ScenePreview(
5957
val scope = PreviewSceneScope(
6058
states = scene.states,
6159
frame = updateTransition(state),
62-
animatedVisibilityScope = this@AnimatedVisibility,
63-
sharedTransitionScope = this@SceneWrapper
6460
)
6561
scene.content(scope)
6662
}

storyboard-core/src/commonMain/kotlin/dev/bnorm/storyboard/ui/StoryScene.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fun StoryScene(storyState: StoryState, modifier: Modifier = Modifier) {
3535
) { scene ->
3636
holder.SaveableStateProvider(scene) {
3737
Box(Modifier.fillMaxSize()) {
38-
SceneContent(storyState, scene, frame, this@AnimatedContent, this@SceneWrapper)
38+
SceneContent(storyState, scene, frame)
3939
}
4040
}
4141
}
@@ -44,12 +44,11 @@ fun StoryScene(storyState: StoryState, modifier: Modifier = Modifier) {
4444
}
4545

4646
@Composable
47+
context(_: AnimatedVisibilityScope, _: SharedTransitionScope)
4748
private fun <T> SceneContent(
4849
storyState: StoryState,
4950
stateScene: StoryState.StateScene<T>,
5051
frame: Transition<StoryState.StateFrame<*>>,
51-
animatedContentScope: AnimatedContentScope,
52-
sharedTransitionScope: SharedTransitionScope,
5352
) {
5453
val state = frame.createChildTransition {
5554
@Suppress("UNCHECKED_CAST")
@@ -60,13 +59,11 @@ private fun <T> SceneContent(
6059
}
6160
}
6261

63-
val scope = remember(storyState, stateScene, state, animatedContentScope, sharedTransitionScope) {
62+
val scope = remember(storyState, stateScene, state) {
6463
StoryboardSceneScope(
6564
storyState = storyState,
6665
states = stateScene.scene.states,
6766
frame = state,
68-
animatedVisibilityScope = animatedContentScope,
69-
sharedTransitionScope = sharedTransitionScope
7067
)
7168
}
7269

@@ -79,7 +76,7 @@ internal fun SceneWrapper(
7976
decorator: SceneDecorator,
8077
displayType: DisplayType,
8178
modifier: Modifier = Modifier,
82-
content: @Composable SharedTransitionScope.() -> Unit,
79+
content: @Composable context(SharedTransitionScope) () -> Unit,
8380
) {
8481
FixedSize(size = size, modifier = modifier, contentAlignment = Alignment.Center) {
8582
CompositionLocalProvider(LocalDisplayType provides displayType) {

0 commit comments

Comments
 (0)