use waterui_core::animation::Animation;
use waterui_core::{Environment, Metadata, View};
#[derive(Debug, Clone)]
pub struct CollectionTransition {
pub animation: Animation,
}
impl CollectionTransition {
#[must_use]
pub const fn new(animation: Animation) -> Self {
Self { animation }
}
}
pub fn collection_transition(content: impl View, animation: Animation) -> impl View {
CollectionTransitionScope { content, animation }
}
struct CollectionTransitionScope<V> {
content: V,
animation: Animation,
}
impl<V: View> View for CollectionTransitionScope<V> {
fn body(self, env: &Environment) -> impl View {
Metadata::new(
self.content,
env.extending(CollectionTransition::new(self.animation)),
)
}
fn stretch_axis(&self) -> waterui_core::layout::StretchAxis {
self.content.stretch_axis()
}
}