feat(scrollable): add helper for horizontal scrollables

Adds a helper function to get horizontal scrollables with COSMIC styling.
This commit is contained in:
Vukašin Vojinović 2025-04-04 17:18:13 +02:00 committed by Michael Murphy
parent 1509163230
commit dd1b16a353
5 changed files with 42 additions and 33 deletions

View file

@ -0,0 +1,6 @@
// Copyright 2022 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
mod scrollable;
pub use scrollable::{horizontal, scrollable, vertical};

View file

@ -0,0 +1,31 @@
// Copyright 2022 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use crate::{Element, Renderer};
use iced::widget;
pub fn scrollable<'a, Message>(
element: impl Into<Element<'a, Message>>,
) -> widget::Scrollable<'a, Message, crate::Theme, Renderer> {
vertical(element)
}
pub fn vertical<'a, Message>(
element: impl Into<Element<'a, Message>>,
) -> widget::Scrollable<'a, Message, crate::Theme, Renderer> {
widget::scrollable(element)
.scroller_width(8.0)
.scrollbar_width(8.0)
.scrollbar_padding(8.0)
}
pub fn horizontal<'a, Message>(
element: impl Into<Element<'a, Message>>,
) -> widget::Scrollable<'a, Message, crate::Theme, Renderer> {
widget::scrollable(element)
.direction(widget::scrollable::Direction::Horizontal(
widget::scrollable::Scrollbar::new(),
))
.scroller_width(8.0)
.scrollbar_width(8.0)
}