Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Update circuit to v0.14.0 #1493

Merged
merged 2 commits into from
Aug 31, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import app.tivi.inject.AndroidApplicationComponent
import app.tivi.inject.UiComponent
import app.tivi.screens.DiscoverScreen
import com.slack.circuit.backstack.rememberSaveableBackStack
import com.slack.circuit.foundation.push
import com.slack.circuit.foundation.rememberCircuitNavigator
import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.slack.circuit.foundation.NavEvent
import com.slack.circuit.overlay.Overlay
import com.slack.circuit.overlay.OverlayHost
import com.slack.circuit.overlay.OverlayNavigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import kotlinx.coroutines.launch

class DialogOverlay<Model : Any, Result : Any>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package app.tivi.screens

import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen

@CommonParcelize
object AccountScreen : TiviScreen(name = "AccountUi()")
Expand Down
1 change: 0 additions & 1 deletion desktop-app/src/jvmMain/kotlin/app/tivi/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import app.tivi.inject.WindowComponent
import app.tivi.inject.create
import app.tivi.screens.DiscoverScreen
import com.slack.circuit.backstack.rememberSaveableBackStack
import com.slack.circuit.foundation.push
import com.slack.circuit.foundation.rememberCircuitNavigator

fun main() = application {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ agp = "8.1.1"
androidxlifecycle = "2.6.1"
androidxactivity = "1.7.2"
chucker = "4.0.0"
circuit = "0.12.1"
circuit = "0.14.0"
compose-multiplatform = "1.5.0"
coroutines = "1.7.3"
debugdrawer = "0.9.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import app.tivi.screens.AccountScreen
import app.tivi.screens.SettingsScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import kotlinx.coroutines.launch
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject
Expand All @@ -43,7 +43,6 @@ class AccountPresenter(
private val logoutTrakt: LogoutTrakt,
private val observeTraktAuthState: ObserveTraktAuthState,
private val observeUserDetails: ObserveUserDetails,

) : Presenter<AccountUiState> {

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import app.tivi.overlays.LocalNavigator
import app.tivi.screens.AccountScreen
import app.tivi.screens.SettingsScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import kotlinx.datetime.LocalDateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import app.tivi.screens.DiscoverScreen
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.overlay.LocalOverlayHost
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import app.tivi.util.Logger
import app.tivi.util.onException
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import kotlinx.coroutines.launch
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import app.tivi.screens.EpisodeTrackScreen
import com.moriatsushi.insetsx.statusBars
import com.slack.circuit.overlay.LocalOverlayHost
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import app.tivi.util.Logger
import app.tivi.util.onException
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import kotlinx.coroutines.launch
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import app.tivi.data.models.Episode
import app.tivi.data.models.Season
import app.tivi.screens.EpisodeTrackScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import kotlinx.datetime.LocalDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import app.tivi.util.Logger
import app.tivi.util.onException
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import kotlinx.coroutines.launch
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import app.tivi.screens.LibraryScreen
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.overlay.LocalOverlayHost
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import app.tivi.util.Logger
import app.tivi.util.onException
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.launch
import me.tatarka.inject.annotations.Assisted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import app.tivi.common.compose.EntryGrid
import app.tivi.common.compose.LocalStrings
import app.tivi.screens.PopularShowsScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import me.tatarka.inject.annotations.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import app.tivi.screens.PopularShowsScreen
import app.tivi.screens.ShowDetailsScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import app.tivi.common.compose.EntryGrid
import app.tivi.common.compose.LocalStrings
import app.tivi.screens.RecommendedShowsScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import com.slack.circuit.runtime.ui.ui
import me.tatarka.inject.annotations.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import app.tivi.screens.RecommendedShowsScreen
import app.tivi.screens.ShowDetailsScreen
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.screen.Screen
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,35 @@ import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.dp
import app.tivi.animations.lerp
import app.tivi.util.Logger
import com.slack.circuit.backstack.NavDecoration
import com.slack.circuit.foundation.NavigatorDefaults
import com.slack.circuit.runtime.Navigator
import kotlin.math.absoluteValue
import kotlinx.collections.immutable.ImmutableList

internal actual class GestureNavDecoration actual constructor(
private val navigator: Navigator,
logger: Logger,
) : NavDecorationWithPrevious {
) : NavDecoration {

@Composable
override fun <T> DecoratedContent(
arg: T,
previous: T?,
args: ImmutableList<T>,
backStackDepth: Int,
modifier: Modifier,
content: @Composable (T) -> Unit,
) {
if (Build.VERSION.SDK_INT < 34) {
// on API 33 and below, we just use the default decoration
DefaultDecoration.DecoratedContent(
arg = arg,
NavigatorDefaults.DefaultDecoration.DecoratedContent(
args = args,
backStackDepth = backStackDepth,
modifier = modifier,
content = content,
)
} else {
GestureDecoratedContent(
arg = arg,
previous = previous,
args = args,
backStackDepth = backStackDepth,
modifier = modifier,
content = content,
Expand All @@ -78,12 +79,14 @@ internal actual class GestureNavDecoration actual constructor(
@RequiresApi(34)
@Composable
private fun <T> GestureDecoratedContent(
arg: T,
previous: T?,
args: ImmutableList<T>,
backStackDepth: Int,
modifier: Modifier,
content: @Composable (T) -> Unit,
) {
val current = args.first()
val previous = args.getOrNull(1)

Box(modifier = modifier) {
var showPrevious by remember { mutableStateOf(false) }
var recordPoppedFromGesture by remember { mutableStateOf<T?>(null) }
Expand All @@ -100,7 +103,7 @@ internal actual class GestureNavDecoration actual constructor(
prevStackDepth = backStackDepth
}

val transition = updateTransition(targetState = arg, label = "GestureNavDecoration")
val transition = updateTransition(targetState = current, label = "GestureNavDecoration")

LaunchedEffect(transition.currentState) {
// When the current state has changed (i.e. any transition has completed),
Expand All @@ -123,7 +126,8 @@ internal actual class GestureNavDecoration actual constructor(
// come back from back stack
backStackDepth < prevStackDepth -> {
if (recordPoppedFromGesture == initialState) {
EnterTransition.None togetherWith scaleOut(targetScale = 0.8f) + fadeOut()
EnterTransition.None togetherWith
scaleOut(targetScale = 0.8f) + fadeOut()
} else {
slideInHorizontally(tween(), SlightlyLeft) + fadeIn() togetherWith
slideOutHorizontally(tween(), SlightlyRight) + fadeOut()
Expand Down
64 changes: 0 additions & 64 deletions ui/root/src/commonMain/kotlin/app/tivi/home/DefaultDecoration.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
package app.tivi.home

import app.tivi.util.Logger
import com.slack.circuit.backstack.NavDecoration
import com.slack.circuit.runtime.Navigator

internal expect class GestureNavDecoration(
navigator: Navigator,
logger: Logger,
) : NavDecorationWithPrevious
) : NavDecoration
10 changes: 6 additions & 4 deletions ui/root/src/commonMain/kotlin/app/tivi/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ import com.moriatsushi.insetsx.safeContentPadding
import com.moriatsushi.insetsx.statusBars
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.backstack.SaveableBackStack
import com.slack.circuit.foundation.screen
import com.slack.circuit.foundation.NavigableCircuitContent
import com.slack.circuit.overlay.ContentWithOverlays
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.Screen
import com.slack.circuit.runtime.screen.Screen

@Composable
internal fun Home(
Expand Down Expand Up @@ -130,10 +130,12 @@ internal fun Home(
}

ContentWithOverlays {
NavigableCircuitContentWithPrevious(
NavigableCircuitContent(
navigator = navigator,
backstack = backstack,
decoration = GestureNavDecoration(navigator, logger),
decoration = remember(navigator, logger) {
GestureNavDecoration(navigator, logger)
},
modifier = Modifier
.weight(1f)
.fillMaxHeight(),
Expand Down
Loading