1.0.0-Beta-05
Pre-releaseChanges
Breaking changes
SlideSpecs
are now constructed directly, instead of by copy in a lambda. See the migration guide.
Version updates
- Kotlin 2.0.0.
- Compose 1.6.10.
Migration Guide
Kotlin 2.0.0
You need to add the kotlin("plugin.compose")
plugin to your projects. See the dedicated migration guide.
Note that presentations written with CuP 1.0.0-Beta-05
(or superior) must be compiled with at least Kotlin 2.0.0
and Compose 1.6.10
.
In Slide
: new way of defining SlideSpecs
If you changed the size of a particular slide, or its transitions, you would have changed its specs with:
// Correct up to 1.0.0-Beta-04
// Incorrect starting at 1.0.0-Beta-05
val mySlide by Slide(
specs = {
copy(
size = SLIDE_SIZE_16_9,
startTransitions = coolTransition
)
}
) { /*...*/ }
Using copy
meant starting form the global "default" slide specs and overriding some of its values.
This mechanism is now done for you (with a merge
function). The same code is now expressed much more concisely:
// Correct starting at 1.0.0-Beta-05
val mySlide by Slide(
specs = SlideSpecs(
size = SLIDE_SIZE_16_9,
startTransitions = coolTransition
)
) { /*...*/ }
Note that in this example we do not provide endTransitions
, which will be merged down from the default presentation specs.
In Slides
: new way of defining grouped slides inside transitions
CuP provides a way of applying specific transitions in a group of slides.
For example, this is how you would have all slides in a group use vertical transitions between them (note that this changes neither the startTransitions
of the first slide nor the endTransitions
of the last slide since this changes the transitions between the slides of the group):
// Correct up to 1.0.0-Beta-04
// Incorrect starting at 1.0.0-Beta-05
val modes = Slides(
slide1, slide2, slide3,
specs = {
copyWithInsideTransitions(
config = it,
startTransitions = TransitionSet.moveVertical,
endTransitions = TransitionSet.moveVertical
)
}
)
Due to changes in the way SlideSpecs are defined (explained in the next section), the copyWithInsideTransitions
function is replaced by insideTransitionSpecs
:
// Correct starting at 1.0.0-Beta-05
val modes = Slides(
slide1, slide2, slide3,
specs = {
it.insideTransitions(
startTransitions = TransitionSet.moveVertical,
endTransitions = TransitionSet.moveVertical
)
}
)
Note that it
is now the receiver, and no longer a parameter.
In Slides
: new way of defining grouped slides SlideSpecs
and user data
Slides
allows you to group multiple slides, and apply specific SlideSpecs
and user data to all slides in its group.
Here's how you would do that:
// Correct up to 1.0.0-Beta-04
// Incorrect starting at 1.0.0-Beta-05
val modes = Slides(
slide1, slide2, slide3,
// Make all slides in the group 16/9.
specs = { copy(size = SLIDE_SIZE_16_9) },
// Attach that data to all slides in the group.
user = MySpecificDataElement("foo-bar")
)
We have implemented two changes:
SlideSpecs
are now built directly and merged in each Slides.- user data is now built by slide, which allows you to configure it according to its
Slides.Position
.
This code is now expressed as such:
// Correct starting at 1.0.0-Beta-05
val modes = Slides(
slide1, slide2, slide3,
// Make all slides in the group 16/9.
specs = { SlideSpecs(size = SLIDE_SIZE_16_9) },
// Attach that data to all slides in the group.
user = { MySpecificDataElement("foo-bar") }
)
In essence, both specs
and user
now have the same logic :
public class Slides(
private val content: List<SlideGroup>,
private val user: ((Slides.Position) -> DataMap)? = null,
private val specs: ((Slides.Position) -> SlideSpecs)? = null
): SlideGroup
Note that you can merge SlideSpecs
together with the plus
operator.
This is how you would set inside transitions and slide size to slides in a group:
// Correct starting at 1.0.0-Beta-05
val modes = Slides(
slide1, slide2, slide3,
specs = {
it.insideTransitionSpecs(
startTransitions = TransitionSet.moveVertical,
endTransitions = TransitionSet.moveVertical
) + SlideSpecs(
size = SLIDE_SIZE_16_9
)
}
)