diff --git a/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneAdaptiveTransform.kt b/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneAdaptiveDecorator.kt similarity index 87% rename from library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneAdaptiveTransform.kt rename to library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneAdaptiveDecorator.kt index bca561a..36f5731 100644 --- a/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneAdaptiveTransform.kt +++ b/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneAdaptiveDecorator.kt @@ -25,22 +25,22 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.tunjid.treenav.Node import com.tunjid.treenav.compose.threepane.ThreePane -import com.tunjid.treenav.compose.transforms.PaneTransform -import com.tunjid.treenav.compose.transforms.paneMappingTransform +import com.tunjid.treenav.compose.panedecorators.PaneDecorator +import com.tunjid.treenav.compose.panedecorators.paneMappingDecorator /** - * An [PaneTransform] that selectively displays panes for a [ThreePane] layout + * An [PaneDecorator] that selectively displays panes for a [ThreePane] layout * based on the space available determined by the [windowWidthState]. * * @param windowWidthState provides the current width of the display in Dp. */ fun - threePanedAdaptiveTransform( + threePaneAdaptiveDecorator( windowWidthState: State, secondaryPaneBreakPoint: State = mutableStateOf(SECONDARY_PANE_MIN_WIDTH_BREAKPOINT_DP), tertiaryPaneBreakPoint: State = mutableStateOf(TERTIARY_PANE_MIN_WIDTH_BREAKPOINT_DP), -): PaneTransform = - paneMappingTransform { destination, destinationPaneMapper -> +): PaneDecorator = + paneMappingDecorator { destination, destinationPaneMapper -> val showSecondary by remember { derivedStateOf { windowWidthState.value >= secondaryPaneBreakPoint.value } } diff --git a/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/MovableSharedElementTransform.kt b/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneMovableSharedElementDecorator.kt similarity index 94% rename from library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/MovableSharedElementTransform.kt rename to library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneMovableSharedElementDecorator.kt index 28496d9..708aef0 100644 --- a/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/MovableSharedElementTransform.kt +++ b/library/compose-threepane/src/commonMain/kotlin/com/tunjid/treenav/compose/threepane/transforms/ThreePaneMovableSharedElementDecorator.kt @@ -41,11 +41,11 @@ import com.tunjid.treenav.compose.moveablesharedelement.MovableSharedElementScop import com.tunjid.treenav.compose.moveablesharedelement.PaneMovableSharedElementScope import com.tunjid.treenav.compose.moveablesharedelement.rememberPaneMovableSharedElementScope import com.tunjid.treenav.compose.threepane.ThreePane -import com.tunjid.treenav.compose.transforms.PaneTransform -import com.tunjid.treenav.compose.transforms.paneRenderTransform +import com.tunjid.treenav.compose.panedecorators.PaneDecorator +import com.tunjid.treenav.compose.panedecorators.paneRenderDecorator /** - * A [PaneTransform] that applies semantics of movable shared elements to + * A [PaneDecorator] that applies semantics of movable shared elements to * [ThreePane] layouts. * * It is an opinionated implementation that always shows the movable shared element in @@ -60,10 +60,10 @@ import com.tunjid.treenav.compose.transforms.paneRenderTransform * There should be one instance of this per [MultiPaneDisplay]. */ fun - threePanedMovableSharedElementTransform( + threePanedMovableSharedElementDecorator( movableSharedElementHostState: MovableSharedElementHostState, -): PaneTransform = - paneRenderTransform { destination, destinationPaneMapper -> +): PaneDecorator = + paneRenderDecorator { destination, destinationPaneMapper -> val delegate = rememberPaneMovableSharedElementScope( movableSharedElementHostState = movableSharedElementHostState ) @@ -82,7 +82,7 @@ fun /** * Requires that this [PaneScope] is a [MovableSharedElementScope] specifically configured for * [ThreePane] layouts and returns it. This only succeeds if the [MultiPaneDisplayState] has the - * [threePanedMovableSharedElementTransform] applied to it. + * [threePanedMovableSharedElementDecorator] applied to it. * * In the case this [PaneScope] is not the [MovableSharedElementScope] requested, an exception * will be thrown. @@ -96,7 +96,7 @@ fun PaneScope< """ The current PaneScope (${this::class.qualifiedName}) is not an instance of a ThreePaneMovableSharedElementScope. You must configure your ThreePane MultiPaneDisplay with - threePanedMovableSharedElementTransform(). + threePaneAdaptiveDecorator(). """.trimIndent() } return this diff --git a/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/MultiPaneDisplayState.kt b/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/MultiPaneDisplayState.kt index 7df2e03..3eb7953 100644 --- a/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/MultiPaneDisplayState.kt +++ b/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/MultiPaneDisplayState.kt @@ -24,9 +24,9 @@ import androidx.compose.runtime.Stable import androidx.compose.runtime.State import com.tunjid.treenav.Node import com.tunjid.treenav.compose.navigation3.runtime.NavEntry -import com.tunjid.treenav.compose.transforms.PaneMappingTransform -import com.tunjid.treenav.compose.transforms.PaneTransform -import com.tunjid.treenav.compose.transforms.PaneRenderTransform +import com.tunjid.treenav.compose.panedecorators.PaneMappingDecorator +import com.tunjid.treenav.compose.panedecorators.PaneDecorator +import com.tunjid.treenav.compose.panedecorators.PaneRenderDecorator /** * Class for configuring a [MultiPaneDisplay] for selecting, adapting and placing navigation @@ -115,14 +115,14 @@ class MultiPaneDisplayState in * @param destinationTransform a transform of the [navigationState] to its current destination. * @param popTransform a transform of the [navigationState] when back is pressed. * @param onPopped an action to perform when the navigation state has been popped to a new state. - * @param entryProvider provides the [PaneTransform]s and content needed to render + * @param entryProvider provides the [PaneDecorator]s and content needed to render * a [Destination] in its pane. - * @param transforms a list of transforms applied to every [Destination] before it is + * @param paneDecorators a list of decorators applied to every [Destination] before it is * rendered in its pane. Order matters; they are applied from last to first. */ fun MultiPaneDisplayState( panes: List, - transforms: List>, + paneDecorators: List>, navigationState: State, backStackTransform: (NavigationState) -> List, destinationTransform: (NavigationState) -> Destination, @@ -132,7 +132,7 @@ fun MultiPaneDisplayState( NoContentTransform }, entryProvider: (Destination) -> PaneEntry, -) = transforms.fold( +) = paneDecorators.fold( initial = MultiPaneDisplayState( panes = panes, navigationState = navigationState, @@ -154,7 +154,7 @@ fun MultiPaneDisplayState( private operator fun MultiPaneDisplayState.plus( - transform: PaneTransform, + transform: PaneDecorator, ): MultiPaneDisplayState = MultiPaneDisplayState( panes = panes, @@ -166,21 +166,21 @@ private operator fun transitionSpec = transitionSpec, paneEntryProvider = paneEntryProvider, destinationPanes = when (transform) { - is PaneMappingTransform -> { destination -> + is PaneMappingDecorator -> { destination -> transform.toPanesAndDestinations( destination = destination, - previousTransform = destinationPanes, + previousDecorator = destinationPanes, ) } else -> destinationPanes }, destinationContent = when (transform) { - is PaneRenderTransform -> { paneEntry, destination -> + is PaneRenderDecorator -> { paneEntry, destination -> with(transform) { Render( destination = destination, - previousTransform = previous@{ innerDestination -> + previousDecorator = previous@{ innerDestination -> destinationContent( this@previous, paneEntry, diff --git a/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/transforms/Transforms.kt b/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/panedecorators/PaneDecorator.kt similarity index 70% rename from library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/transforms/Transforms.kt rename to library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/panedecorators/PaneDecorator.kt index 3cf6312..8306f59 100644 --- a/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/transforms/Transforms.kt +++ b/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/panedecorators/PaneDecorator.kt @@ -1,4 +1,4 @@ -package com.tunjid.treenav.compose.transforms +package com.tunjid.treenav.compose.panedecorators import androidx.compose.runtime.Composable import com.tunjid.treenav.Node @@ -9,13 +9,13 @@ import com.tunjid.treenav.compose.PaneScope /** * Provides APIs for adjusting what is presented in a [MultiPaneDisplay]. */ -sealed interface PaneTransform +sealed interface PaneDecorator /** - * A [PaneTransform] that allows for changing which [Destination] shows in which [Pane]. + * A [PaneDecorator] that allows for changing which [Destination] shows in which [Pane]. */ -internal fun interface PaneMappingTransform - : PaneTransform { +internal fun interface PaneMappingDecorator + : PaneDecorator { /** * Given the current [Destination], provide what [Destination] to show in a [Pane]. @@ -23,35 +23,35 @@ internal fun interface PaneMappingTransform * back stack of the [MultiPaneDisplayState.navigationState]. * * @param destination the current [Destination] to display. - * @param previousTransform a [PaneTransform] that when invoked, returns the pane to destination + * @param previousDecorator a [PaneDecorator] that when invoked, returns the pane to destination * mapping for the current [Destination] pre-transform that can then be composed with new logic. */ @Composable fun toPanesAndDestinations( destination: Destination, - previousTransform: @Composable (Destination) -> Map, + previousDecorator: @Composable (Destination) -> Map, ): Map } /** - * A [PaneTransform] that allows for the rendering semantics of a [Destination] in a given + * A [PaneDecorator] that allows for the rendering semantics of a [Destination] in a given * [PaneScope]. */ -internal fun interface PaneRenderTransform - : PaneTransform { +internal fun interface PaneRenderDecorator + : PaneDecorator { /** * Given the current [Destination], and its [PaneScope], compose additional presentation * logic. * * @param destination the current [Destination] to display in the provided [PaneScope]. - * @param previousTransform a [PaneTransform] that when invoked, renders the [Destination] - * for the [PaneScope ]pre-transform that can then be composed with new logic. + * @param previousDecorator a [PaneDecorator] that when invoked, renders the [Destination] + * for the [PaneScope ]pre-decoration that can then be composed with new logic. */ @Composable fun PaneScope.Render( destination: Destination, - previousTransform: @Composable PaneScope.(Destination) -> Unit, + previousDecorator: @Composable PaneScope.(Destination) -> Unit, ) } @@ -67,30 +67,30 @@ internal fun interface PaneRenderTransform * - destinationPaneMapper: A lambda that when invoked, returns the pane to destination * mapping for the current [Destination] pre-transform that can then be composed with new logic. */ -fun paneMappingTransform( +fun paneMappingDecorator( mappingTransform: @Composable ( destination: Destination, - destinationPaneMapper: @Composable (Destination) -> Map + destinationPaneDecorator: @Composable (Destination) -> Map ) -> Map -): PaneTransform = - PaneMappingTransform { destination, previousTransform -> +): PaneDecorator = + PaneMappingDecorator { destination, previousTransform -> mappingTransform(destination, previousTransform) } /** - * A [PaneTransform] that allows for adjusting the rendering semantics of a [Destination] in a + * A [PaneDecorator] that allows for adjusting the rendering semantics of a [Destination] in a * for a given [Pane] in the [PaneScope]. * * @param renderTransform a lambda providing the Composable to render. It has two arguments: * - destination: The [Destination] being rendered in the provided [PaneScope]. * - destinationContent: A lambda that when invoked, renders the [Destination] pre-transform */ -fun paneRenderTransform( +fun paneRenderDecorator( renderTransform: @Composable PaneScope.( destination: Destination, destinationContent: @Composable PaneScope.(Destination) -> Unit ) -> Unit -): PaneTransform = - PaneRenderTransform { destination, previousTransform -> +): PaneDecorator = + PaneRenderDecorator { destination, previousTransform -> renderTransform(destination, previousTransform) } diff --git a/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/transforms/PaneModifierTransform.kt b/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/panedecorators/PaneModifierDecorator.kt similarity index 87% rename from library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/transforms/PaneModifierTransform.kt rename to library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/panedecorators/PaneModifierDecorator.kt index bacfb13..4240bc4 100644 --- a/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/transforms/PaneModifierTransform.kt +++ b/library/compose/src/commonMain/kotlin/com/tunjid/treenav/compose/panedecorators/PaneModifierDecorator.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.tunjid.treenav.compose.transforms +package com.tunjid.treenav.compose.panedecorators import androidx.compose.foundation.layout.Box import androidx.compose.ui.Modifier @@ -28,10 +28,10 @@ import com.tunjid.treenav.compose.PaneScope * * @param paneModifier a lambda for specifying the [Modifier] for each [Pane] in a [PaneScope]. */ -fun paneModifierTransform( +fun paneModifierDecorator( paneModifier: PaneScope.() -> Modifier = { Modifier }, -): PaneTransform = - paneRenderTransform { destination, destinationContent -> +): PaneDecorator = + paneRenderDecorator { destination, destinationContent -> Box( modifier = paneModifier() ) { diff --git a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt index da3a9f3..f70afdc 100644 --- a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt +++ b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt @@ -85,10 +85,10 @@ import com.tunjid.treenav.compose.moveablesharedelement.MovableSharedElementHost import com.tunjid.treenav.compose.multiPaneDisplayBackstack import com.tunjid.treenav.compose.navigation3.ui.NavigationEventHandler import com.tunjid.treenav.compose.threepane.ThreePane -import com.tunjid.treenav.compose.threepane.transforms.threePanedAdaptiveTransform -import com.tunjid.treenav.compose.threepane.transforms.threePanedMovableSharedElementTransform -import com.tunjid.treenav.compose.transforms.PaneTransform -import com.tunjid.treenav.compose.transforms.paneModifierTransform +import com.tunjid.treenav.compose.threepane.transforms.threePaneAdaptiveDecorator +import com.tunjid.treenav.compose.threepane.transforms.threePanedMovableSharedElementDecorator +import com.tunjid.treenav.compose.panedecorators.PaneDecorator +import com.tunjid.treenav.compose.panedecorators.paneModifierDecorator import com.tunjid.treenav.pop import com.tunjid.treenav.popToRoot import com.tunjid.treenav.requireCurrent @@ -117,7 +117,7 @@ fun App( state = appState.rememberMultiPaneDisplayState( remember { listOf( - threePanedAdaptiveTransform( + threePaneAdaptiveDecorator( secondaryPaneBreakPoint = mutableStateOf( SecondaryPaneMinWidthBreakpointDp ), @@ -128,10 +128,10 @@ fun App( appState.splitLayoutState.size } ), - threePanedMovableSharedElementTransform( + threePanedMovableSharedElementDecorator( movableSharedElementHostState = movableSharedElementHostState ), - paneModifierTransform { + paneModifierDecorator { if (paneState.pane == ThreePane.Primary && inPredictiveBack && isActive @@ -322,7 +322,7 @@ class AppState( companion object { @Composable fun AppState.rememberMultiPaneDisplayState( - transforms: List>, + paneDecorators: List>, ): MultiPaneDisplayState { val displayState = remember { MultiPaneDisplayState( @@ -345,7 +345,7 @@ class AppState( is SampleDestination.Avatar -> avatarPaneEntry() } }, - transforms = transforms, + paneDecorators = paneDecorators, ) } DisposableEffect(Unit) {