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