Skip to content

Commit

Permalink
Merge pull request #78 from Tlaster/compose-1.5
Browse files Browse the repository at this point in the history
Compose 1.5
  • Loading branch information
Tlaster authored Jul 31, 2023
2 parents 2f384a0 + d725afd commit 513b2c5
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Apply Signing
if: ${{ github.event_name != 'pull_request' }}
Expand Down
12 changes: 6 additions & 6 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.gradle.api.JavaVersion

object Versions {
const val precompose = "1.4.4"
const val precompose = "1.5.0-beta01"
object Android {
const val min = 21
const val compile = 33
Expand All @@ -10,8 +10,8 @@ object Versions {
}

object Kotlin {
const val lang = "1.8.20"
const val coroutines = "1.7.1"
const val lang = "1.9.0"
const val coroutines = "1.7.3"
}

object Java {
Expand All @@ -21,11 +21,11 @@ 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-beta01"

object AndroidX {
const val activity = "1.7.0"
const val activity = "1.7.2"
const val appcompat = "1.6.1"
}
}
5 changes: 5 additions & 0 deletions precompose-viewmodel/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ kotlin {
implementation(compose.foundation)
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val iosMain by creating {
dependsOn(commonMain)
dependencies {
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 @@ -14,13 +15,12 @@ import moe.tlaster.precompose.ui.BackDispatcherOwner
import moe.tlaster.precompose.ui.LocalBackDispatcherOwner
import platform.UIKit.UIViewController

@Suppress("FunctionName")
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

0 comments on commit 513b2c5

Please sign in to comment.