Remove push_maybe from stack widget
This commit is contained in:
parent
8a1462b54c
commit
145534c92e
2 changed files with 16 additions and 27 deletions
|
|
@ -344,11 +344,10 @@ where
|
||||||
.background(Color::BLACK.scale_alpha(0.8))
|
.background(Color::BLACK.scale_alpha(0.8))
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(setup)
|
Some(themer(theme(), Element::from(setup).map(Event::Message)))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
};
|
||||||
.map(|setup| themer(theme(), Element::from(setup).map(Event::Message)));
|
|
||||||
|
|
||||||
let notification = self
|
let notification = self
|
||||||
.show_notification
|
.show_notification
|
||||||
|
|
@ -359,12 +358,8 @@ where
|
||||||
"Types have changed. Restart to re-enable hotpatching.",
|
"Types have changed. Restart to re-enable hotpatching.",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
|
.map(|notification| {
|
||||||
stack![view]
|
|
||||||
.height(Fill)
|
|
||||||
.push_maybe(setup.map(opaque))
|
|
||||||
.push_maybe(notification.map(|notification| {
|
|
||||||
themer(
|
themer(
|
||||||
theme(),
|
theme(),
|
||||||
bottom_right(opaque(
|
bottom_right(opaque(
|
||||||
|
|
@ -373,7 +368,11 @@ where
|
||||||
.style(container::dark),
|
.style(container::dark),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
}))
|
});
|
||||||
|
|
||||||
|
stack![view, setup, notification]
|
||||||
|
.width(Fill)
|
||||||
|
.height(Fill)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,30 +84,20 @@ where
|
||||||
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
child: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let child = child.into();
|
let child = child.into();
|
||||||
|
let child_size = child.as_widget().size_hint();
|
||||||
|
|
||||||
if self.children.is_empty() {
|
if !child_size.is_void() {
|
||||||
let child_size = child.as_widget().size_hint();
|
if self.children.is_empty() {
|
||||||
|
self.width = self.width.enclose(child_size.width);
|
||||||
|
self.height = self.height.enclose(child_size.height);
|
||||||
|
}
|
||||||
|
|
||||||
self.width = self.width.enclose(child_size.width);
|
self.children.push(child);
|
||||||
self.height = self.height.enclose(child_size.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.children.push(child);
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an element to the [`Stack`], if `Some`.
|
|
||||||
pub fn push_maybe(
|
|
||||||
self,
|
|
||||||
child: Option<impl Into<Element<'a, Message, Theme, Renderer>>>,
|
|
||||||
) -> Self {
|
|
||||||
if let Some(child) = child {
|
|
||||||
self.push(child)
|
|
||||||
} else {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extends the [`Stack`] with the given children.
|
/// Extends the [`Stack`] with the given children.
|
||||||
pub fn extend(
|
pub fn extend(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue