Skip to main content

iced_dialog/
lib.rs

1//! Custom dialog for [`iced`](https://iced.rs)
2//!
3//! It's mostly the dialog from @frgp42's [Fluent Iced Gallery](https://github.com/frgp42/fluent_iced_gallery), but made into a "widget".
4
5pub mod dialog;
6pub use dialog::Dialog;
7use iced_widget::{Button, core, text};
8
9/// Creates a new [`Dialog`] with the given base and dialog content.
10pub fn dialog<'a, Message, Base, Content, Theme, Renderer>(
11    is_open: bool,
12    base: Base,
13    content: Content,
14) -> Dialog<'a, Message, Base, Content, Theme, Renderer>
15where
16    Message: 'a + Clone,
17    Theme: 'a + dialog::Catalog,
18    Renderer: 'a + core::text::Renderer,
19{
20    Dialog::new(is_open, base, content)
21}
22
23/// Pre-styled [`Button`] for [`Dialog`]s.
24pub fn button<'a, Message, Theme>(
25    content: impl text::IntoFragment<'a>,
26    message: Message,
27) -> Button<'a, Message, text::Text<'a, Theme>, Theme>
28where
29    Theme: 'a + iced_widget::button::Catalog + text::Catalog,
30{
31    iced_widget::button(
32        text(content)
33            .size(14)
34            .line_height(text::LineHeight::Absolute(core::Pixels(20.0)))
35            .align_x(core::Alignment::Center),
36    )
37    .on_press(message)
38    .height(32)
39    .width(core::Length::Fill)
40}