use iced::widget::{container, mouse_area, stack, text};
use iced::{Color, Element, Length};
pub fn modal_backdrop<'a, Message: 'a + Clone>(
content: impl Into<Element<'a, Message>>,
on_backdrop: Message,
opacity: f32,
) -> Element<'a, Message> {
let backdrop = mouse_area(
container(text(""))
.width(Length::Fill)
.height(Length::Fill)
.style(move |_theme: &iced::Theme| container::Style {
background: Some(iced::Background::Color(Color::from_rgba(
0.0, 0.0, 0.0, opacity,
))),
..container::Style::default()
}),
)
.on_press(on_backdrop);
let centered = container(content)
.width(Length::Fill)
.height(Length::Fill)
.center_x(Length::Fill)
.center_y(Length::Fill);
stack([backdrop.into(), centered.into()]).into()
}