Skip to content

Commit

Permalink
attempt to update to latest master changes
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed May 17, 2024
1 parent 8cc9128 commit c57aa81
Show file tree
Hide file tree
Showing 9 changed files with 496 additions and 1,112 deletions.
1,133 changes: 189 additions & 944 deletions Cargo.lock

Large diffs are not rendered by default.

107 changes: 53 additions & 54 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ drop_down = []

default = [
"badge",
"card",
"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",
#"card",
#"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",
]

[dependencies]
Expand All @@ -75,9 +75,9 @@ time = { version = "0.3.34", features = ["local-offset"], optional = true }
once_cell = { version = "1.19.0", optional = true }

[dependencies.iced]
#git = "https://github.com/iced-rs/iced.git"
git = "https://github.com/iced-rs/iced.git"
#rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
version = "0.12.1"
version = "0.13.0-dev"
default-features = false
features = ["advanced"]

Expand All @@ -87,41 +87,40 @@ opt-level = 2
[workspace]
members = [
"examples/badge",
"examples/card",
"examples/number_input",
"examples/date_picker",
"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",
#"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",
]

[workspace.dependencies.iced]
#git = "https://github.com/iced-rs/iced.git"
git = "https://github.com/iced-rs/iced.git"
#rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
version = "0.12.1"
version = "0.13.0-dev"
default-features = false
features = ["advanced"]

Expand Down
61 changes: 29 additions & 32 deletions examples/badge/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use iced::{
widget::{Column, Container, Row, Text},
Alignment, Element, Length, Sandbox, Settings,
Alignment, Element, Length,
};

use iced_aw::{helpers::badge, style::BadgeStyles};
use iced_aw::{helpers::badge, style, style::status::Status};

const BADGE_TEXT_SIZE: u16 = 15;

fn main() -> iced::Result {
BadgeExample::run(Settings::default())
iced::program("Badge example", BadgeExample::update, BadgeExample::view)
.centered()
.run()
}

#[derive(Debug, Clone)]
Expand All @@ -18,23 +20,19 @@ struct BadgeExample {
messages: Vec<(String, usize)>,
}

impl Sandbox for BadgeExample {
type Message = Message;

fn new() -> Self {
BadgeExample {
impl Default for BadgeExample {
fn default() -> Self {
Self {
messages: vec![
("Charlotte-Jayne Gilpin".to_string(), 20),
("Keanu Reeves".to_string(), 42),
("Stephen Hawking".to_string(), 21),
],
}
}
}

fn title(&self) -> String {
String::from("Badge example")
}

impl BadgeExample {
fn update(&mut self, _message: Message) {}

fn view(&self) -> Element<Message> {
Expand Down Expand Up @@ -66,19 +64,19 @@ impl Sandbox for BadgeExample {
Row::new()
.spacing(10)
.push(badge(Text::new("Default")))
.push(badge(Text::new("Primary")).style(BadgeStyles::Primary))
.push(badge(Text::new("Secondary")).style(BadgeStyles::Secondary))
.push(badge(Text::new("Success")).style(BadgeStyles::Success))
.push(badge(Text::new("Danger")).style(BadgeStyles::Danger)),
.push(badge(Text::new("Primary")).style(style::badge::primary))
.push(badge(Text::new("Secondary")).style(style::badge::secondary))
.push(badge(Text::new("Success")).style(style::badge::success))
.push(badge(Text::new("Danger")).style(style::badge::danger)),
)
.push(
Row::new()
.spacing(10)
.push(badge(Text::new("Warning")).style(BadgeStyles::Warning))
.push(badge(Text::new("Info")).style(BadgeStyles::Info))
.push(badge(Text::new("Light")).style(BadgeStyles::Light))
.push(badge(Text::new("Dark")).style(BadgeStyles::Dark))
.push(badge(Text::new("White")).style(BadgeStyles::White)),
.push(badge(Text::new("Warning")).style(style::badge::warning))
.push(badge(Text::new("Info")).style(style::badge::info))
.push(badge(Text::new("Light")).style(style::badge::light))
.push(badge(Text::new("Dark")).style(style::badge::dark))
.push(badge(Text::new("White")).style(style::badge::white)),
);

Container::new(
Expand All @@ -90,21 +88,20 @@ impl Sandbox for BadgeExample {
)
.width(Length::Fill)
.height(Length::Fill)
.center_y()
.into()
}
}

fn predefined_style(index: usize) -> BadgeStyles {
fn predefined_style(index: usize) -> impl Fn(&iced::Theme, Status) -> style::badge::Style {
match index {
0 => BadgeStyles::Primary,
1 => BadgeStyles::Secondary,
2 => BadgeStyles::Success,
3 => BadgeStyles::Danger,
4 => BadgeStyles::Warning,
5 => BadgeStyles::Info,
6 => BadgeStyles::Light,
7 => BadgeStyles::Dark,
_ => BadgeStyles::Default,
0 => style::badge::primary,
1 => style::badge::secondary,
2 => style::badge::success,
3 => style::badge::danger,
4 => style::badge::warning,
5 => style::badge::info,
6 => style::badge::light,
7 => style::badge::dark,
_ => style::badge::primary,
}
}
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ pub use iced::Element;

/// Exports for all platforms that are not WASM32.
mod platform {
#[allow(unused_imports)]
pub use crate::style;
pub use crate::widgets::helpers;

cfg_if::cfg_if! {
Expand All @@ -70,7 +72,7 @@ mod platform {

#[doc(no_inline)]
#[cfg(feature = "badge")]
pub use {crate::style::BadgeStyles, crate::widgets::badge, badge::Badge};
pub use {crate::widgets::badge, badge::Badge};

#[doc(no_inline)]
#[cfg(feature = "card")]
Expand Down
3 changes: 1 addition & 2 deletions src/style.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//! The appearance of the widgets

pub mod colors;
pub mod status;
pub mod style_state;

#[cfg(feature = "badge")]
pub mod badge;
#[cfg(feature = "badge")]
pub use badge::BadgeStyles;

#[cfg(feature = "card")]
pub mod card;
Expand Down
Loading

0 comments on commit c57aa81

Please sign in to comment.