Skip to content

Commit

Permalink
Update iced to v0.9 and rename project to iced_aw v0.5 (#110)
Browse files Browse the repository at this point in the history
* Update iced to v0.9 and rename project to iced_aw v0.5

* cargo fmt
  • Loading branch information
Cupnfish committed Apr 13, 2023
1 parent 49c6f99 commit 175b928
Show file tree
Hide file tree
Showing 32 changed files with 386 additions and 270 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iced_aw"
version = "0.4.1"
version = "0.5.0"
authors = ["Kaiden42 <gitlab@tinysn.com>"]
edition = "2021"
description = "Additional widgets for the Iced GUI library"
Expand Down Expand Up @@ -65,17 +65,17 @@ lazy_static = { version = "1.4.0", optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.iced_native]
#git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.9.1"
version = "0.10.1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.iced_graphics]
#git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.7.0"
version = "0.8.0"

[dependencies.iced_style]
#git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.7.0"
version = "0.8.0"

[profile.dev.package."*"]
opt-level = 2
Expand Down Expand Up @@ -106,7 +106,7 @@ members = [
[workspace.dependencies.iced]
#git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.8.0"
version = "0.9.0"

[workspace.dependencies.iced_aw]
path = "./"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Every widget is hidden by a feature gate. This allows you to cherry pick the wid
Include `iced_aw` as a dependency in your `Cargo.toml`:
```toml
[dependencies]
iced = "0.8.0"
iced_aw = { version = "0.4.1", default-features = false, features = [...] }
iced = "0.9.0"
iced_aw = { version = "0.5", default-features = false, features = [...] }
```

## Versioning
Expand All @@ -24,7 +24,7 @@ iced_aw = { version = "0.4.1", default-features = false, features = [...] }
| 0.4 | 0.2 |
| 0.7 | 0.3 |
| 0.8 | 0.4 |

| 0.9 | 0.5 |
## Widgets


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

use iced_aw::{Badge, style::BadgeStyles};
use iced_aw::{style::BadgeStyles, Badge};

const BADGE_TEXT_SIZE: u16 = 15;

Expand Down Expand Up @@ -40,20 +43,21 @@ impl Sandbox for BadgeExample {
.spacing(15)
.max_width(300);

let content_messages = self.messages.iter().enumerate().fold(
content,
|col, (i, (name, count))| {
col.push(
Row::new()
.align_items(Alignment::Center)
.push(Text::new(name).width(Length::Fill))
.push(
Badge::new(Text::new(format!("{count}")).size(BADGE_TEXT_SIZE))
.style(predefined_style(i)),
),
)
},
);
let content_messages =
self.messages
.iter()
.enumerate()
.fold(content, |col, (i, (name, count))| {
col.push(
Row::new()
.align_items(Alignment::Center)
.push(Text::new(name).width(Length::Fill))
.push(
Badge::new(Text::new(format!("{count}")).size(BADGE_TEXT_SIZE))
.style(predefined_style(i)),
),
)
});

let content_all = Column::new()
.spacing(10)
Expand Down Expand Up @@ -82,11 +86,12 @@ impl Sandbox for BadgeExample {
.spacing(40)
.push(content_messages)
.push(content_all),
).width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y()
.into()
)
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y()
.into()
}
}

Expand Down
8 changes: 5 additions & 3 deletions examples/card/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use iced::{Element, Length, Sandbox, Settings,
widget::{Button, Column, Container, Scrollable, Text}};
use iced_aw::{Card, style::CardStyles};
use iced::{
widget::{Button, Column, Container, Scrollable, Text},
Element, Length, Sandbox, Settings,
};
use iced_aw::{style::CardStyles, Card};

fn main() -> iced::Result {
CardExample::run(Settings::default())
Expand Down
6 changes: 4 additions & 2 deletions examples/color_picker/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use iced::{Alignment, Color, Element, Length, Sandbox, Settings,
widget::{Button, Container, Row, Text}};
use iced::{
widget::{Button, Container, Row, Text},
Alignment, Color, Element, Length, Sandbox, Settings,
};

use iced_aw::ColorPicker;

Expand Down
4 changes: 2 additions & 2 deletions examples/cupertino/cupertino_spinner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
publish = false

[dependencies]
iced = { version = "0.8.0", features = ["canvas", "debug", "tokio"] }
iced = { workspace = true, features = ["canvas", "debug", "tokio"] }
iced_aw = { path = "../../../", features = ["cupertino"] }
tokio = { version = "1.26.0", features = ["time"] }
tokio = { version = "1.27.0", features = ["time"] }

80 changes: 42 additions & 38 deletions examples/cupertino/cupertino_spinner/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use iced::{Application, Command, Element, executor, Length, Settings, Theme};
use iced::alignment;
use iced::widget::{column, container, text};
use iced::{executor, Application, Command, Element, Length, Settings, Theme};
use iced_aw::native::cupertino::cupertino_spinner::CupertinoSpinner;

pub fn main() -> iced::Result {
Spinner::run(Settings { antialiasing: true, ..Settings::default() })
Spinner::run(Settings {
antialiasing: true,
..Settings::default()
})
}

#[derive(Debug, Clone)]
Expand All @@ -26,66 +29,67 @@ impl State {
async fn load() -> Result<State, ()> {
println!("Doing stuff...");
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
return Ok(Self { hello: "Loaded!".to_string() });
return Ok(Self {
hello: "Loaded!".to_string(),
});
}
}

impl Application for Spinner {
type Executor = executor::Default;
type Message = Message;
type Theme = Theme;
type Flags = ();
type Message = Message;
type Theme = Theme;
type Flags = ();

fn new(_flags: ()) -> (Self, Command<Message>) {
(Spinner::Loading, Command::perform(State::load(), Message::Loaded))
(
Spinner::Loading,
Command::perform(State::load(), Message::Loaded),
)
}

fn title(&self) -> String { String::from("CupertinoSpinner - Iced") }
fn title(&self) -> String {
String::from("CupertinoSpinner - Iced")
}

fn update(&mut self, message: Message) -> Command<Message> {
match self {
Spinner::Loading => {
match message {
Message::Loaded(Ok(state)) => {
*self = Spinner::Loaded(State {
hello: state.hello,
});
},

_ => ()
Spinner::Loading => match message {
Message::Loaded(Ok(state)) => {
*self = Spinner::Loaded(State { hello: state.hello });
}
},

_ => ()
_ => (),
},

_ => (),
}

Command::none()
}

fn view(&self) -> Element<Message> {
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)
])
Spinner::Loading => container(
CupertinoSpinner::new()
.width(Length::Fill)
.height(Length::Fill)
.center_y()
.into()
},
.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 }
fn theme(&self) -> Self::Theme {
Theme::Light
}
}

7 changes: 5 additions & 2 deletions examples/date_picker/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use iced::{Alignment, Element, Length, Sandbox, Settings, widget::{Button, Container, Row, Text}};
use iced_aw::{DatePicker, date_picker::Date};
use iced::{
widget::{Button, Container, Row, Text},
Alignment, Element, Length, Sandbox, Settings,
};
use iced_aw::{date_picker::Date, DatePicker};

fn main() -> iced::Result {
DatePickerExample::run(Settings::default())
Expand Down
14 changes: 9 additions & 5 deletions examples/floating_element/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use iced::widget::button;
use iced::widget::button::Appearance;
use iced::{theme, Element, Length, Sandbox, Settings, Theme,
widget::{Button, Column, Container, Scrollable, Text}};
use iced::{
theme,
widget::{Button, Column, Container, Scrollable, Text},
Element, Length, Sandbox, Settings, Theme,
};

use iced_aw::floating_element::{self, FloatingElement};
use iced_aw::{Icon, ICON_FONT};
Expand Down Expand Up @@ -69,9 +72,10 @@ impl Sandbox for FloatingElementExample {
))))
.into()
},
).anchor(floating_element::Anchor::SouthEast)
.offset(20.0)
.hide(false);
)
.anchor(floating_element::Anchor::SouthEast)
.offset(20.0)
.hide(false);

Container::new(content)
.width(Length::Fill)
Expand Down
2 changes: 1 addition & 1 deletion examples/floating_element_anchors/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use iced::widget::{button, container, text};
use iced::{Element, Length, Sandbox, Settings};
use iced_aw::{FloatingElement, floating_element::Anchor};
use iced_aw::{floating_element::Anchor, FloatingElement};

fn main() -> iced::Result {
FloatingElementAnchorsExample::run(Settings::default())
Expand Down
7 changes: 5 additions & 2 deletions examples/grid/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use iced::{theme, Alignment, Color, Element, Length, Sandbox, Settings,
widget::{Button, Column, Container, Scrollable, Text}};
use iced::{
theme,
widget::{Button, Column, Container, Scrollable, Text},
Alignment, Color, Element, Length, Sandbox, Settings,
};

use iced_aw::Grid;

Expand Down

0 comments on commit 175b928

Please sign in to comment.