Package examples and remove `dev-dependencies`

This commit is contained in:
Héctor Ramón Jiménez 2020-01-20 06:27:01 +01:00
parent 04086a90c9
commit 7cea737115
30 changed files with 193 additions and 78 deletions

View File

@ -29,6 +29,18 @@ members = [
"web",
"wgpu",
"winit",
"examples/bezier_tool",
"examples/counter",
"examples/custom_widget",
"examples/events",
"examples/geometry",
"examples/pokedex",
"examples/progress_bar",
"examples/stopwatch",
"examples/styling",
"examples/svg",
"examples/todos",
"examples/tour",
]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
@ -37,20 +49,3 @@ iced_wgpu = { version = "0.1.0", path = "wgpu" }
[target.'cfg(target_arch = "wasm32")'.dependencies]
iced_web = { version = "0.1.0", path = "web" }
[dev-dependencies]
iced_native = { version = "0.1", path = "./native" }
iced_wgpu = { version = "0.1", path = "./wgpu" }
iced_futures = { version = "0.1.0-alpha", path = "./futures", features = ["async-std"] }
env_logger = "0.7"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
directories = "2.0"
futures = "0.3"
async-std = { version = "1.3", features = ["unstable"] }
surf = "1.0"
rand = "0.7"
lyon = "0.15"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen = "0.2.51"

View File

@ -0,0 +1,12 @@
[package]
name = "bezier_tool"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }
iced_wgpu = { path = "../../wgpu" }
lyon = "0.15"

View File

@ -0,0 +1,9 @@
[package]
name = "counter"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }

View File

@ -0,0 +1,11 @@
[package]
name = "custom_widget"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }
iced_wgpu = { path = "../../wgpu" }

View File

@ -0,0 +1,10 @@
[package]
name = "events"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }

View File

@ -0,0 +1,11 @@
[package]
name = "geometry"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }
iced_wgpu = { path = "../../wgpu" }

View File

@ -0,0 +1,14 @@
[package]
name = "pokedex"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
iced_futures = { path = "../../futures", features = ["async-std"] }
surf = "1.0"
rand = "0.7"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

View File

@ -1,6 +1,6 @@
use iced::{
button, image, Align, Application, Button, Column, Command, Container,
Element, Image, Length, Row, Settings, Text,
button, futures, image, Align, Application, Button, Column, Command,
Container, Element, Image, Length, Row, Settings, Text,
};
pub fn main() {

View File

@ -0,0 +1,9 @@
[package]
name = "progress_bar"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }

View File

@ -0,0 +1,12 @@
[package]
name = "stopwatch"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }
iced_futures = { path = "../../futures", features = ["async-std"] }
async-std = { version = "1.0", features = ["unstable"] }

View File

@ -143,6 +143,8 @@ impl Application for Stopwatch {
}
mod time {
use iced::futures;
pub fn every(
duration: std::time::Duration,
) -> iced::Subscription<std::time::Instant> {

View File

@ -0,0 +1,9 @@
[package]
name = "styling"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }

View File

@ -1,54 +0,0 @@
use iced::{Container, Element, Length, Sandbox, Settings};
pub fn main() {
Tiger::run(Settings::default())
}
#[derive(Default)]
struct Tiger;
impl Sandbox for Tiger {
type Message = ();
fn new() -> Self {
Self::default()
}
fn title(&self) -> String {
String::from("SVG - Iced")
}
fn update(&mut self, _message: ()) {}
fn view(&mut self) -> Element<()> {
#[cfg(feature = "svg")]
let content = {
use iced::{Column, Svg};
Column::new().padding(20).push(
Svg::new(format!(
"{}/examples/resources/tiger.svg",
env!("CARGO_MANIFEST_DIR")
))
.width(Length::Fill)
.height(Length::Fill),
)
};
#[cfg(not(feature = "svg"))]
let content = {
use iced::{HorizontalAlignment, Text};
Text::new("You need to enable the `svg` feature!")
.horizontal_alignment(HorizontalAlignment::Center)
.size(30)
};
Container::new(content)
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y()
.into()
}
}

9
examples/svg/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "svg"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../..", features = ["svg"] }

View File

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

37
examples/svg/src/main.rs Normal file
View File

@ -0,0 +1,37 @@
use iced::{Column, Container, Element, Length, Sandbox, Settings, Svg};
pub fn main() {
Tiger::run(Settings::default())
}
#[derive(Default)]
struct Tiger;
impl Sandbox for Tiger {
type Message = ();
fn new() -> Self {
Self::default()
}
fn title(&self) -> String {
String::from("SVG - Iced")
}
fn update(&mut self, _message: ()) {}
fn view(&mut self) -> Element<()> {
let content = Column::new().padding(20).push(
Svg::new(format!("{}/tiger.svg", env!("CARGO_MANIFEST_DIR")))
.width(Length::Fill)
.height(Length::Fill),
);
Container::new(content)
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y()
.into()
}
}

16
examples/todos/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "todos"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
iced = { path = "../.." }
iced_futures = { path = "../../futures", features = ["async-std"] }
async-std = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
directories = "2.0"

View File

@ -451,7 +451,7 @@ fn empty_message(message: &str) -> Element<'static, Message> {
// Fonts
const ICONS: Font = Font::External {
name: "Icons",
bytes: include_bytes!("resources/icons.ttf"),
bytes: include_bytes!("../fonts/icons.ttf"),
};
fn icon(unicode: char) -> Text {

13
examples/tour/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "tour"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../.." }
env_logger = "0.7"
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.51"

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -681,10 +681,10 @@ fn ferris<'a>(width: u16) -> Container<'a, StepMessage> {
// This should go away once we unify resource loading on native
// platforms
if cfg!(target_arch = "wasm32") {
Image::new("resources/ferris.png")
Image::new("images/ferris.png")
} else {
Image::new(format!(
"{}/examples/resources/ferris.png",
"{}/images/ferris.png",
env!("CARGO_MANIFEST_DIR")
))
}

View File

@ -204,6 +204,6 @@ use iced_winit as common;
use iced_web as common;
pub use common::{
Align, Background, Color, Command, Font, HorizontalAlignment, Length,
Space, Subscription, Vector, VerticalAlignment,
futures, Align, Background, Color, Command, Font, HorizontalAlignment,
Length, Space, Subscription, Vector, VerticalAlignment,
};