Skip to content

Commit

Permalink
Merge branch 'master' into v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arkivanov committed Jul 26, 2023
2 parents c51ef92 + 83023d7 commit 5406535
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 34 deletions.
3 changes: 3 additions & 0 deletions decompose/api/android/decompose.api
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public final class com/arkivanov/decompose/DefaultComponentContextBuilderKt {
public abstract interface annotation class com/arkivanov/decompose/ExperimentalDecomposeApi : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/arkivanov/decompose/FaultyDecomposeApi : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/arkivanov/decompose/InternalDecomposeApi : java/lang/annotation/Annotation {
}

Expand Down
3 changes: 3 additions & 0 deletions decompose/api/jvm/decompose.api
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public final class com/arkivanov/decompose/DefaultComponentContext : com/arkivan
public abstract interface annotation class com/arkivanov/decompose/ExperimentalDecomposeApi : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/arkivanov/decompose/FaultyDecomposeApi : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/arkivanov/decompose/InternalDecomposeApi : java/lang/annotation/Annotation {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ annotation class InternalDecomposeApi
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Retention(AnnotationRetention.BINARY)
annotation class ExperimentalDecomposeApi

/**
* Marks Decompose API, the implementation of which may contain bugs or known to contain bugs.
* See the docs of the annotated API for more information.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Retention(AnnotationRetention.BINARY)
annotation class FaultyDecomposeApi
2 changes: 1 addition & 1 deletion docs/extensions/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ val backDispatcher = BackDispatcher()
val componentContext =
DefaultComponentContext(
lifecycle = lifecycle,
backHandler = backHandler, // Pass BackDispatcher here
backHandler = backDispatcher, // Pass BackDispatcher here
)

val root = DefaultRootComponent(componentContext = componentContext)
Expand Down
24 changes: 0 additions & 24 deletions docs/samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,6 @@ Content:
<img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleMultiPaneDesktop.png" width="392">
<img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleMultiPaneWeb.gif" width="392">

## Sample Todo List App

<img src="https://raw.githubusercontent.com/JetBrains/compose-jb/master/examples/todoapp/screenshots/todo.png" width="384">

The Sample Todo List App demonstrates the following features:

* Multiplatform: Android, iOS, Desktop and Web
* Shared JetBrains Compose UI for Android and Desktop apps
* JetBrains (multiplatform) Compose UI for the Web browser app
* SwiftUI for iOS app
* Nested components
* Shared routing with view state preservation
* Using `Lifecycle`
* Multi-module structure (one component per module)
* Inter-component communication (via [Reaktive](https://github.com/badoo/Reaktive), just an example)
* MVI using [MVIKotlin](https://github.com/arkivanov/MVIKotlin)
* Data persistence using [SQLDelight](https://github.com/cashapp/sqldelight)

Please refer to the [sample's readme](https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/README.md) for more information.

### Source Code

The Sample Todo List App can be found in the JetBrains Compose repository [here](https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp).

## Sample Greetings App

![](media/SampleGreetingsDemo.gif)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.Child
import com.arkivanov.decompose.FaultyDecomposeApi
import com.arkivanov.decompose.router.stack.ChildStack

/**
Expand All @@ -21,9 +22,14 @@ fun interface StackAnimation<C : Any, T : Any> {
/**
* Creates an implementation of [StackAnimation] that allows different [StackAnimator]s.
*
* FaultyDecomposeApi. Please note that this API uses `movableContentOf` Compose API.
* Even though `movableContentOf` is not marked as experimental, it is known to contain bugs,
* e.g. https://issuetracker.google.com/issues/270656235, https://issuetracker.google.com/issues/290343159.
*
* @param disableInputDuringAnimation disables input and touch events while animating, default value is `true`.
* @param selector provides a [StackAnimator] for the current [Child], other [Child] and [Direction].
*/
@FaultyDecomposeApi
fun <C : Any, T : Any> stackAnimation(
disableInputDuringAnimation: Boolean = true,
selector: (child: Child.Created<C, T>, otherChild: Child.Created<C, T>, direction: Direction) -> StackAnimator?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.arkivanov.decompose.extensions.compose.jetpack.stack.animation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.Child
import com.arkivanov.decompose.FaultyDecomposeApi
import com.arkivanov.decompose.router.stack.ChildStack

/**
Expand All @@ -21,9 +22,14 @@ fun interface StackAnimation<C : Any, T : Any> {
/**
* Creates an implementation of [StackAnimation] that allows different [StackAnimator]s.
*
* FaultyDecomposeApi. Please note that this API uses `movableContentOf` Compose API.
* Even though `movableContentOf` is not marked as experimental, it is known to contain bugs,
* e.g. https://issuetracker.google.com/issues/270656235, https://issuetracker.google.com/issues/290343159.
*
* @param disableInputDuringAnimation disables input and touch events while animating, default value is `true`.
* @param selector provides a [StackAnimator] for the current [Child], other [Child] and [Direction].
*/
@FaultyDecomposeApi
fun <C : Any, T : Any> stackAnimation(
disableInputDuringAnimation: Boolean = true,
selector: (child: Child.Created<C, T>, otherChild: Child.Created<C, T>, direction: Direction) -> StackAnimator?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.fade
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.isFront
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.plus
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.predictiveBackAnimation
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.scale
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.slide
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation
import com.arkivanov.decompose.router.stack.ChildStack
import com.arkivanov.decompose.value.MutableValue
Expand All @@ -30,13 +28,15 @@ internal fun CountersContent(component: CountersComponent, modifier: Modifier =
modifier = modifier,
animation = predictiveBackAnimation(
backHandler = component.backHandler,
animation = stackAnimation { _, _, direction ->
if (direction.isFront) {
slide() + fade()
} else {
scale(frontFactor = 1F, backFactor = 0.7F) + fade()
}
},
// Workaround for https://issuetracker.google.com/issues/270656235
animation = stackAnimation(fade() + scale()),
// animation = stackAnimation { _, _, direction ->
// if (direction.isFront) {
// slide() + fade()
// } else {
// scale(frontFactor = 1F, backFactor = 0.7F) + fade()
// }
// },
onBack = component::onBackClicked,
),
) {
Expand Down

0 comments on commit 5406535

Please sign in to comment.