From 6339225cfb0840200088c7e58736c25edc20ca9a Mon Sep 17 00:00:00 2001 From: pml68 Date: Mon, 2 Jun 2025 22:57:07 +0200 Subject: ci: fix workflow --- .github/workflows/ci.yml | 2 +- Cargo.toml | 18 +++++--------- example/Cargo.toml | 8 ------- example/src/main.rs | 61 ----------------------------------------------- examples/save.rs | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 82 deletions(-) delete mode 100644 example/Cargo.toml delete mode 100644 example/src/main.rs create mode 100644 examples/save.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daff1be..154ee76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,4 +18,4 @@ jobs: - name: Run tests run: cargo test --verbose - name: Build example - run: cargo build -p example + run: cargo build --example save diff --git a/Cargo.toml b/Cargo.toml index 18cf8a9..950adcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,20 +12,14 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"] rust-version = "1.85" [dependencies] -iced_widget.workspace = true -iced_core.workspace = true +iced_widget = { git = "https://github.com/iced-rs/iced", branch = "master" } +iced_core = { git = "https://github.com/iced-rs/iced", branch = "master", features = ["advanced"] } -[workspace.dependencies.iced_widget] -git = "https://github.com/iced-rs/iced" -branch = "master" +[dev-dependencies] +iced = { git = "https://github.com/iced-rs/iced", branch = "master" } -[workspace.dependencies.iced_core] -git = "https://github.com/iced-rs/iced" -branch = "master" -features = ["advanced"] - -[workspace] -members = ["example"] +[[example]] +name = "save" [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/example/Cargo.toml b/example/Cargo.toml deleted file mode 100644 index 7bc22dc..0000000 --- a/example/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "example" -version = "0.0.1" -edition = "2024" - -[dependencies] -iced = { git = "https://github.com/iced-rs/iced", branch = "master" } -iced_dialog = { path = ".." } diff --git a/example/src/main.rs b/example/src/main.rs deleted file mode 100644 index 659411d..0000000 --- a/example/src/main.rs +++ /dev/null @@ -1,61 +0,0 @@ -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(State::update, State::view) -} - -impl State { - fn update(&mut self, message: Message) -> Task { - 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() - } -} diff --git a/examples/save.rs b/examples/save.rs new file mode 100644 index 0000000..a7c73a2 --- /dev/null +++ b/examples/save.rs @@ -0,0 +1,62 @@ +#![allow(missing_docs)] +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(State::update, State::view) +} + +impl State { + fn update(&mut self, message: Message) -> Task { + 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() + } +} -- cgit v1.2.3