Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: update iced to master #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
752 changes: 711 additions & 41 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ icon = ["assets/dynasty.icns"]
[dependencies]
binance-rs-async = { version = "1.3.2", default_features = false, features = ["rustls-tls", "wallet_api"] }
chrono = "0.4.31"
iced = { version = "0.12.0", features = ["tokio", "debug", "lazy", "svg", "image", "advanced", "canvas"] }
iced_futures = "0.12.0"
iced = { git = "https://github.com/iced-rs/iced", features = ["tokio", "debug", "lazy", "svg", "image", "advanced", "canvas"] }
x86y marked this conversation as resolved.
Show resolved Hide resolved
iced_futures = { git = "https://github.com/iced-rs/iced" }
x86y marked this conversation as resolved.
Show resolved Hide resolved
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
tokio = { version = "1.32.0", default-features = false, features=["sync"]}
Expand Down
16 changes: 9 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use iced::widget::svg;
use iced::widget::Row;
use iced::widget::Space;
use iced::widget::{column, container, row, text};
use iced::{Application, Color, Command, Element, Length, Subscription, Theme};
use iced::Renderer;
use iced::{Color, Command, Element, Length, Subscription, Theme};
use ringbuf::Rb;

pub(crate) struct App {
Expand Down Expand Up @@ -92,7 +93,8 @@ impl App {
}
}

