iced_dialog/
lib.rs

1#![doc = include_str!("../README.md")]
2pub mod dialog;
3pub use dialog::Dialog;
4use iced_widget::Button;
5use iced_widget::core;
6use iced_widget::{container, text};
7
8/// Creates a new [`Dialog`] with the given base and dialog content.
9pub fn dialog<'a, Message, Theme, Renderer>(
10    is_open: bool,
11    base: impl Into<core::Element<'a, Message, Theme, Renderer>>,
12    content: impl Into<core::Element<'a, Message, Theme, Renderer>>,
13) -> Dialog<'a, Message, Theme, Renderer>
14where
15    Renderer: 'a + core::Renderer + core::text::Renderer,
16    Theme: 'a + dialog::Catalog,
17    Message: 'a + Clone,
18    <Theme as container::Catalog>::Class<'a>:
19        From<container::StyleFn<'a, Theme>>,
20{
21    Dialog::new(is_open, base, content)
22}
23
24/// Pre-styled [`Button`] for [`Dialog`]s.
25///
26/// [`Button`]: https://docs.iced.rs/iced/widget/struct.Button.html
27pub fn button<'a, Message, Theme, Renderer>(
28    content: &'a str,
29    message: Message,
30) -> Button<'a, Message, Theme, Renderer>
31where
32    Theme: 'a + iced_widget::button::Catalog + text::Catalog,
33    Renderer: 'a + core::Renderer + core::text::Renderer,
34{
35    iced_widget::button(
36        text(content)
37            .size(14)
38            .line_height(text::LineHeight::Absolute(core::Pixels(20.0)))
39            .align_x(core::Alignment::Center),
40    )
41    .on_press(message)
42    .height(32)
43    .width(core::Length::Fill)
44}