Skip to content

Commit

Permalink
Merge pull request #658 from zsoltk/cleanup
Browse files Browse the repository at this point in the history
Remove unused code
  • Loading branch information
zsoltk authored Jan 23, 2024
2 parents d5a2406 + c4454ad commit 6c419cf
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Modal<InteractionTarget : Any>(
revertGestureSpec = animationSpec,
),
disableAnimations: Boolean = false,
isDebug: Boolean = false,
) : BaseAppyxComponent<InteractionTarget, ModalModel.State<InteractionTarget>>(
scope = scope,
model = model,
Expand All @@ -39,6 +38,5 @@ class Modal<InteractionTarget : Any>(
backPressStrategy = backPressStrategy,
defaultAnimationSpec = animationSpec,
gestureSettleConfig = gestureSettleConfig,
disableAnimations = disableAnimations,
isDebug = isDebug
disableAnimations = disableAnimations
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class BackStack<InteractionTarget : Any>(
backPressStrategy: BackPressHandlerStrategy<InteractionTarget, BackStackModel.State<InteractionTarget>> =
PopBackstackStrategy(scope),
disableAnimations: Boolean = false,
isDebug: Boolean = false
) : BaseAppyxComponent<InteractionTarget, BackStackModel.State<InteractionTarget>>(
scope = scope,
model = model,
Expand All @@ -35,7 +34,6 @@ class BackStack<InteractionTarget : Any>(
gestureSettleConfig = gestureSettleConfig,
backPressStrategy = backPressStrategy,
defaultAnimationSpec = animationSpec,
disableAnimations = disableAnimations,
isDebug = isDebug
disableAnimations = disableAnimations
)

Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ open class Spotlight<InteractionTarget : Any>(
revertGestureSpec = animationSpec,
),
disableAnimations: Boolean = false,
isDebug: Boolean = false
) : BaseAppyxComponent<InteractionTarget, SpotlightModel.State<InteractionTarget>>(
scope = scope,
model = model,
visualisation = visualisation,
gestureFactory = gestureFactory,
defaultAnimationSpec = animationSpec,
gestureSettleConfig = gestureSettleConfig,
disableAnimations = disableAnimations,
isDebug = isDebug
disableAnimations = disableAnimations
) {
val activeIndex: StateFlow<Float> = model.output
.mapState(scope) { it.currentTargetState.activeIndex }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.bumble.appyx.interactions.core.Element
import com.bumble.appyx.interactions.core.model.backpresshandlerstrategies.BackPressHandlerStrategy
import com.bumble.appyx.interactions.core.model.backpresshandlerstrategies.DontHandleBackPress
import com.bumble.appyx.interactions.core.model.progress.AnimatedProgressController
import com.bumble.appyx.interactions.core.model.progress.DebugProgressInputSource
import com.bumble.appyx.interactions.core.model.progress.DragProgressController
import com.bumble.appyx.interactions.core.model.progress.Draggable
import com.bumble.appyx.interactions.core.model.progress.HasDefaultAnimationSpec
Expand Down Expand Up @@ -57,7 +56,6 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(
private val backPressStrategy: BackPressHandlerStrategy<InteractionTarget, ModelState> = DontHandleBackPress(),
private val animateSettle: Boolean = false,
private val disableAnimations: Boolean = false,
private val isDebug: Boolean = false
) : AppyxComponent<InteractionTarget, ModelState>,
HasDefaultAnimationSpec<Float>,
Draggable,
Expand All @@ -83,7 +81,6 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(

private val instant = InstantProgressController(model = model)
private var animated: AnimatedProgressController<InteractionTarget, ModelState>? = null
private var debug: DebugProgressInputSource<InteractionTarget, ModelState>? = null
private val drag = DragProgressController(
model = model,
gestureFactory = { _gestureFactory },
Expand Down Expand Up @@ -140,12 +137,11 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(
override fun onAddedToComposition(scope: CoroutineScope) {
animationScope = scope
createAnimatedProgressController(scope)
createdDebugInputSource()
}

override fun onRemovedFromComposition() {
// TODO finish unfinished transitions
if (isDebug) debug?.stopModel() else animated?.stopModel()
animated?.stopModel()
animationScope?.cancel()
}

Expand All @@ -158,12 +154,6 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(
)
}

private fun createdDebugInputSource() {
debug = DebugProgressInputSource(
transitionModel = model,
)
}

override fun updateContext(uiContext: UiContext) {
if (this.uiContext != uiContext) {
this.uiContext = uiContext
Expand Down Expand Up @@ -237,9 +227,7 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(
animationSpec
)
val animatedSource = animated
val debugSource = debug
when {
(isDebug && debugSource != null) -> debugSource.operation(operation)
animatedSource == null || DisableAnimations || disableAnimations -> instant.operation(
operation
)
Expand Down Expand Up @@ -281,15 +269,11 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(
}

private fun settle(gestureSettleConfig: GestureSettleConfig) {
if (isDebug) {
debug?.settle()
} else {
animated?.settle(
completionThreshold = gestureSettleConfig.completionThreshold,
completeGestureSpec = gestureSettleConfig.completeGestureSpec,
revertGestureSpec = gestureSettleConfig.revertGestureSpec,
)
}
animated?.settle(
completionThreshold = gestureSettleConfig.completionThreshold,
completeGestureSpec = gestureSettleConfig.completeGestureSpec,
revertGestureSpec = gestureSettleConfig.revertGestureSpec,
)
}

// TODO plugin?!
Expand All @@ -299,10 +283,6 @@ open class BaseAppyxComponent<InteractionTarget : Any, ModelState : Any>(
scope.cancel()
}

fun setNormalisedProgress(progress: Float) {
debug?.setNormalisedProgress(progress)
}

override fun handleBackPress(): Boolean = backPressStrategy.handleBackPress()

override fun canHandeBackPress(): StateFlow<Boolean> = backPressStrategy.canHandleBackPress
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion demos/appyx-interactions/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies {

implementation(composeBom)
implementation(project(":appyx-interactions:android"))
implementation(project(":appyx-components:stable:backstack:backstack"))
implementation(project(":appyx-components:stable:spotlight:spotlight"))
implementation(project(":appyx-components:experimental:cards:android"))
implementation(project(":appyx-components:experimental:modal:modal"))
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ open class SpotlightHero<NavTarget : Any>(
revertGestureSpec = animationSpec,
),
disableAnimations: Boolean = false,
isDebug: Boolean = false
) : BaseAppyxComponent<NavTarget, State<NavTarget>>(
scope = scope,
model = model,
Expand All @@ -43,8 +42,7 @@ open class SpotlightHero<NavTarget : Any>(
defaultAnimationSpec = animationSpec,
gestureSettleConfig = gestureSettleConfig,
disableAnimations = disableAnimations,
backPressStrategy = ExitHeroModeStrategy(scope),
isDebug = isDebug
backPressStrategy = ExitHeroModeStrategy(scope)
) {
val currentState: State<NavTarget>
get() = model.currentState
Expand Down
Loading

0 comments on commit 6c419cf

Please sign in to comment.