feat(widget): add text function with Cow<str> input

This commit is contained in:
Michael Aaron Murphy 2023-01-23 22:48:06 +01:00 committed by Michael Murphy
parent f81a06bc4a
commit b3a3c9c29a
6 changed files with 37 additions and 14 deletions

View file

@ -89,8 +89,11 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
widget.into()
}
fn title_widget(&self) -> Element<'a, Message> {
widget::container(widget::text(self.title.clone()))
fn title_widget(&mut self) -> Element<'a, Message> {
let mut title = Cow::default();
std::mem::swap(&mut title, &mut self.title);
widget::container(super::text(title))
.center_x()
.center_y()
.width(Length::Fill)
@ -106,7 +109,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
super::icon(name, size)
.force_svg(true)
.style(crate::theme::Svg::SymbolicActive)
.apply(iced::widget::button)
.apply(widget::button)
.style(theme::Button::Text)
.on_press(on_press)
};