Move all operations to widget::operation module

This commit is contained in:
Héctor Ramón Jiménez 2025-08-23 03:54:54 +02:00
parent 885d45f435
commit 34a42b5ad4
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
14 changed files with 124 additions and 136 deletions

View file

@ -37,8 +37,6 @@ use crate::core::{
Length, Padding, Pixels, Point, Rectangle, Shell, Size, Theme, Vector,
Widget,
};
use crate::runtime::Action;
use crate::runtime::task::{self, Task};
pub use operation::scrollable::{AbsoluteOffset, RelativeOffset};
@ -1262,42 +1260,6 @@ where
}
}
/// Produces a [`Task`] that snaps the [`Scrollable`] with the given [`widget::Id`]
/// to the provided [`RelativeOffset`].
pub fn snap_to<T>(
id: impl Into<widget::Id>,
offset: RelativeOffset,
) -> Task<T> {
task::effect(Action::widget(operation::scrollable::snap_to(
id.into(),
offset,
)))
}
/// Produces a [`Task`] that scrolls the [`Scrollable`] with the given [`widget::Id`]
/// to the provided [`AbsoluteOffset`].
pub fn scroll_to<T>(
id: impl Into<widget::Id>,
offset: AbsoluteOffset,
) -> Task<T> {
task::effect(Action::widget(operation::scrollable::scroll_to(
id.into(),
offset,
)))
}
/// Produces a [`Task`] that scrolls the [`Scrollable`] with the given [`widget::Id`]
/// by the provided [`AbsoluteOffset`].
pub fn scroll_by<T>(
id: impl Into<widget::Id>,
offset: AbsoluteOffset,
) -> Task<T> {
task::effect(Action::widget(operation::scrollable::scroll_by(
id.into(),
offset,
)))
}
fn notify_scroll<Message>(
state: &mut State,
on_scroll: &Option<Box<dyn Fn(Viewport) -> Message + '_>>,