aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2025-07-04 02:19:03 +0200
committerpml68 <contact@pml68.dev>2025-07-04 02:19:40 +0200
commit38cccdd09ebef0c8eefded8c3d817b43ecae2049 (patch)
tree6297aaa3252071db5d77acbad91c1d5f40706091
parentfeat: simplify the internal `view` method (diff)
downloadiced_dialog-38cccdd09ebef0c8eefded8c3d817b43ecae2049.tar.gz
doc: use `README` as crate documentation
-rw-r--r--README.md2
-rw-r--r--src/lib.rs67
2 files changed, 2 insertions, 67 deletions
diff --git a/README.md b/README.md
index 668abfb..a4d971c 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ It's mostly the dialog from @frgp42's [Fluent Iced Gallery](https://github.com/f
## Example
-```rust
+```rust,no_run
use iced::{
Element, Length, Task,
widget::{button, center, column, text},
diff --git a/src/lib.rs b/src/lib.rs
index 1e536a4..46cbe94 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,69 +1,4 @@
-//! Custom dialog for `iced`
-//!
-//! # Example
-//! ```no_run
-//! use iced::{
-//! Element, Length, Task,
-//! widget::{button, center, column, text},
-//! };
-//! use iced_dialog::dialog;
-//!
-//! #[derive(Default)]
-//! struct State {
-//! is_open: bool,
-//! action_text: String,
-//! }
-//!
-//! #[derive(Debug, Clone)]
-//! enum Message {
-//! OpenDialog,
-//! Saved,
-//! Cancelled,
-//! }
-//!
-//! fn main() -> iced::Result {
-//! iced::run("Dialog Example", State::update, State::view)
-//! }
-//!
-//! impl State {
-//! fn update(&mut self, message: Message) -> Task<Message> {
-//! match message {
-//! Message::OpenDialog => self.is_open = true,
-//! Message::Saved => {
-//! self.action_text = "User saved their work".to_owned();
-//! self.is_open = false;
-//! }
-//! Message::Cancelled => {
-//! self.action_text = "User cancelled the dialog".to_owned();
-//! self.is_open = false;
-//! }
-//! }
-//! Task::none()
-//! }
-//!
-//! fn view(&self) -> Element<'_, Message> {
-//! let base = center(
-//! column![
-//! text(&self.action_text),
-//! button("Open Dialog").on_press(Message::OpenDialog)
-//! ]
-//! .spacing(14.0),
-//! )
-//! .width(Length::Fill)
-//! .height(Length::Fill);
-//!
-//! let dialog_content = text("Do you want to save?");
-//!
-//! dialog(self.is_open, base, dialog_content)
-//! .title("Save")
-//! .push_button(iced_dialog::button("Save", Message::Saved))
-//! .push_button(iced_dialog::button("Cancel", Message::Cancelled))
-//! .width(350)
-//! .height(234)
-//! .into()
-//! }
-//! }
-//! ```
+#![doc = include_str!("../README.md")]
pub mod dialog;
pub use dialog::Dialog;
use iced_core as core;