impl Application for App {
impl iced::advanced::Application for App {
type Renderer = Renderer;
type Message = Message;
type Theme = Theme;
type Flags = Config;
Expand Down Expand Up @@ -268,13 +270,13 @@ impl Application for App {
Space::new(Length::Fill, 1),
button(text("Settings").size(14))
.padding(8)
.style(iced::theme::Button::Text)
.style(iced::widget::button::text)
.on_press(Message::SettingsToggled)
]
.align_items(iced::Alignment::Center),
)
.padding([0, 16])
.style(container::Appearance {
.style(|_t| container::Style {
background: Some(iced::Background::Color(Color::from_rgb(0.07, 0.07, 0.07))),
border: iced::Border {
radius: 16.0.into(),
Expand All @@ -289,13 +291,13 @@ impl Application for App {
Space::new(Length::Fill, 1),
button(text("X").size(14))
.padding(8)
.style(iced::theme::Button::Text)
.style(iced::widget::button::text)
.on_press(Message::SettingsToggled)
]
.align_items(iced::Alignment::Center),
)
.padding([0, 16])
.style(container::Appearance {
.style(|_t| container::Style {
x86y marked this conversation as resolved.
Show resolved Hide resolved
background: Some(iced::Background::Color(Color::from_rgb(0.99, 0.03, 0.03))),
border: iced::Border {
radius: 16.0.into(),
Expand Down Expand Up @@ -327,7 +329,7 @@ impl Application for App {
.width(Length::Fill)
.height(Length::Fill)
.padding(20)
.style(|_: &_| container::Appearance {
.style(|_: &_| container::Style {
background: Some(iced::Background::Color(Color::BLACK)),
..Default::default()
})
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{app::App, config::Config};

use std::env;

use iced::{Application, Font, Settings};
use iced::{advanced::Application, Font, Settings};
use tracing_subscriber::EnvFilter;

fn main() -> iced::Result {
Expand Down
191 changes: 89 additions & 102 deletions src/views/components/better_btn.rs
Original file line number Diff line number Diff line change
@@ -1,118 +1,105 @@
use iced::{widget::button, Color};

pub struct BetterBtn;

impl button::StyleSheet for BetterBtn {
type Style = iced::Theme;
fn active(&self, _: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
shadow_offset: iced::Vector { x: 1.0, y: 1.0 },
border: iced::Border {
radius: 4.0.into(),
width: 1.0,
color: Color::from_rgba(0.0, 0.0, 0.0, 0.5),
},
..Default::default()
}
pub fn unstyled_btn() -> button::Style {
button::Style {
background: None,
text_color: Color::WHITE,
..Default::default()
}
}

fn pressed(&self, _: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
shadow_offset: iced::Vector { x: 1.0, y: 1.0 },
border: iced::Border {
radius: 0.0.into(),
width: 1.0,
color: Color::from_rgb(1.0, 0.0, 0.0),
},
..Default::default()
}
pub fn better_btn() -> button::Style {
button::Style {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
border: iced::Border {
radius: 4.0.into(),
width: 1.0,
color: Color::from_rgba(0.0, 0.0, 0.0, 0.5),
},
..Default::default()
}
}

pub struct GreenBtn;

impl button::StyleSheet for GreenBtn {
type Style = iced::Theme;
fn active(&self, _: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(iced::Background::Color(Color::from_rgba(
50.0 / 255.0,
217.0 / 255.0,
147.0 / 255.0,
1.0,
))),
text_color: Color::WHITE,
shadow_offset: iced::Vector { x: 1.0, y: 1.0 },
border: iced::Border {
radius: 4.0.into(),
width: 1.0,
color: Color::from_rgba(0.0, 0.0, 0.0, 0.5),
},
..Default::default()
}
/* fn pressed(&self, _: &Self::Style) -> button::Style {
button::Style {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
border: iced::Border {
radius: 0.0.into(),
width: 1.0,
color: Color::from_rgb(1.0, 0.0, 0.0),
},
..Default::default()
}
} */

fn pressed(&self, _: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
shadow_offset: iced::Vector { x: 1.0, y: 1.0 },
border: iced::Border {
radius: 0.0.into(),
width: 1.0,
color: Color::from_rgb(1.0, 0.0, 0.0),
},
..Default::default()
}
pub fn green_btn() -> button::Style {
button::Style {
background: Some(iced::Background::Color(Color::from_rgba(
50.0 / 255.0,
217.0 / 255.0,
147.0 / 255.0,
1.0,
))),
text_color: Color::WHITE,
border: iced::Border {
radius: 4.0.into(),
width: 1.0,
color: Color::from_rgba(0.0, 0.0, 0.0, 0.5),
},
..Default::default()
}
}

pub struct RedBtn;
pub fn red_btn() -> button::Style {
button::Style {
background: Some(iced::Background::Color(Color::from_rgba(
1.0,
112.0 / 255.0,
126.0 / 255.0,
1.0,
))),
text_color: Color::WHITE,
border: iced::Border {
radius: 4.0.into(),
width: 1.0,
color: Color::from_rgba(0.0, 0.0, 0.0, 0.5),
},
..Default::default()
}
}

impl button::StyleSheet for RedBtn {
type Style = iced::Theme;
fn active(&self, _: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(iced::Background::Color(Color::from_rgba(
1.0,
112.0 / 255.0,
126.0 / 255.0,
1.0,
))),
text_color: Color::WHITE,
shadow_offset: iced::Vector { x: 1.0, y: 1.0 },
border: iced::Border {
radius: 4.0.into(),
width: 1.0,
color: Color::from_rgba(0.0, 0.0, 0.0, 0.5),
},
..Default::default()
}
/* fn pressed(&self, _: &Self::Style) -> button::Style {
button::Style {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
border: iced::Border {
radius: 0.0.into(),
width: 1.0,
color: Color::from_rgb(1.0, 0.0, 0.0),
},
..Default::default()
}
} */

fn pressed(&self, _: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
shadow_offset: iced::Vector { x: 1.0, y: 1.0 },
border: iced::Border {
radius: 0.0.into(),
width: 1.0,
color: Color::from_rgb(1.0, 0.0, 0.0),
},
..Default::default()
}
/* fn pressed(&self, _: &Self::Style) -> button::Style {
button::Style {
background: Some(iced::Background::Color(Color::from_rgba(
0.3, 0.3, 0.3, 0.3,
))),
text_color: Color::WHITE,
border: iced::Border {
radius: 0.0.into(),
width: 1.0,
color: Color::from_rgb(1.0, 0.0, 0.0),
},
..Default::default()
}
}
} */
74 changes: 0 additions & 74 deletions src/views/components/input.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/views/components/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ where
renderer.with_translation(Vector::new(bounds.x, bounds.y), |renderer| {
use iced::advanced::graphics::geometry::Renderer as _;

renderer.draw(vec![geometry]);
renderer.draw_geometry(geometry);
});
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/views/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
pub mod better_btn;
pub mod input;
// pub mod list;
pub mod loading;
pub mod scrollbar;
pub mod unstyled_btn;
Loading