From b86e2076d759c3726b4406abbd61290fd41581ce Mon Sep 17 00:00:00 2001 From: pml68 Date: Sun, 30 Mar 2025 16:24:46 +0200 Subject: feat: initial commit --- src/lib.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/lib.rs (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..856a45c --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,46 @@ +//! Custom dialog for `iced` +//! +//! # Example +//! See [here](https://github.com/pml68/iced_dialog/tree/master/example) +pub mod dialog; +use dialog::Dialog; +use iced_core as core; +use iced_core::alignment::Horizontal; +use iced_widget::Button; +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>, + content: impl Into>, +) -> Dialog<'a, Message, Theme, Renderer> +where + Renderer: 'a + core::Renderer + core::text::Renderer, + Theme: 'a + dialog::Catalog, + Message: 'a + Clone, + ::Class<'a>: + From>, +{ + 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: &'a str, +) -> 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(Horizontal::Center), + ) + .height(32) + .width(core::Length::Fill) +} -- cgit v1.2.3