Skip to content

Commit

Permalink
migrating to iced 0.13 (styling, program, task)
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Sep 20, 2024
1 parent f9fa4c1 commit 37d1cdf
Show file tree
Hide file tree
Showing 37 changed files with 1,173 additions and 957 deletions.
845 changes: 458 additions & 387 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 @@ -39,8 +39,8 @@ pcap = "2.2.0"
etherparse = "0.16.0"
chrono = { version = "0.4.38", default-features = false, features = ["clock"] }
plotters = { version = "0.3.7", default-features = false, features = ["area_series"] }
iced = { version = "0.12.1", features = ["tokio", "svg", "advanced", "lazy"] }
plotters-iced = "0.10.0"
iced = { version = "0.13.0", features = ["tokio", "svg", "advanced", "lazy"] }
plotters-iced = "0.11.0"
maxminddb = "0.24.0"
confy = "0.6.1"
serde = { version = "1.0.210", default-features = false, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion src/chart/types/traffic_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use plotters::prelude::*;
use plotters_iced::{Chart, ChartBuilder, ChartWidget, DrawingBackend};
use splines::Spline;

use crate::gui::app::FONT_FAMILY_NAME;
use crate::gui::sniffer::FONT_FAMILY_NAME;
use crate::gui::styles::style_constants::CHARTS_LINE_BORDER;
use crate::gui::styles::types::palette::to_rgb_color;
use crate::gui::types::message::Message;
Expand Down
2 changes: 1 addition & 1 deletion src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn get_flag_from_country(
is_loopback: bool,
traffic_type: TrafficType,
language: Language,
) -> (Svg<StyleType>, String) {
) -> (Svg<'static, StyleType>, String) {
#![allow(clippy::too_many_lines)]
let mut tooltip = country.to_string();
let mut svg_style = SvgType::Standard;
Expand Down
133 changes: 0 additions & 133 deletions src/gui/app.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/gui/components/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn button_hide(
Position::Right,
)
.gap(5)
.style(ContainerType::Tooltip)
.class(ContainerType::Tooltip)
}

pub fn button_open_file(
Expand Down Expand Up @@ -69,13 +69,13 @@ pub fn button_open_file(

Tooltip::new(button, Text::new(tooltip_str).font(font), Position::Right)
.gap(5)
.style(tooltip_style)
.class(tooltip_style)
}

pub fn row_open_link_tooltip(text: &'static str, font: Font) -> Row<'static, Message, StyleType> {
Row::new()
.align_items(Alignment::Center)
.spacing(10)
.push(Text::new(text).font(font))
.push(Icon::OpenLink.to_text().size(16).style(TextType::Title))
.push(Icon::OpenLink.to_text().size(16).class(TextType::Title))
}
16 changes: 8 additions & 8 deletions src/gui/components/footer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn footer(
Container::new(footer_row)
.height(45)
.align_y(Vertical::Center)
.style(ContainerType::Gradient(color_gradient))
.class(ContainerType::Gradient(color_gradient))
}

fn get_button_website(font: Font) -> Tooltip<'static, Message, StyleType> {
Expand All @@ -78,7 +78,7 @@ fn get_button_website(font: Font) -> Tooltip<'static, Message, StyleType> {
row_open_link_tooltip("Website", font),
Position::Top,
)
.style(ContainerType::Tooltip)
.class(ContainerType::Tooltip)
}

fn get_button_github(font: Font) -> Tooltip<'static, Message, StyleType> {
Expand All @@ -99,15 +99,15 @@ fn get_button_github(font: Font) -> Tooltip<'static, Message, StyleType> {
row_open_link_tooltip("GitHub", font),
Position::Top,
)
.style(ContainerType::Tooltip)
.class(ContainerType::Tooltip)
}

fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, StyleType> {
let content = button(
Text::new('❤'.to_string())
.font(font)
.size(23)
.style(TextType::Sponsor)
.class(TextType::Sponsor)
.horizontal_alignment(Horizontal::Center)
.vertical_alignment(Vertical::Center)
.line_height(LineHeight::Relative(1.0)),
Expand All @@ -122,7 +122,7 @@ fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, StyleType> {
row_open_link_tooltip("Sponsor", font),
Position::Top,
)
.style(ContainerType::Tooltip)
.class(ContainerType::Tooltip)
}

fn get_release_details(
Expand All @@ -145,7 +145,7 @@ fn get_release_details(
// a newer release is available on GitHub
let button = button(
Text::new('!'.to_string())
.style(TextType::Danger)
.class(TextType::Danger)
.size(28)
.horizontal_alignment(Horizontal::Center)
.vertical_alignment(Vertical::Center)
Expand All @@ -154,14 +154,14 @@ fn get_release_details(
.padding(0)
.height(35)
.width(35)
.style(ButtonType::Alert)
.class(ButtonType::Alert)
.on_press(Message::OpenWebPage(WebPage::WebsiteDownload));
let tooltip = Tooltip::new(
button,
row_open_link_tooltip(new_version_available_translation(language), font),
Position::Top,
)
.style(ContainerType::Tooltip);
.class(ContainerType::Tooltip);
ret_val = ret_val.push(Space::with_width(10)).push(tooltip);
} else {
// this is the latest release
Expand Down
16 changes: 8 additions & 8 deletions src/gui/components/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use crate::configs::types::config_settings::ConfigSettings;
use crate::gui::components::tab::notifications_badge;
use crate::gui::pages::types::running_page::RunningPage;
use crate::gui::pages::types::settings_page::SettingsPage;
use crate::gui::sniffer::Sniffer;
use crate::gui::styles::button::ButtonType;
use crate::gui::styles::container::ContainerType;
use crate::gui::styles::types::gradient_type::GradientType;
use crate::gui::types::message::Message;
use crate::gui::types::sniffer::Sniffer;
use crate::translations::translations::{quit_analysis_translation, settings_translation};
use crate::translations::translations_3::thumbnail_mode_translation;
use crate::utils::types::icon::Icon;
Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn header(sniffer: &Sniffer) -> Container<'static, Message, StyleType> {
)
.height(80)
.align_y(Vertical::Center)
.style(ContainerType::Gradient(color_gradient))
.class(ContainerType::Gradient(color_gradient))
}

fn get_button_reset(font: Font, language: Language) -> Tooltip<'static, Message, StyleType> {
Expand All @@ -99,7 +99,7 @@ fn get_button_reset(font: Font, language: Language) -> Tooltip<'static, Message,
Position::Right,
)
.gap(5)
.style(ContainerType::Tooltip)
.class(ContainerType::Tooltip)
}

pub fn get_button_settings(
Expand All @@ -125,7 +125,7 @@ pub fn get_button_settings(
Position::Left,
)
.gap(5)
.style(ContainerType::Tooltip)
.class(ContainerType::Tooltip)
}

pub fn get_button_minimize(
Expand Down Expand Up @@ -160,12 +160,12 @@ pub fn get_button_minimize(
.padding(0)
.height(button_size)
.width(button_size)
.style(ButtonType::Thumbnail)
.class(ButtonType::Thumbnail)
.on_press(Message::ToggleThumbnail(false));

Tooltip::new(content, Text::new(tooltip).font(font), Position::Right)
.gap(0)
.style(tooltip_style)
.class(tooltip_style)
}

fn thumbnail_header(
Expand All @@ -187,7 +187,7 @@ fn thumbnail_header(
.push(if unread_notifications > 0 {
Container::new(
notifications_badge(font, unread_notifications)
.style(ContainerType::HighlightedOnHeader),
.class(ContainerType::HighlightedOnHeader),
)
.width(40)
.align_x(Horizontal::Center)
Expand All @@ -197,5 +197,5 @@ fn thumbnail_header(
)
.height(30)
.align_y(Vertical::Center)
.style(ContainerType::Gradient(color_gradient))
.class(ContainerType::Gradient(color_gradient))
}
8 changes: 4 additions & 4 deletions src/gui/components/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn get_exit_overlay(
Container::new(content)
.height(160)
.width(450)
.style(ContainerType::Modal)
.class(ContainerType::Modal)
}

pub fn get_clear_all_overlay(
Expand Down Expand Up @@ -80,7 +80,7 @@ pub fn get_clear_all_overlay(
Container::new(content)
.height(160)
.width(450)
.style(ContainerType::Modal)
.class(ContainerType::Modal)
}

fn get_modal_header(
Expand Down Expand Up @@ -110,7 +110,7 @@ fn get_modal_header(
.align_y(Vertical::Center)
.height(40)
.width(Length::Fill)
.style(ContainerType::Gradient(color_gradient))
.class(ContainerType::Gradient(color_gradient))
}

fn confirm_button_row(
Expand All @@ -131,7 +131,7 @@ fn confirm_button_row(
.padding(5)
.height(40)
.width(80)
.style(ButtonType::Alert)
.class(ButtonType::Alert)
.on_press(message),
)
}
Expand Down
Loading

0 comments on commit 37d1cdf

Please sign in to comment.