Reintroduce old text helper as value helper
This commit is contained in:
parent
1d83e59e8a
commit
b8d5df2817
2 changed files with 16 additions and 9 deletions
|
|
@ -2,7 +2,7 @@ mod echo;
|
||||||
|
|
||||||
use iced::alignment::{self, Alignment};
|
use iced::alignment::{self, Alignment};
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
button, column, container, row, scrollable, text, text_input,
|
button, column, container, row, scrollable, text, text_input, value,
|
||||||
};
|
};
|
||||||
use iced::{color, Command, Element, Length, Subscription};
|
use iced::{color, Command, Element, Length, Subscription};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
@ -96,14 +96,8 @@ impl WebSocket {
|
||||||
.into()
|
.into()
|
||||||
} else {
|
} else {
|
||||||
scrollable(
|
scrollable(
|
||||||
column(
|
column(self.messages.iter().map(value).map(Element::from))
|
||||||
self.messages
|
.spacing(10),
|
||||||
.iter()
|
|
||||||
.map(ToString::to_string)
|
|
||||||
.map(text)
|
|
||||||
.map(Element::from),
|
|
||||||
)
|
|
||||||
.spacing(10),
|
|
||||||
)
|
)
|
||||||
.id(MESSAGE_LOG.clone())
|
.id(MESSAGE_LOG.clone())
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,19 @@ where
|
||||||
Text::new(text)
|
Text::new(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new [`Text`] widget that displays the provided value.
|
||||||
|
///
|
||||||
|
/// [`Text`]: core::widget::Text
|
||||||
|
pub fn value<'a, Theme, Renderer>(
|
||||||
|
value: impl ToString,
|
||||||
|
) -> Text<'a, Theme, Renderer>
|
||||||
|
where
|
||||||
|
Theme: text::Catalog + 'a,
|
||||||
|
Renderer: core::text::Renderer,
|
||||||
|
{
|
||||||
|
Text::new(value.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a new [`Checkbox`].
|
/// Creates a new [`Checkbox`].
|
||||||
///
|
///
|
||||||
/// [`Checkbox`]: crate::Checkbox
|
/// [`Checkbox`]: crate::Checkbox
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue