feat(scrollable): add helper for horizontal scrollables
Adds a helper function to get horizontal scrollables with COSMIC styling.
This commit is contained in:
parent
1509163230
commit
dd1b16a353
5 changed files with 42 additions and 33 deletions
6
src/widget/scrollable/mod.rs
Normal file
6
src/widget/scrollable/mod.rs
Normal 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};
|
||||
31
src/widget/scrollable/scrollable.rs
Normal file
31
src/widget/scrollable/scrollable.rs
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue