Expose styling types for scrollable in iced_web

This commit is contained in:
Héctor Ramón Jiménez 2020-02-06 00:23:44 +01:00
parent c2dad29429
commit 9a7f7bfdf5

View file

@ -1,6 +1,8 @@
//! Navigate an endless amount of content with a scrollbar.
use crate::{bumpalo, css, Align, Bus, Column, Css, Element, Length, Widget};
pub use iced_style::scrollable::{Scrollbar, Scroller, StyleSheet};
/// A widget that can vertically display an infinite amount of content with a
/// scrollbar.
#[allow(missing_debug_implementations)]
@ -9,6 +11,7 @@ pub struct Scrollable<'a, Message> {
height: Length,
max_height: u32,
content: Column<'a, Message>,
style: Box<dyn StyleSheet>,
}
impl<'a, Message> Scrollable<'a, Message> {
@ -24,6 +27,7 @@ impl<'a, Message> Scrollable<'a, Message> {
height: Length::Shrink,
max_height: u32::MAX,
content: Column::new(),
style: Default::default(),
}
}
@ -85,6 +89,14 @@ impl<'a, Message> Scrollable<'a, Message> {
self
}
/// Sets the style of the [`Scrollable`] .
///
/// [`Scrollable`]: struct.Scrollable.html
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
self.style = style.into();
self
}
/// Adds an element to the [`Scrollable`].
///
/// [`Scrollable`]: struct.Scrollable.html
@ -112,6 +124,8 @@ where
let width = css::length(self.width);
let height = css::length(self.height);
// TODO: Scrollbar styling
let node = div(bump)
.attr(
"style",
@ -126,8 +140,6 @@ where
)
.children(vec![self.content.node(bump, bus, style_sheet)]);
// TODO: Complete styling
node.finish()
}
}