diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e554530..87b23d1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changes +- Split removed in favor of Iced pane grid +- Modal and Floating element removed in favor of Iced Stack. +- Segmented Button Removed use iced button. +- cupertino Removed as we are not going to support these anymore. + ## [0.9.3] - 2024-05-08 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index ea91bb44..2f7869a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,23 +20,19 @@ card = [] date_picker = ["chrono", "once_cell", "icons"] color_picker = ["icons", "iced/canvas"] cupertino = ["time", "iced/canvas", "icons"] -floating_element = [] grid = ["itertools"] glow = [] # TODO icons = [] -modal = [] tab_bar = [] tabs = ["tab_bar"] time_picker = ["chrono", "icons", "iced/canvas"] wrap = [] number_input = ["num-format", "num-traits"] selection_list = [] -split = [] menu = [] quad = [] spinner = [] context_menu = [] -segmented_button = [] slide_bar = [] drop_down = [] @@ -46,21 +42,16 @@ default = [ #"number_input", #"date_picker", #"color_picker", - #"floating_element", #"grid", - #"modal", #"tab_bar", #"tabs", #"time_picker", #"slide_bar", #"wrap", #"selection_list", - #"split", #"quad", #"context_menu", #"spinner", - #"cupertino", - #"segmented_button", #"drop_down", #"menu", ] @@ -90,29 +81,17 @@ members = [ #"examples/card", #"examples/number_input", #"examples/color_picker", - #"examples/floating_element", - #"examples/floating_element multioverlay", - #"examples/floating_element_anchors", #"examples/font_loading", #"examples/grid", - #"examples/modal", - #"examples/modal_component", - #"examples/multiple_modals", #"examples/tab_bar", #"examples/tabs", #"examples/time_picker", #"examples/sliderbar", #"examples/wrap", #"examples/selection_list", - #"examples/split", - #"examples/split_scroller", #"examples/context_menu", #"examples/spinner", - #"examples/cupertino/cupertino_button", - #"examples/cupertino/cupertino_spinner", - #"examples/cupertino/cupertino_switch", #"examples/WidgetIDReturn", - #"examples/segmented_button", #"examples/drop_down", #"examples/menu", ] diff --git a/examples/cupertino/cupertino_button/Cargo.toml b/examples/cupertino/cupertino_button/Cargo.toml deleted file mode 100644 index c6005f88..00000000 --- a/examples/cupertino/cupertino_button/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "cupertino-button" -version = "0.1.0" -authors = ["Brett Byler "] -edition = "2021" -publish = false - -[dependencies] -iced.workspace = true -iced_aw = { path = "../../../", features = ["cupertino"] } - diff --git a/examples/cupertino/cupertino_button/Makefile b/examples/cupertino/cupertino_button/Makefile deleted file mode 100644 index b355ad83..00000000 --- a/examples/cupertino/cupertino_button/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SHELL := /bin/bash - -run: - cargo run --package cupertino-button - -.ONESHELL: - diff --git a/examples/cupertino/cupertino_button/README.md b/examples/cupertino/cupertino_button/README.md deleted file mode 100644 index 5d0c5f9a..00000000 --- a/examples/cupertino/cupertino_button/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Cupertino Button Example -========================= - -An application that uses the `CupertinoAlert` widget to draw a -switch. - -The __[`main`]__ file contains all the code of the example. - -You can run it with `cargo run`: - -```bash -cargo run --package cupertino-button - -# Or -make run -``` - -[`main`]: src/main.rs - diff --git a/examples/cupertino/cupertino_button/src/main.rs b/examples/cupertino/cupertino_button/src/main.rs deleted file mode 100644 index 47d76615..00000000 --- a/examples/cupertino/cupertino_button/src/main.rs +++ /dev/null @@ -1,130 +0,0 @@ -use iced::{ - alignment, executor, font, - widget::{column, container, text, Text}, - Application, Command, Element, Length, Settings, Theme, -}; - -use iced_aw::widgets::cupertino::cupertino_button::CupertinoButton; - -pub fn main() -> iced::Result { - ButtonApp::run(Settings { - antialiasing: true, - ..Settings::default() - }) -} - -enum ButtonApp { - Loading, - EnabledButtonClicked, - EnabledFilledButtonClicked, -} - -#[derive(Debug, Clone)] -enum Message { - EnabledButtonClicked, - EnabledFilledButtonClicked, - #[allow(dead_code)] - Loaded(Result<(), String>), - FontLoaded(Result<(), font::Error>), -} - -async fn load() -> Result<(), String> { - Ok(()) -} - -// `cargo fmt` becomes unreadable for this example, so switching off // -#[rustfmt::skip] -impl Application for ButtonApp { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command) { - (ButtonApp::Loading, Command::batch(vec![ - font::load(iced_aw::SF_UI_ROUNDED_BYTES).map(Message::FontLoaded), - Command::perform(load(), Message::Loaded), - ])) - } - - fn title(&self) -> String { - String::from("CupertinoButton - Iced") - } - - fn update(&mut self, message: Message) -> Command { - match message { - Message::EnabledButtonClicked => { - println!("You clicked the enabled button!"); - *self = ButtonApp::EnabledButtonClicked; - }, - - Message::EnabledFilledButtonClicked => { - println!("You clicked the filled enabled button!"); - *self = ButtonApp::EnabledFilledButtonClicked; - }, - _ => {} - } - - Command::none() - } - - fn view(&self) -> Element { - let disabled = CupertinoButton::new() - .on_pressed(None) - .body(Text::new("Disabled") - .size(24) - .horizontal_alignment(alignment::Horizontal::Center) - .width(Length::Fixed(100.0)) - .height(Length::Fixed(50.0)) - ); - - let disabled_filled = CupertinoButton::new() - .on_pressed(None) - .is_filled(true) - .body(Text::new("Disabled") - .size(24) - .horizontal_alignment(alignment::Horizontal::Center) - .width(Length::Fixed(200.0)) - .height(Length::Fixed(50.0)) - ); - - let enabled = CupertinoButton::new() - .on_pressed(Some(Message::EnabledButtonClicked)) - .body(Text::new("Enabled") - .size(24) - .horizontal_alignment(alignment::Horizontal::Center) - .width(Length::Fixed(100.0)) - .height(Length::Fixed(50.0)) - ); - - let enabled_filled = CupertinoButton::new() - .on_pressed(Some(Message::EnabledFilledButtonClicked)) - .is_filled(true) - .body(Text::new("Enabled") - .size(24) - .horizontal_alignment(alignment::Horizontal::Center) - .width(Length::Fixed(200.0)) - .height(Length::Fixed(50.0)) - ); - - container(column![ - text("Cupertino Button Example!") - .width(Length::Fill) - .height(Length::Fixed(100.0)) - .horizontal_alignment(alignment::Horizontal::Center) - .vertical_alignment(alignment::Vertical::Center), - - disabled, - disabled_filled, - enabled, - enabled_filled, - ].width(Length::Fill).align_items(alignment::Horizontal::Center.into())) - .center_y() - .height(Length::Fill) - .into() - } - - fn theme(&self) -> Self::Theme { - Theme::Light - } -} diff --git a/examples/cupertino/cupertino_spinner/Cargo.toml b/examples/cupertino/cupertino_spinner/Cargo.toml deleted file mode 100644 index 28c1d387..00000000 --- a/examples/cupertino/cupertino_spinner/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "cupertino-spinner" -version = "0.1.0" -authors = ["Brett Byler "] -edition = "2021" -publish = false - -[dependencies] -iced = { workspace = true, features = ["tokio"] } -iced_aw = { path = "../../../", features = ["cupertino"] } -tokio = { version = "1.29.1", features = ["time"] } diff --git a/examples/cupertino/cupertino_spinner/Makefile b/examples/cupertino/cupertino_spinner/Makefile deleted file mode 100644 index 5ac15146..00000000 --- a/examples/cupertino/cupertino_spinner/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SHELL := /bin/bash - -run: - cargo run --package cupertino-spinner - -.ONESHELL: - diff --git a/examples/cupertino/cupertino_spinner/README.md b/examples/cupertino/cupertino_spinner/README.md deleted file mode 100644 index 5764d73a..00000000 --- a/examples/cupertino/cupertino_spinner/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Cupertino Spinner Example -========================= - -An application that uses the `CupertinoSpinner` widget to draw a -spinner. - -The __[`main`]__ file contains all the code of the example. - -You can run it with `cargo run`: - -```bash -cargo run --package cupertino-spinner - -# Or -make run -``` - -[`main`]: src/main.rs - diff --git a/examples/cupertino/cupertino_spinner/src/main.rs b/examples/cupertino/cupertino_spinner/src/main.rs deleted file mode 100644 index 16873f98..00000000 --- a/examples/cupertino/cupertino_spinner/src/main.rs +++ /dev/null @@ -1,89 +0,0 @@ -use iced::alignment; -use iced::widget::{column, container, text}; -use iced::{executor, Application, Command, Element, Length, Settings, Theme}; -use iced_aw::widgets::cupertino::cupertino_spinner::CupertinoSpinner; - -pub fn main() -> iced::Result { - Spinner::run(Settings { - antialiasing: true, - ..Settings::default() - }) -} - -#[derive(Debug, Clone)] -struct State { - hello: String, -} - -enum Spinner { - Loading, - Loaded(State), -} - -#[derive(Debug, Clone)] -enum Message { - Loaded(Result), -} - -impl State { - async fn load() -> Result { - println!("Doing stuff..."); - tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; - Ok(Self { - hello: "Loaded!".to_string(), - }) - } -} - -impl Application for Spinner { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command) { - ( - Spinner::Loading, - Command::perform(State::load(), Message::Loaded), - ) - } - - fn title(&self) -> String { - String::from("CupertinoSpinner - Iced") - } - - fn update(&mut self, message: Message) -> Command { - if let Spinner::Loading = self { - if let Message::Loaded(Ok(state)) = message { - *self = Spinner::Loaded(State { hello: state.hello }); - } - } - - Command::none() - } - - fn view(&self) -> Element { - match self { - Spinner::Loading => container( - CupertinoSpinner::new() - .width(Length::Fill) - .height(Length::Fill), - ) - .into(), - - Spinner::Loaded(state) => container(column![text(&state.hello) - .width(Length::Fill) - .size(25) - .horizontal_alignment(alignment::Horizontal::Center) - .vertical_alignment(alignment::Vertical::Center)]) - .width(Length::Fill) - .height(Length::Fill) - .center_y() - .into(), - } - } - - fn theme(&self) -> Self::Theme { - Theme::Light - } -} diff --git a/examples/cupertino/cupertino_switch/Cargo.toml b/examples/cupertino/cupertino_switch/Cargo.toml deleted file mode 100644 index 56e41569..00000000 --- a/examples/cupertino/cupertino_switch/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "cupertino-switch" -version = "0.1.0" -authors = ["Brett Byler "] -edition = "2021" -publish = false - -[dependencies] -iced.workspace = true -iced_aw = { path = "../../../", features = ["cupertino"] } - diff --git a/examples/cupertino/cupertino_switch/Makefile b/examples/cupertino/cupertino_switch/Makefile deleted file mode 100644 index 507dac78..00000000 --- a/examples/cupertino/cupertino_switch/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SHELL := /bin/bash - -run: - cargo run --package cupertino-switch - -.ONESHELL: - diff --git a/examples/cupertino/cupertino_switch/README.md b/examples/cupertino/cupertino_switch/README.md deleted file mode 100644 index f257e83a..00000000 --- a/examples/cupertino/cupertino_switch/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Cupertino Switch Example -========================= - -An application that uses the `CupertinoSwitch` widget to draw a -switch. - -The __[`main`]__ file contains all the code of the example. - -You can run it with `cargo run`: - -```bash -cargo run --package cupertino-switch - -# Or -make run -``` - -[`main`]: src/main.rs - diff --git a/examples/cupertino/cupertino_switch/src/main.rs b/examples/cupertino/cupertino_switch/src/main.rs deleted file mode 100644 index bb92c4f4..00000000 --- a/examples/cupertino/cupertino_switch/src/main.rs +++ /dev/null @@ -1,113 +0,0 @@ -use iced::widget::{column, container, row, text}; -use iced::{alignment, executor, Application, Color, Command, Element, Length, Settings, Theme}; -use iced_aw::widgets::cupertino::cupertino_switch::CupertinoSwitch; - -pub fn main() -> iced::Result { - Switch::run(Settings { - antialiasing: true, - ..Settings::default() - }) -} - -enum Switch { - Loading, - LeftSwitchChanged(bool), - RightSwitchChanged(bool), -} - -#[derive(Debug, Clone)] -enum Message { - LeftSwitchChanged(bool), - RightSwitchChanged(bool), -} - -// `cargo fmt` becomes unreadable for this example, so switching off // -#[rustfmt::skip] -impl Application for Switch { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command) { - (Switch::Loading, Command::none()) - } - - fn title(&self) -> String { - String::from("CupertinoSwitch - Iced") - } - - fn update(&mut self, message: Message) -> Command { - match message { - Message::LeftSwitchChanged(value) => *self = Switch::LeftSwitchChanged(value), - Message::RightSwitchChanged(value) => *self = Switch::RightSwitchChanged(value), - } - - Command::none() - } - - fn view(&self) -> Element { - let toggle_1: CupertinoSwitch = CupertinoSwitch::new().on_changed(Some(Box::new( - Message::LeftSwitchChanged - ))).value(match self { - Switch::LeftSwitchChanged(v) => *v, - _ => true, - }); - - let toggle_2: CupertinoSwitch = CupertinoSwitch::new() - .value(match self { - Switch::LeftSwitchChanged(v) => *v, - _ => false, - }) - .on_changed(Some(Box::new(Message::RightSwitchChanged))); - - let left_text: String = match self { - Switch::LeftSwitchChanged(v) => format!("Left Toggle State: {}", v), - _ => format!("Left Toggle State: {}", toggle_1.value), - }; - - let right_text: String = match self { - Switch::RightSwitchChanged(v) => format!("Right Toggle State: {}", v), - _ => format!("Right Toggle State: {}", toggle_2.value), - }; - - let content = row![ - toggle_1, - - container(column![ - text(left_text) - .width(Length::Shrink) - .size(25) - .horizontal_alignment(alignment::Horizontal::Center) - .vertical_alignment(alignment::Vertical::Center), - - text(right_text) - .width(Length::Shrink) - .size(25) - .horizontal_alignment(alignment::Horizontal::Center) - .vertical_alignment(alignment::Vertical::Center), - ]).width(Length::Shrink).center_y(), - - toggle_2, - ].spacing(100).align_items(alignment::Alignment::Center).width(Length::Shrink); - - // No effect, but here for demonstrative purposes // - let style: fn(&iced::Theme) -> container::Appearance = |_theme| container::Appearance { - background: Some(Color::TRANSPARENT.into()), - ..Default::default() - }; - // - - container(content) - .center_x() - .center_y() - .width(Length::Fill) - .height(Length::Fill) - .style(style) - .into() - } - - fn theme(&self) -> Self::Theme { - Theme::Light - } -} diff --git a/examples/floating_element multioverlay/Cargo.toml b/examples/floating_element multioverlay/Cargo.toml deleted file mode 100644 index c2e64ff9..00000000 --- a/examples/floating_element multioverlay/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "floating_element_overlay" -version = "0.1.0" -authors = ["Kaiden42 "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = [ - "floating_element", - "icons", -] } -iced.workspace=true diff --git a/examples/floating_element multioverlay/src/main.rs b/examples/floating_element multioverlay/src/main.rs deleted file mode 100644 index 6c0eb98a..00000000 --- a/examples/floating_element multioverlay/src/main.rs +++ /dev/null @@ -1,195 +0,0 @@ -use iced::widget::button; -use iced::widget::button::Appearance; -use iced::{ - alignment, font, theme, - widget::{container, text, Button, Container, PickList, Text}, - Application, Command, Element, Length, Settings, Theme, -}; - -use iced_aw::core::icons::bootstrap::icon_to_string; -use iced_aw::floating_element::Anchor; -use iced_aw::Bootstrap; -use iced_aw::{helpers::floating_element, BOOTSTRAP_FONT}; - -fn main() -> iced::Result { - FloatingElementExample::run(Settings::default()) -} - -#[derive(Debug, Clone)] -enum Message { - ButtonPressed, - #[allow(dead_code)] - Loaded(Result<(), String>), - FontLoaded(Result<(), font::Error>), - LanguageSelected(Language), -} - -#[derive(Debug)] -enum FloatingElementExample { - Loading, - Loaded(State), -} - -#[derive(Debug)] -struct State { - selected_language: Option, -} - -async fn load() -> Result<(), String> { - Ok(()) -} - -impl Application for FloatingElementExample { - type Message = Message; - type Theme = Theme; - type Executor = iced::executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (FloatingElementExample, Command) { - ( - FloatingElementExample::Loading, - Command::batch(vec![ - font::load(iced_aw::BOOTSTRAP_FONT_BYTES).map(Message::FontLoaded), - Command::perform(load(), Message::Loaded), - ]), - ) - } - - fn title(&self) -> String { - String::from("FloatingButton example") - } - - fn update(&mut self, message: Message) -> Command { - match self { - FloatingElementExample::Loading => { - if let Message::Loaded(_) = message { - *self = FloatingElementExample::Loaded(State { - selected_language: None, - }) - } - } - FloatingElementExample::Loaded(State { selected_language }) => match message { - Message::ButtonPressed => println!("Test 123 added new line"), - Message::LanguageSelected(language) => *selected_language = Some(language), - _ => {} - }, - } - - Command::none() - } - - fn view(&self) -> Element { - match self { - FloatingElementExample::Loading => container( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .width(Length::Fill) - .height(Length::Fill) - .center_y() - .center_x() - .into(), - FloatingElementExample::Loaded(State { selected_language }) => { - let content = floating_element( - Container::new(PickList::new( - &Language::ALL[..], - *selected_language, - Message::LanguageSelected, - )) - .width(Length::Fill) - .height(Length::Fill) - .max_width(400) - .max_height(600) - .style(theme::Container::Box), - Button::new( - Text::new(icon_to_string(Bootstrap::Plus)) - .font(BOOTSTRAP_FONT) - .size(35) - .line_height(1.0) - .shaping(text::Shaping::Advanced), - ) - .on_press(Message::ButtonPressed) - .padding(5) - .style(theme::Button::Custom(Box::new( - CircleButtonStyle::new(theme::Button::Primary), - ))), - ) - .anchor(Anchor::SouthEast) - .offset(20.0) - .hide(false); - - Container::new(content) - .width(Length::Fill) - .height(Length::Fill) - .padding(10) - .center_x() - .center_y() - .into() - } - } - } -} - -struct CircleButtonStyle { - theme: theme::Button, -} - -impl CircleButtonStyle { - pub fn new(theme: theme::Button) -> Self { - Self { theme } - } -} - -impl button::StyleSheet for CircleButtonStyle { - type Style = Theme; - - fn active(&self, style: &Self::Style) -> Appearance { - let mut appearance = style.active(&self.theme); - appearance.border.radius = 25.0.into(); - - appearance - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] -pub enum Language { - #[default] - Rust, - Elm, - Ruby, - Haskell, - C, - Javascript, - Other, -} - -impl Language { - const ALL: [Language; 7] = [ - Language::C, - Language::Elm, - Language::Ruby, - Language::Haskell, - Language::Rust, - Language::Javascript, - Language::Other, - ]; -} - -impl std::fmt::Display for Language { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - match self { - Language::Rust => "Rust", - Language::Elm => "Elm", - Language::Ruby => "Ruby", - Language::Haskell => "Haskell", - Language::C => "C", - Language::Javascript => "Javascript", - Language::Other => "Some other language", - } - ) - } -} diff --git a/examples/floating_element/Cargo.toml b/examples/floating_element/Cargo.toml deleted file mode 100644 index adef06b8..00000000 --- a/examples/floating_element/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "floating_element" -version = "0.1.0" -authors = ["Kaiden42 "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = [ - "floating_element", - "icons", -] } -iced.workspace = true \ No newline at end of file diff --git a/examples/floating_element/src/main.rs b/examples/floating_element/src/main.rs deleted file mode 100644 index c9b501f4..00000000 --- a/examples/floating_element/src/main.rs +++ /dev/null @@ -1,180 +0,0 @@ -use iced::widget::button; -use iced::widget::button::Appearance; -use iced::{ - alignment, font, theme, - widget::{container, text, Button, Column, Container, Scrollable, Text}, - Application, Command, Element, Length, Settings, Theme, -}; - -use iced_aw::core::icons::bootstrap::icon_to_string; -use iced_aw::floating_element::Anchor; -use iced_aw::Bootstrap; -use iced_aw::{helpers::floating_element, BOOTSTRAP_FONT}; - -fn main() -> iced::Result { - FloatingElementExample::run(Settings::default()) -} - -#[derive(Debug, Clone)] -enum Message { - ButtonPressed, - #[allow(dead_code)] - Loaded(Result<(), String>), - FontLoaded(Result<(), font::Error>), -} - -#[derive(Debug)] -enum FloatingElementExample { - Loading, - Loaded(State), -} - -#[derive(Debug)] -struct State { - lines: Vec, -} - -async fn load() -> Result<(), String> { - Ok(()) -} - -impl Application for FloatingElementExample { - type Message = Message; - type Theme = Theme; - type Executor = iced::executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (FloatingElementExample, Command) { - ( - FloatingElementExample::Loading, - Command::batch(vec![ - font::load(iced_aw::BOOTSTRAP_FONT_BYTES).map(Message::FontLoaded), - Command::perform(load(), Message::Loaded), - ]), - ) - } - - fn title(&self) -> String { - String::from("FloatingButton example") - } - - fn update(&mut self, message: Message) -> Command { - match self { - FloatingElementExample::Loading => { - if let Message::Loaded(_) = message { - *self = FloatingElementExample::Loaded(State { - lines: (0..3000) - .map(|_| "This is a newly added line.".into()) - .collect(), - }) - } - } - FloatingElementExample::Loaded(State { lines }) => { - if let Message::ButtonPressed = message { - lines.push("This is a newly added line.".into()); - } - } - } - - Command::none() - } - - fn view(&self) -> Element { - match self { - FloatingElementExample::Loading => container( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .width(Length::Fill) - .height(Length::Fill) - .center_y() - .center_x() - .into(), - FloatingElementExample::Loaded(State { lines }) => { - let scrollable_content = lines.iter().enumerate().fold( - Column::new() - .width(Length::Fill) - .height(Length::Shrink) - .padding(10), - |scroll, (i, line)| scroll.push(Text::new(format!("{}. {}", i + 1, line))), - ); - let scrollable_content = Scrollable::new(scrollable_content).height(Length::Fill); - - let content = floating_element( - Container::new(scrollable_content) - .width(Length::Fill) - .height(Length::Fill) - .max_width(400) - .max_height(600) - .style(theme::Container::Box), - Button::new( - Text::new(icon_to_string(Bootstrap::Plus)) - .font(BOOTSTRAP_FONT) - .size(35) - .line_height(1.0) - .shaping(text::Shaping::Advanced), - ) - .on_press(Message::ButtonPressed) - .padding(5) - .style(theme::Button::Custom(Box::new( - CircleButtonStyle::new(theme::Button::Primary), - ))), - ) - .anchor(Anchor::SouthEast) - .offset(20.0) - .hide(false); - - Container::new(content) - .width(Length::Fill) - .height(Length::Fill) - .padding(10) - .center_x() - .center_y() - .into() - } - } - } -} - -struct CircleButtonStyle { - theme: theme::Button, -} - -impl CircleButtonStyle { - pub fn new(theme: theme::Button) -> Self { - Self { theme } - } -} - -impl button::StyleSheet for CircleButtonStyle { - type Style = Theme; - - fn active(&self, style: &Self::Style) -> Appearance { - let mut appearance = style.active(&self.theme); - appearance.border.radius = 25.0.into(); - - appearance - } - - fn hovered(&self, style: &Self::Style) -> Appearance { - let mut appearance = style.hovered(&self.theme); - appearance.border.radius = 25.0.into(); - - appearance - } - - fn pressed(&self, style: &Self::Style) -> Appearance { - let mut appearance = style.pressed(&self.theme); - appearance.border.radius = 25.0.into(); - - appearance - } - - fn disabled(&self, style: &Self::Style) -> Appearance { - let mut appearance = style.disabled(&self.theme); - appearance.border.radius = 25.0.into(); - - appearance - } -} diff --git a/examples/floating_element_anchors/Cargo.toml b/examples/floating_element_anchors/Cargo.toml deleted file mode 100644 index d294eae9..00000000 --- a/examples/floating_element_anchors/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "floating_element_anchors" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = [ - "floating_element", - "icons", -] } -iced.workspace = true diff --git a/examples/floating_element_anchors/src/main.rs b/examples/floating_element_anchors/src/main.rs deleted file mode 100644 index 1582acd9..00000000 --- a/examples/floating_element_anchors/src/main.rs +++ /dev/null @@ -1,73 +0,0 @@ -use iced::widget::{button, container, text}; -use iced::{Element, Length, Sandbox, Settings}; -use iced_aw::{floating_element::Anchor, FloatingElement}; - -fn main() -> iced::Result { - FloatingElementAnchorsExample::run(Settings::default()) -} - -struct FloatingElementAnchorsExample { - current_anchor: usize, -} - -#[derive(Clone, Debug)] -enum Message { - NextAnchor, -} - -const AVAILABLE_ANCHORS: [Anchor; 8] = [ - Anchor::North, - Anchor::NorthEast, - Anchor::East, - Anchor::SouthEast, - Anchor::South, - Anchor::SouthWest, - Anchor::West, - Anchor::NorthWest, -]; - -impl Sandbox for FloatingElementAnchorsExample { - type Message = Message; - - fn new() -> Self { - Self { current_anchor: 0 } - } - - fn title(&self) -> String { - String::from("Floating element anchors") - } - - fn update(&mut self, message: Self::Message) { - match message { - Message::NextAnchor => { - self.current_anchor = (self.current_anchor + 1) % 8; - } - } - } - - fn view(&self) -> Element<'_, Self::Message> { - let current_anchor = AVAILABLE_ANCHORS[self.current_anchor]; - let current_anchor_name = match current_anchor { - Anchor::NorthWest => "North West", - Anchor::NorthEast => "North East", - Anchor::SouthWest => "South West", - Anchor::SouthEast => "South East", - Anchor::North => "North", - Anchor::East => "East", - Anchor::South => "South", - Anchor::West => "West", - }; - - let content = container(button(text(current_anchor_name)).on_press(Message::NextAnchor)) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y() - .padding(8); - - FloatingElement::new(content, text("Content")) - .anchor(current_anchor) - .hide(false) - .into() - } -} diff --git a/examples/modal/Cargo.toml b/examples/modal/Cargo.toml deleted file mode 100644 index 7273eb10..00000000 --- a/examples/modal/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "modal" -version = "0.1.0" -authors = ["Kaiden42 "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = [ - "card", - "modal", - "icons", -] } -iced.workspace = true diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs deleted file mode 100644 index 06ed2570..00000000 --- a/examples/modal/src/main.rs +++ /dev/null @@ -1,181 +0,0 @@ -use iced::{ - alignment::{self, Horizontal}, - font, - widget::{container, pick_list, text, Button, Container, Row, Text}, - Alignment, Application, Command, Element, Length, Settings, Theme, -}; - -use iced_aw::{modal, Card}; - -fn main() -> iced::Result { - ModalExample::run(Settings::default()) -} - -#[derive(Clone, Debug)] -enum Message { - OpenModal, - CloseModal, - CancelButtonPressed, - OkButtonPressed, - ChangeTheme(Theme), - #[allow(dead_code)] - Loaded(Result<(), String>), - FontLoaded(Result<(), font::Error>), -} - -#[derive(Debug)] -enum ModalExample { - Loading, - Loaded(State), -} - -#[derive(Default, Debug)] -struct State { - show_modal: bool, - last_message: Option, - theme: Theme, -} - -async fn load() -> Result<(), String> { - Ok(()) -} - -impl Application for ModalExample { - type Message = Message; - type Theme = Theme; - type Executor = iced::executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (ModalExample, Command) { - ( - ModalExample::Loading, - Command::batch(vec![ - font::load(iced_aw::BOOTSTRAP_FONT_BYTES).map(Message::FontLoaded), - Command::perform(load(), Message::Loaded), - ]), - ) - } - - fn title(&self) -> String { - String::from("Modal example") - } - - fn update(&mut self, message: Self::Message) -> Command { - match self { - ModalExample::Loading => { - if let Message::Loaded(_) = message { - *self = ModalExample::Loaded(State::default()) - } - } - ModalExample::Loaded(state) => { - match message { - Message::OpenModal => state.show_modal = true, - Message::CloseModal => state.show_modal = false, - Message::CancelButtonPressed => state.show_modal = false, - Message::OkButtonPressed => state.show_modal = false, - Message::ChangeTheme(ref t) => state.theme = t.clone(), - _ => {} - } - - state.last_message = Some(message) - } - } - - Command::none() - } - - fn view(&self) -> Element<'_, Self::Message> { - match self { - ModalExample::Loading => container( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .width(Length::Fill) - .height(Length::Fill) - .center_y() - .center_x() - .into(), - ModalExample::Loaded(state) => { - let underlay = Container::new( - Row::new() - .spacing(10) - .align_items(Alignment::Center) - .push(Button::new(Text::new("Open modal!")).on_press(Message::OpenModal)) - .push(pick_list( - Theme::ALL, - Some(&state.theme), - Message::ChangeTheme, - )) - .push(Text::new(format!( - "Last message: {}", - match state.last_message.as_ref() { - Some(message) => match message { - Message::OpenModal => "Modal opened", - Message::CloseModal => "Modal closed", - Message::CancelButtonPressed => "Modal canceled", - Message::OkButtonPressed => "Modal accepted", - Message::ChangeTheme(_) => "Changed Theme", - _ => "None", - }, - None => "None", - } - ))), - ); - - let overlay = if state.show_modal { - Some( - Card::new( - Text::new("My modal"), - Text::new("This is a modal!"), //Text::new("Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.") - ) - .foot( - Row::new() - .spacing(10) - .padding(5) - .width(Length::Fill) - .push(pick_list( - Theme::ALL, - Some(&state.theme), - Message::ChangeTheme, - )) - .push( - Button::new( - Text::new("Cancel") - .horizontal_alignment(Horizontal::Center), - ) - .width(Length::Fill) - .on_press(Message::CancelButtonPressed), - ) - .push( - Button::new( - Text::new("Ok").horizontal_alignment(Horizontal::Center), - ) - .width(Length::Fill) - .on_press(Message::OkButtonPressed), - ), - ) - .max_width(500.0) - //.width(Length::Shrink) - .on_close(Message::CloseModal), - ) - } else { - None - }; - - modal(underlay, overlay) - .backdrop(Message::CloseModal) - .on_esc(Message::CloseModal) - .align_y(alignment::Vertical::Center) - .into() - } - } - } - - fn theme(&self) -> Theme { - match self { - ModalExample::Loading => Theme::Light, - ModalExample::Loaded(state) => state.theme.clone(), - } - } -} diff --git a/examples/modal_component/Cargo.toml b/examples/modal_component/Cargo.toml deleted file mode 100644 index 73f10f0b..00000000 --- a/examples/modal_component/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "modal_component" -version = "0.1.0" -authors = ["Kaiden42 "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = [ - "card", - "modal", - "icons", -] } -iced = { workspace = true, features = [ - "lazy", -] } diff --git a/examples/modal_component/src/main.rs b/examples/modal_component/src/main.rs deleted file mode 100644 index 34b21336..00000000 --- a/examples/modal_component/src/main.rs +++ /dev/null @@ -1,153 +0,0 @@ -use iced::{ - alignment, font, - widget::{container, text, Button, Container, Row, Text}, - Alignment, Application, Command, Element, Length, Settings, Theme, -}; - -use iced_aw::Modal; - -fn main() -> iced::Result { - ModalExample::run(Settings::default()) -} - -#[derive(Clone, Debug)] -enum Message { - OpenModal, - CloseModal, - #[allow(dead_code)] - Loaded(Result<(), String>), - FontLoaded(Result<(), font::Error>), -} - -#[derive(Debug)] -enum ModalExample { - Loading, - Loaded(State), -} - -#[derive(Default, Debug)] -struct State { - show_modal: bool, - last_message: Option, -} - -async fn load() -> Result<(), String> { - Ok(()) -} - -impl Application for ModalExample { - type Message = Message; - type Theme = Theme; - type Executor = iced::executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (ModalExample, Command) { - ( - ModalExample::Loading, - Command::batch(vec![ - font::load(iced_aw::BOOTSTRAP_FONT_BYTES).map(Message::FontLoaded), - Command::perform(load(), Message::Loaded), - ]), - ) - } - - fn title(&self) -> String { - String::from("Modal example") - } - - fn update(&mut self, message: Self::Message) -> Command { - match self { - ModalExample::Loading => { - if let Message::Loaded(_) = message { - *self = ModalExample::Loaded(State::default()) - } - } - ModalExample::Loaded(state) => { - match message { - Message::OpenModal => state.show_modal = true, - Message::CloseModal => state.show_modal = false, - _ => {} - } - state.last_message = Some(message) - } - } - - Command::none() - } - - fn view(&self) -> Element<'_, Self::Message> { - match self { - ModalExample::Loading => container( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .width(Length::Fill) - .height(Length::Fill) - .center_y() - .center_x() - .into(), - ModalExample::Loaded(state) => { - let underlay = Container::new( - Row::new() - .spacing(10) - .align_items(Alignment::Center) - .push(Button::new(Text::new("Open modal!")).on_press(Message::OpenModal)) - .push(Text::new(format!( - "Last message: {}", - match state.last_message.as_ref() { - Some(message) => match message { - Message::OpenModal => "Modal opened", - Message::CloseModal => "Modal closed", - _ => "None", - }, - None => "None", - } - ))), - ); - - let overlay = if state.show_modal { - Some(container(my_component::MyComponent)) - } else { - None - }; - - Modal::new(underlay, overlay) - .backdrop(Message::CloseModal) - .on_esc(Message::CloseModal) - .into() - } - } - } -} - -mod my_component { - use iced::{ - widget::{component, container, row, text, Component}, - Element, - }; - - pub struct MyComponent; - - impl Component for MyComponent { - type State = (); - type Event = (); - - fn update(&mut self, _state: &mut Self::State, _event: ()) -> Option { - None - } - - fn view(&self, _state: &Self::State) -> Element<()> { - container(row![text("Hello there")]).into() - } - } - - impl<'a, Message> From for Element<'a, Message> - where - Message: 'a, - { - fn from(my_component: MyComponent) -> Self { - component(my_component) - } - } -} diff --git a/examples/multiple_modals/Cargo.toml b/examples/multiple_modals/Cargo.toml deleted file mode 100644 index fb06a0a9..00000000 --- a/examples/multiple_modals/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "multiple_modals" -version = "0.1.0" -authors = ["Luca Trevisani "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = ["card", "modal", "icons"] } -iced.workspace = true diff --git a/examples/multiple_modals/src/main.rs b/examples/multiple_modals/src/main.rs deleted file mode 100644 index b901a9fe..00000000 --- a/examples/multiple_modals/src/main.rs +++ /dev/null @@ -1,234 +0,0 @@ -use iced::widget::{button, column, container, row, text, vertical_space}; -use iced::{alignment, executor, font, window}; -use iced::{Alignment, Application, Command, Element, Length, Settings, Theme}; -use iced_aw::{card, modal, CardStyles}; - -fn main() -> iced::Result { - MultipleModalsExample::run(Settings { - window: window::Settings { - size: iced::Size { - width: 500.0, - height: 175.0, - }, - position: window::Position::Centered, - ..Default::default() - }, - ..Default::default() - }) -} - -enum State { - Start, - Button1, - Button2, - Button3, - End, -} - -enum ButtonPressed { - Correct, - Wrong, -} - -struct MultipleModalsExample { - state: State, - button_pressed: Option, -} - -#[derive(Debug, Clone)] -enum Message { - FontLoaded(Result<(), font::Error>), - ButtonStartPressed, - Button1Pressed, - Button2Pressed, - Button3Pressed, - ButtonRestartPressed, - ButtonQuitPressed, - CloseOverlay, -} - -impl Application for MultipleModalsExample { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: Self::Flags) -> (Self, Command) { - ( - Self { - state: State::Start, - button_pressed: None, - }, - font::load(iced_aw::BOOTSTRAP_FONT_BYTES).map(Message::FontLoaded), - ) - } - - fn title(&self) -> String { - String::from("Multiple Modals example") - } - - fn update(&mut self, message: Self::Message) -> Command { - match message { - Message::FontLoaded(_) => Command::none(), - Message::ButtonStartPressed => { - match self.state { - State::Start => self.state = State::Button1, - _ => panic!("button `Start` should be shown only with state `Start`"), - } - Command::none() - } - Message::Button1Pressed => { - match self.state { - State::Button1 => self.button_pressed = Some(ButtonPressed::Correct), - State::Button2 | State::Button3 => { - self.button_pressed = Some(ButtonPressed::Wrong) - } - _ => panic!( - "button 1 should be shown only with states `Button1`, `Button2`, or `Button3`" - ), - } - Command::none() - } - Message::Button2Pressed => { - match self.state { - State::Button2 => self.button_pressed = Some(ButtonPressed::Correct), - State::Button1 | State::Button3 => { - self.button_pressed = Some(ButtonPressed::Wrong) - } - _ => panic!( - "button 2 should be shown only with states `Button1`, `Button2`, or `Button3`" - ), - } - Command::none() - } - Message::Button3Pressed => { - match self.state { - State::Button3 => self.button_pressed = Some(ButtonPressed::Correct), - State::Button1 | State::Button2 => { - self.button_pressed = Some(ButtonPressed::Wrong) - } - _ => panic!( - "button 3 should be shown only with states `Button1`, `Button2`, or `Button3`" - ), - } - Command::none() - } - Message::ButtonRestartPressed => { - self.state = State::Button1; - Command::none() - } - Message::ButtonQuitPressed => window::close(window::Id::MAIN), - Message::CloseOverlay => { - match (&self.state, &self.button_pressed) { - (State::Button1, Some(ButtonPressed::Correct)) => self.state = State::Button2, - (State::Button2, Some(ButtonPressed::Correct)) => self.state = State::Button3, - (State::Button3, Some(ButtonPressed::Correct)) => self.state = State::End, - ( - State::Button1 | State::Button2 | State::Button3, - Some(ButtonPressed::Wrong), - ) => (), - _ => panic!( - "overlays should open only with states `Button1`, `Button2`, or `Button3`" - ), - } - self.button_pressed = None; - Command::none() - } - } - } - - fn view(&self) -> Element { - let underlay = { - let body_string = match self.state { - State::Start => "Press the Start button to begin", - State::Button1 => "Press Button 1", - State::Button2 => "Press Button 2", - State::Button3 => "Press Button 3", - State::End => "All done!", - }; - - let button = |label, message| { - button(text(label).horizontal_alignment(alignment::Horizontal::Center)) - .width(90) - .on_press(message) - }; - - let foot_row = match self.state { - State::Start => Some(row![button("Start", Message::ButtonStartPressed)]), - State::Button1 | State::Button2 | State::Button3 => Some(row![ - button("Button 1", Message::Button1Pressed), - button("Button 2", Message::Button2Pressed), - button("Button 3", Message::Button3Pressed) - ]), - State::End => Some(row![ - button("Restart", Message::ButtonRestartPressed), - button("Quit", Message::ButtonQuitPressed), - ]), - }; - - match foot_row { - Some(foot_row) => container( - column![ - //vertical_space(Length::Fill), - vertical_space(), - text(body_string), - //vertical_space(Length::Fill), - vertical_space(), - foot_row.spacing(20) - ] - .spacing(20) - .padding(20) - .align_items(Alignment::Center), - ) - .width(Length::Fill) - .center_x(), - None => container(text(body_string)) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y(), - } - }; - - let overlay = self.button_pressed.as_ref().map(|button_pressed| { - let head_string = match button_pressed { - ButtonPressed::Correct => "Correct button", - ButtonPressed::Wrong => "Wrong button", - }; - - let body_string = match button_pressed { - ButtonPressed::Correct => match self.state { - State::Button1 => "You pressed button 1!\nClose this dialogue to continue.", - State::Button2 => "You pressed button 2!\nClose this dialogue to continue.", - State::Button3 => "You pressed button 3!\nClose this dialogue to continue.", - _ => panic!( - "overlays should open only with states `Button1`, `Button2`, or `Button3`" - ), - }, - ButtonPressed::Wrong => { - "You pressed the wrong button.\nClose this dialogue to continue." - } - }; - - let card_style = match button_pressed { - ButtonPressed::Correct => CardStyles::Success, - ButtonPressed::Wrong => CardStyles::Danger, - }; - - card( - text(head_string), - text(body_string) - .width(Length::Fill) - .horizontal_alignment(alignment::Horizontal::Center), - ) - .style(card_style) - .max_width(300.0) - .on_close(Message::CloseOverlay) - }); - - modal(underlay, overlay) - .backdrop(Message::CloseOverlay) - .on_esc(Message::CloseOverlay) - .into() - } -} diff --git a/examples/segmented_button/Cargo.toml b/examples/segmented_button/Cargo.toml deleted file mode 100644 index fcc534f0..00000000 --- a/examples/segmented_button/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "segmented_button" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - - -[dependencies] -iced_aw = { workspace = true, features = [ - "segmented_button", - "icons", -] } -iced.workspace = true \ No newline at end of file diff --git a/examples/segmented_button/src/main.rs b/examples/segmented_button/src/main.rs deleted file mode 100644 index 44a265e8..00000000 --- a/examples/segmented_button/src/main.rs +++ /dev/null @@ -1,103 +0,0 @@ -use iced::widget::container; -use iced::widget::{column, row, text}; -use iced::{Element, Length, Sandbox, Settings}; - -use iced_aw::widgets::segmented_button; -use segmented_button::SegmentedButton; - -pub fn main() -> iced::Result { - Example::run(Settings::default()) -} - -#[derive(Default)] -struct Example { - selected_radio: Option, -} - -#[derive(Debug, Clone, Copy)] -enum Message { - RadioSelected(Choice), -} - -impl Sandbox for Example { - type Message = Message; - - fn new() -> Self { - Self { - selected_radio: Some(Choice::A), - } - } - - fn title(&self) -> String { - String::from("Radio - Iced") - } - - fn update(&mut self, message: Message) { - match message { - Message::RadioSelected(value) => { - self.selected_radio = Some(value); - } - } - } - - fn view(&self) -> Element { - // let selected_radio = Some(Choice::A); - - // i added a row just to demonstrate that anything can be used as a child, - //in this case instead of A B C you might add icons - let a = SegmentedButton::new( - row!(text("HEAVY "), "A"), - Choice::A, - self.selected_radio, - Message::RadioSelected, - ); - - let b = SegmentedButton::new( - row!(text("MEDIUM "), "B"), - Choice::B, - self.selected_radio, - Message::RadioSelected, - ); - - let c = SegmentedButton::new( - row!(text("LIGHT "), "C"), - Choice::C, - self.selected_radio, - Message::RadioSelected, - ); - let content = column![ - row![a, b, c], - text(self.selected_radio.unwrap().to_string()) - ] - .align_items(iced::Alignment::Center); - - container(content) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y() - .into() - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] -pub enum Choice { - #[default] - A, - B, - C, -} - -impl std::fmt::Display for Choice { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - match self { - Choice::A => "A", - Choice::B => "B", - Choice::C => "C", - } - ) - } -} diff --git a/examples/split/Cargo.toml b/examples/split/Cargo.toml deleted file mode 100644 index 1ebf2865..00000000 --- a/examples/split/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "split" -version = "0.1.0" -authors = ["Kaiden42 "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = ["split", "icons"] } -iced.workspace = true diff --git a/examples/split/src/main.rs b/examples/split/src/main.rs deleted file mode 100644 index f4b921f4..00000000 --- a/examples/split/src/main.rs +++ /dev/null @@ -1,91 +0,0 @@ -use iced::{ - widget::{Container, Text}, - Application, Command, Element, Length, Settings, Theme, -}; -use iced_aw::{split, Split}; - -fn main() -> iced::Result { - SplitPaneExample::run(Settings::default()) -} - -#[derive(Debug, Clone)] -enum Message { - OnVerResize(u16), - OnHorResize(u16), -} - -struct SplitPaneExample { - ver_divider_position: Option, - hor_divider_position: Option, -} - -impl Application for SplitPaneExample { - type Message = Message; - type Flags = (); - type Theme = Theme; - type Executor = iced::executor::Default; - - fn new(_flags: Self::Flags) -> (SplitPaneExample, Command) { - ( - SplitPaneExample { - ver_divider_position: None, - hor_divider_position: None, - }, - Command::none(), - ) - } - - fn title(&self) -> String { - String::from("Split example") - } - - fn update(&mut self, message: Message) -> Command { - match message { - Message::OnVerResize(position) => self.ver_divider_position = Some(position), - Message::OnHorResize(position) => self.hor_divider_position = Some(position), - } - - Command::none() - } - - fn view(&self) -> Element { - let first = Container::new(Text::new("First")) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y(); - - let second = Container::new(Text::new("Second")) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y(); - - let top = Container::new(Text::new("Top")) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y(); - - let bottom_content = Split::new( - first, - second, - self.ver_divider_position, - split::Axis::Vertical, - Message::OnVerResize, - ); - - Split::new( - top, - bottom_content, - self.hor_divider_position, - split::Axis::Horizontal, - Message::OnHorResize, - ) - .into() - } - - fn theme(&self) -> Self::Theme { - Theme::Light - } -} diff --git a/examples/split_scroller/Cargo.toml b/examples/split_scroller/Cargo.toml deleted file mode 100644 index 4c3f3351..00000000 --- a/examples/split_scroller/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "split_scroller" -version = "0.1.0" -authors = ["Kaiden42 "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced_aw = { workspace = true, features = ["split", "icons"] } -iced.workspace = true -once_cell = "1.17.1" diff --git a/examples/split_scroller/src/main.rs b/examples/split_scroller/src/main.rs deleted file mode 100644 index 8b127046..00000000 --- a/examples/split_scroller/src/main.rs +++ /dev/null @@ -1,537 +0,0 @@ -use iced::executor; -use iced::{Application, Command, Element, Settings, Theme}; -use router::Router; - -#[derive(Debug, Clone)] -pub enum Message { - RouterMessage(router::Message), -} - -struct MyApp { - router: Router, -} - -pub fn main() -> iced::Result { - MyApp::run(Settings::default()) -} - -impl Application for MyApp { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: Self::Flags) -> (Self, Command) { - ( - MyApp { - router: Router::new(), - }, - Command::none(), - ) - } - - fn title(&self) -> String { - String::from("Scrollable - Iced") - } - - fn update(&mut self, message: Message) -> Command { - match message { - Message::RouterMessage(router_msg) => { - self.router.update(router_msg).map(Message::RouterMessage) - } - } - - // Command::none() - } - - fn view(&self) -> Element { - self.router.view().map(Message::RouterMessage) - } - - fn theme(&self) -> Self::Theme { - Theme::Dark - } -} - -mod router { - use iced::{ - widget::{button, column, row}, - Command, Element, - }; - - use crate::demo::{self, ScrollableDemo}; - - #[derive(Debug, Clone)] - pub enum Message { - Splitted(splitted::Message), - Demo(demo::Message), - GoToDemo, - GoToSplitted, - } - pub struct Router { - previous_state: Option, - state: ViewState, - } - impl Router { - pub fn new() -> Self { - Self { - previous_state: None, - state: ViewState::splitted(), - } - } - fn next_state(&mut self, next: ViewState) { - let old_state = std::mem::replace(&mut self.state, next); - self.previous_state = Some(old_state); - } - fn _next_state_skip(&mut self, next: ViewState) { - self.state = next; - } - fn _back(&mut self) { - if let Some(s) = self.previous_state.take() { - self.state = s; - } - } - - pub fn view(&self) -> Element { - let nav_bar = row![ - button("Go to Demo").on_press(Message::GoToDemo), - button("Go to Splitted").on_press(Message::GoToSplitted), - ] - .padding(20) - .spacing(10); - let view_cp = self.state.view(); - column![nav_bar, view_cp].into() - } - - pub fn update(&mut self, message: Message) -> Command { - match message { - Message::GoToDemo => { - self.next_state(ViewState::demo()); - } - Message::GoToSplitted => { - self.next_state(ViewState::splitted()); - } - Message::Splitted(msg) => { - if let ViewState::Splitted { state } = &mut self.state { - return state.update(msg).map(Message::Splitted); - } - } - Message::Demo(demo_msg) => { - if let ViewState::Demo { state } = &mut self.state { - return state.update(demo_msg).map(Message::Demo); - } - } - } - - Command::none() - } - } - - pub enum ViewState { - Splitted { state: splitted::State }, - Demo { state: demo::ScrollableDemo }, - } - - impl ViewState { - pub fn splitted() -> Self { - Self::Splitted { - state: splitted::State::new(), - } - } - pub fn demo() -> Self { - Self::Demo { - state: ScrollableDemo::new(), - } - } - pub fn view(&self) -> Element { - match self { - Self::Splitted { state } => state.view().map(Message::Splitted), - Self::Demo { state } => state.view().map(Message::Demo), - } - } - } - - mod splitted { - use iced::{ - widget::{container, text}, - Command, Element, - }; - - use crate::demo::{self, ScrollableDemo}; - - #[derive(Debug, Clone)] - pub enum Message { - DemoMessage(demo::Message), - OnVerResize(u16), - } - - pub struct State { - demo_state: ScrollableDemo, - divider_position: u16, - } - impl State { - pub fn new() -> Self { - Self { - demo_state: ScrollableDemo::new(), - divider_position: 200, - } - } - pub fn update(&mut self, message: Message) -> Command { - match message { - Message::OnVerResize(new_size) => { - self.divider_position = new_size; - Command::none() - } - Message::DemoMessage(msg) => { - self.demo_state.update(msg).map(Message::DemoMessage) - } - } - } - pub fn view(&self) -> Element { - let demo = self.demo_state.view().map(Message::DemoMessage); - - let first: Element<_> = container(text("First Container")).into(); - let splitted = iced_aw::split::Split::new( - first, - demo, - Some(self.divider_position), - iced_aw::split::Axis::Vertical, - Message::OnVerResize, - ) - .spacing(1.0) - .min_size_second(300); - - splitted.into() - } - } - } -} - -mod demo { - use iced::widget::scrollable::Properties; - use iced::widget::{ - button, column, container, horizontal_space, progress_bar, radio, row, scrollable, slider, - text, vertical_space, - }; - use iced::{theme, Alignment, Color}; - use iced::{Command, Element, Length, Theme}; - use once_cell::sync::Lazy; - - static SCROLLABLE_ID: Lazy = Lazy::new(scrollable::Id::unique); - - pub struct ScrollableDemo { - scrollable_direction: Direction, - scrollbar_width: u16, - scrollbar_margin: u16, - scroller_width: u16, - current_scroll_offset: scrollable::RelativeOffset, - } - - #[derive(Debug, Clone, Eq, PartialEq, Copy)] - pub enum Direction { - Vertical, - Horizontal, - Multi, - } - - #[derive(Debug, Clone)] - pub enum Message { - SwitchDirection(Direction), - ScrollbarWidthChanged(u16), - ScrollbarMarginChanged(u16), - ScrollerWidthChanged(u16), - ScrollToBeginning, - ScrollToEnd, - Scrolled(scrollable::Viewport), - } - impl ScrollableDemo { - pub fn new() -> Self { - ScrollableDemo { - scrollable_direction: Direction::Vertical, - scrollbar_width: 10, - scrollbar_margin: 0, - scroller_width: 10, - current_scroll_offset: scrollable::RelativeOffset::START, - } - } - - pub fn update(&mut self, message: Message) -> Command { - match message { - Message::SwitchDirection(direction) => { - self.current_scroll_offset = scrollable::RelativeOffset::START; - self.scrollable_direction = direction; - - scrollable::snap_to(SCROLLABLE_ID.clone(), self.current_scroll_offset) - } - Message::ScrollbarWidthChanged(width) => { - self.scrollbar_width = width; - - Command::none() - } - Message::ScrollbarMarginChanged(margin) => { - self.scrollbar_margin = margin; - - Command::none() - } - Message::ScrollerWidthChanged(width) => { - self.scroller_width = width; - - Command::none() - } - Message::ScrollToBeginning => { - self.current_scroll_offset = scrollable::RelativeOffset::START; - - scrollable::snap_to(SCROLLABLE_ID.clone(), self.current_scroll_offset) - } - Message::ScrollToEnd => { - self.current_scroll_offset = scrollable::RelativeOffset::END; - - scrollable::snap_to(SCROLLABLE_ID.clone(), self.current_scroll_offset) - } - Message::Scrolled(viewport) => { - self.current_scroll_offset = viewport.relative_offset(); - - Command::none() - } - } - } - - pub fn view(&self) -> Element { - let scrollbar_width_slider = - slider(0..=15, self.scrollbar_width, Message::ScrollbarWidthChanged); - let scrollbar_margin_slider = slider( - 0..=15, - self.scrollbar_margin, - Message::ScrollbarMarginChanged, - ); - let scroller_width_slider = - slider(0..=15, self.scroller_width, Message::ScrollerWidthChanged); - - let scroll_slider_controls = column![ - text("Scrollbar width:"), - scrollbar_width_slider, - text("Scrollbar margin:"), - scrollbar_margin_slider, - text("Scroller width:"), - scroller_width_slider, - ] - .spacing(10) - .width(Length::Fill); - - let scroll_orientation_controls = column(vec![ - text("Scrollbar direction:").into(), - radio( - "Vertical", - Direction::Vertical, - Some(self.scrollable_direction), - Message::SwitchDirection, - ) - .into(), - radio( - "Horizontal", - Direction::Horizontal, - Some(self.scrollable_direction), - Message::SwitchDirection, - ) - .into(), - radio( - "Both!", - Direction::Multi, - Some(self.scrollable_direction), - Message::SwitchDirection, - ) - .into(), - ]) - .spacing(10) - .width(Length::Fill); - - let scroll_controls = row![scroll_slider_controls, scroll_orientation_controls] - .spacing(20) - .width(Length::Fill); - - let scroll_to_end_button = || { - button("Scroll to end") - .padding(10) - .on_press(Message::ScrollToEnd) - }; - - let scroll_to_beginning_button = || { - button("Scroll to beginning") - .padding(10) - .on_press(Message::ScrollToBeginning) - }; - - let scrollable_content: Element = - Element::from(match self.scrollable_direction { - Direction::Vertical => scrollable( - column![ - scroll_to_end_button(), - text("Beginning!"), - //vertical_space(1200), - vertical_space(), - text("Middle!"), - //vertical_space(1200), - vertical_space(), - text("End!"), - scroll_to_beginning_button(), - ] - .width(Length::Fill) - .align_items(Alignment::Center) - .padding([40, 0, 40, 0]) - .spacing(40), - ) - .height(Length::Fill) - .direction(scrollable::Direction::Vertical( - Properties::new() - .width(self.scrollbar_width) - .margin(self.scrollbar_margin) - .scroller_width(self.scroller_width), - )) - .id(SCROLLABLE_ID.clone()) - .on_scroll(Message::Scrolled), - Direction::Horizontal => scrollable( - row![ - scroll_to_end_button(), - text("Beginning!"), - //horizontal_space(1200), - horizontal_space(), - text("Middle!"), - //horizontal_space(1200), - horizontal_space(), - text("End!"), - scroll_to_beginning_button(), - ] - .height(450) - .align_items(Alignment::Center) - .padding([0, 40, 0, 40]) - .spacing(40), - ) - .height(Length::Fill) - .direction(scrollable::Direction::Horizontal( - Properties::new() - .width(self.scrollbar_width) - .margin(self.scrollbar_margin) - .scroller_width(self.scroller_width), - )) - .style(theme::Scrollable::custom(ScrollbarCustomStyle)) - .id(SCROLLABLE_ID.clone()) - .on_scroll(Message::Scrolled), - Direction::Multi => scrollable( - //horizontal content - row![ - column![ - text("Let's do some scrolling!"), - //vertical_space(2400), - vertical_space(), - ], - scroll_to_end_button(), - text("Horizontal - Beginning!"), - //horizontal_space(1200), - horizontal_space(), - //vertical content - column![ - text("Horizontal - Middle!"), - scroll_to_end_button(), - text("Vertical - Beginning!"), - //vertical_space(1200), - vertical_space(), - text("Vertical - Middle!"), - //vertical_space(1200), - vertical_space(), - text("Vertical - End!"), - scroll_to_beginning_button(), - //vertical_space(40), - vertical_space(), - ] - .spacing(40), - //horizontal_space(1200), - horizontal_space(), - text("Horizontal - End!"), - scroll_to_beginning_button(), - ] - .align_items(Alignment::Center) - .padding([0, 40, 0, 40]) - .spacing(40), - ) - .height(Length::Fill) - .direction(scrollable::Direction::Both { - vertical: Properties::new() - .width(self.scrollbar_width) - .margin(self.scrollbar_margin) - .scroller_width(self.scroller_width), - horizontal: Properties::new() - .width(self.scrollbar_width) - .margin(self.scrollbar_margin) - .scroller_width(self.scroller_width), - }) - .style(theme::Scrollable::Custom(Box::new(ScrollbarCustomStyle))) - .id(SCROLLABLE_ID.clone()) - .on_scroll(Message::Scrolled), - }); - - let progress_bars: Element = match self.scrollable_direction { - Direction::Vertical => progress_bar(0.0..=1.0, self.current_scroll_offset.y).into(), - Direction::Horizontal => progress_bar(0.0..=1.0, self.current_scroll_offset.x) - .style(theme::ProgressBar::Custom(Box::new(ProgressBarCustomStyle))) - .into(), - Direction::Multi => column![ - progress_bar(0.0..=1.0, self.current_scroll_offset.y), - progress_bar(0.0..=1.0, self.current_scroll_offset.x).style( - theme::ProgressBar::Custom(Box::new(ProgressBarCustomStyle,)) - ) - ] - .spacing(10) - .into(), - }; - - let content: Element = - column![scroll_controls, scrollable_content, progress_bars] - .width(Length::Fill) - .height(Length::Fill) - .align_items(Alignment::Center) - .spacing(10) - .into(); - - Element::from( - container(content) - .width(Length::Fill) - .height(Length::Fill) - .padding(40) - .center_x() - .center_y(), - ) - } - } - - struct ScrollbarCustomStyle; - - impl scrollable::StyleSheet for ScrollbarCustomStyle { - type Style = Theme; - - fn active(&self, style: &Self::Style) -> iced::widget::scrollable::Appearance { - style.active(&theme::Scrollable::Default) - } - - fn hovered( - &self, - style: &Self::Style, - is_mouse_over: bool, - ) -> iced::widget::scrollable::Appearance { - style.hovered(&theme::Scrollable::Default, is_mouse_over) - } - } - - struct ProgressBarCustomStyle; - - impl progress_bar::StyleSheet for ProgressBarCustomStyle { - type Style = Theme; - - fn appearance(&self, style: &Self::Style) -> progress_bar::Appearance { - progress_bar::Appearance { - background: style.extended_palette().background.strong.color.into(), - bar: Color::from_rgb8(250, 85, 134).into(), - border_radius: 0.0.into(), - } - } - } -} diff --git a/images/concept_drawings/floating_action_button.svg b/images/concept_drawings/floating_action_button.svg deleted file mode 100644 index 8528a793..00000000 --- a/images/concept_drawings/floating_action_button.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - + - - diff --git a/images/concept_drawings/modal.svg b/images/concept_drawings/modal.svg deleted file mode 100644 index fbf1cdcd..00000000 --- a/images/concept_drawings/modal.svg +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - diff --git a/images/showcase/cupertino/buttons.png b/images/showcase/cupertino/buttons.png deleted file mode 100644 index 34685078..00000000 Binary files a/images/showcase/cupertino/buttons.png and /dev/null differ diff --git a/images/showcase/cupertino/cupertino-alert.gif b/images/showcase/cupertino/cupertino-alert.gif deleted file mode 100644 index 939ef013..00000000 Binary files a/images/showcase/cupertino/cupertino-alert.gif and /dev/null differ diff --git a/images/showcase/cupertino/cupertino-spinner.gif b/images/showcase/cupertino/cupertino-spinner.gif deleted file mode 100644 index fd4107a6..00000000 Binary files a/images/showcase/cupertino/cupertino-spinner.gif and /dev/null differ diff --git a/images/showcase/cupertino/cupertino-switch.gif b/images/showcase/cupertino/cupertino-switch.gif deleted file mode 100644 index 5931208b..00000000 Binary files a/images/showcase/cupertino/cupertino-switch.gif and /dev/null differ diff --git a/images/showcase/floating_button.png b/images/showcase/floating_button.png deleted file mode 100644 index c4587e88..00000000 Binary files a/images/showcase/floating_button.png and /dev/null differ diff --git a/images/showcase/modal.png b/images/showcase/modal.png deleted file mode 100644 index a2e5293a..00000000 Binary files a/images/showcase/modal.png and /dev/null differ diff --git a/images/showcase/split_example.gif b/images/showcase/split_example.gif deleted file mode 100644 index 2639047a..00000000 Binary files a/images/showcase/split_example.gif and /dev/null differ diff --git a/src/core.rs b/src/core.rs index c2ba85ed..54dcab9b 100644 --- a/src/core.rs +++ b/src/core.rs @@ -27,7 +27,7 @@ pub mod icons; cfg_if! { if #[cfg(feature = "icons")] { - pub use icons::{BOOTSTRAP_FONT, BOOTSTRAP_FONT_BYTES, NERD_FONT, NERD_FONT_BYTES, SF_UI_ROUNDED_BYTES, SF_UI_ROUNDED, Bootstrap, Nerd}; + pub use icons::{BOOTSTRAP_FONT, BOOTSTRAP_FONT_BYTES, NERD_FONT, NERD_FONT_BYTES, Bootstrap, Nerd}; } else { pub use icons::{BOOTSTRAP_FONT, BOOTSTRAP_FONT_BYTES, Bootstrap}; } diff --git a/src/core/fonts/SFUIRounded.ttf b/src/core/fonts/SFUIRounded.ttf deleted file mode 100644 index ddd11349..00000000 Binary files a/src/core/fonts/SFUIRounded.ttf and /dev/null differ diff --git a/src/core/icons.rs b/src/core/icons.rs index 0b588d93..70134c98 100644 --- a/src/core/icons.rs +++ b/src/core/icons.rs @@ -19,12 +19,6 @@ cfg_if! { pub const BOOTSTRAP_FONT: Font = Font::with_name("bootstrap-icons"); /// The nerd icon font. pub const NERD_FONT: Font = Font::with_name("Symbols Nerd Font"); - - /// The default cupertino font bytes for loading the font into the system. - pub const SF_UI_ROUNDED_BYTES: &[u8] = include_bytes!("./fonts/SFUIRounded.ttf"); - - /// The default cupertino font for alerts and button. - pub const SF_UI_ROUNDED: iced::Font = iced::Font::with_name(".SF UI Rounded"); } else { #[path = "icons/required.rs"] pub mod bootstrap; diff --git a/src/lib.rs b/src/lib.rs index d759578b..050a78e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ mod platform { if #[cfg(feature = "icons")] { pub use crate::core::icons::{ - Bootstrap, BOOTSTRAP_FONT, BOOTSTRAP_FONT_BYTES, Nerd, NERD_FONT, NERD_FONT_BYTES,SF_UI_ROUNDED_BYTES, SF_UI_ROUNDED, + Bootstrap, BOOTSTRAP_FONT, BOOTSTRAP_FONT_BYTES, Nerd, NERD_FONT, NERD_FONT_BYTES, }; } else { pub use crate::core::icons::{Bootstrap, BOOTSTRAP_FONT, BOOTSTRAP_FONT_BYTES}; @@ -86,18 +86,10 @@ mod platform { #[cfg(feature = "date_picker")] pub use {crate::widgets::date_picker, date_picker::DatePicker}; - #[doc(no_inline)] - #[cfg(feature = "floating_element")] - pub use {crate::widgets::floating_element, floating_element::FloatingElement}; - #[doc(no_inline)] #[cfg(feature = "grid")] pub use crate::widgets::grid::{Grid, GridRow}; - #[doc(no_inline)] - #[cfg(feature = "modal")] - pub use {crate::style::ModalStyles, crate::widgets::modal, modal::Modal}; - #[doc(no_inline)] #[cfg(feature = "tab_bar")] pub use { @@ -134,10 +126,6 @@ mod platform { selection_list::SelectionList, }; - #[doc(no_inline)] - #[cfg(feature = "split")] - pub use {crate::style::SplitStyles, crate::widgets::split, split::Split}; - #[doc(no_inline)] #[cfg(feature = "menu")] pub use crate::widgets::menu; diff --git a/src/style/modal.rs b/src/style/modal.rs deleted file mode 100644 index 94355be9..00000000 --- a/src/style/modal.rs +++ /dev/null @@ -1,66 +0,0 @@ -//! Use a badge for color highlighting important information. -//! -//! *This API requires the following crate features to be activated: badge* -use std::rc::Rc; - -use iced::{Background, Color, Theme}; - -/// The appearance of a [`Modal`](crate::native::Modal). -#[derive(Clone, Copy, Debug)] -pub struct Appearance { - /// The background of the [`Modal`](crate::native::Modal). - /// - /// This is used to color the backdrop of the modal. - pub background: Background, -} - -impl Default for Appearance { - fn default() -> Self { - Self { - background: Background::Color([0.87, 0.87, 0.87, 0.30].into()), - } - } -} -/// The appearance of a [`Modal`](crate::native::Modal). -pub trait StyleSheet { - ///Style for the trait to use. - type Style: Default + Clone; - /// The normal appearance of a [`Modal`](crate::native::Modal). - fn active(&self, style: &Self::Style) -> Appearance; -} - -/// The default appearance of a [`Modal`](crate::native::Modal). -#[derive(Clone, Default)] -#[allow(missing_docs, clippy::missing_docs_in_private_items)] -pub enum ModalStyles { - #[default] - Default, - Custom(Rc>), -} - -impl ModalStyles { - /// Creates a custom [`ModalStyles`] style variant. - pub fn custom(style_sheet: impl StyleSheet