Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compose animation 1.5.0 crash #74

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ object Versions {

const val spotless = "6.7.0"
const val ktlint = "0.45.2"
const val compose = "1.4.2"
const val compose_jb = "1.4.0"
const val compose = "1.5.0-beta03"
const val compose_jb = "1.5.0-dev1122"

object AndroidX {
const val activity = "1.7.0"
Expand Down
1 change: 0 additions & 1 deletion precompose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ kotlin {
}
js(IR) {
browser()
binaries.executable()
}
sourceSets {
val commonMain by getting {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package moe.tlaster.precompose.navigation

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentScope
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.ContentTransform
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.with
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
Expand Down Expand Up @@ -96,16 +96,16 @@ fun NavHost(
)
}

val transitionSpec: AnimatedContentScope<BackStackEntry>.() -> ContentTransform = {
val transitionSpec: AnimatedContentTransitionScope<BackStackEntry>.() -> ContentTransform = {
val actualTransaction = run {
if (navigator.stackManager.contains(initialState)) targetState else initialState
}.navTransition ?: navTransition
if (!navigator.stackManager.contains(initialState)) {
actualTransaction.resumeTransition.with(actualTransaction.destroyTransition).apply {
actualTransaction.resumeTransition.togetherWith(actualTransaction.destroyTransition).apply {
targetContentZIndex = actualTransaction.enterTargetContentZIndex
}
} else {
actualTransaction.createTransition.with(actualTransaction.pauseTransition).apply {
actualTransaction.createTransition.togetherWith(actualTransaction.pauseTransition).apply {
targetContentZIndex = actualTransaction.exitTargetContentZIndex
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ fun NavHost(
backStackEntry,
transitionSpec = {
if (prevWasSwiped) {
EnterTransition.None with ExitTransition.None
EnterTransition.None togetherWith ExitTransition.None
} else {
transitionSpec()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package moe.tlaster.precompose

import androidx.compose.runtime.Composable
import androidx.compose.ui.createSkiaLayer
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.native.ComposeLayer
Expand Down Expand Up @@ -98,7 +97,6 @@ internal class ComposeWindow(
val layer = ComposeLayer(
layer = createSkiaLayer(),
platform = platform,
getTopLeftOffset = { Offset.Zero },
input = macosTextInputService.input
)
val title: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package moe.tlaster.precompose
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.window.Application
import androidx.compose.ui.uikit.ComposeUIViewControllerConfiguration
import androidx.compose.ui.window.ComposeUIViewController
import moe.tlaster.precompose.lifecycle.LifecycleOwner
import moe.tlaster.precompose.lifecycle.LifecycleRegistry
import moe.tlaster.precompose.lifecycle.LocalLifecycleOwner
Expand All @@ -15,12 +16,10 @@ import moe.tlaster.precompose.ui.LocalBackDispatcherOwner
import platform.UIKit.UIViewController

fun PreComposeApplication(
title: String,
configure: ComposeUIViewControllerConfiguration.() -> Unit = {},
content: @Composable () -> Unit
): UIViewController {
return Application(
title
) {
return ComposeUIViewController(configure) {
val holder = remember {
PreComposeWindowHolder()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SkikoAppDelegate : UIResponder, UIApplicationDelegateProtocol {

override fun application(application: UIApplication, didFinishLaunchingWithOptions: Map<Any?, *>?): Boolean {
window = UIWindow(frame = UIScreen.mainScreen.bounds).apply {
rootViewController = PreComposeApplication("PreCompose Molecule Sample") {
rootViewController = PreComposeApplication {
App()
}
makeKeyAndVisible()
Expand Down
2 changes: 1 addition & 1 deletion sample/todo/ios/src/uikitMain/kotlin/main.uikit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SkikoAppDelegate : UIResponder, UIApplicationDelegateProtocol {

override fun application(application: UIApplication, didFinishLaunchingWithOptions: Map<Any?, *>?): Boolean {
window = UIWindow(frame = UIScreen.mainScreen.bounds).apply {
rootViewController = PreComposeApplication("PreCompose") {
rootViewController = PreComposeApplication {
Column {
Spacer(
modifier = Modifier
Expand Down
Loading