mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2026-10-25 00:21:12 +00:00
first class theming: settings_style_page
This commit is contained in:
parent
8c8c200fb3
commit
207c452cb5
24 changed files with 493 additions and 488 deletions
|
|
@ -326,7 +326,7 @@ pub fn get_flag_tooltip(
|
|||
traffic_type: TrafficType,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Tooltip<'static, Message> {
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let (content, tooltip) =
|
||||
get_flag_from_country(country, width, is_local, traffic_type, language);
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ pub fn get_computer_tooltip(
|
|||
traffic_type: TrafficType,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Tooltip<'static, Message> {
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = Svg::new(Handle::from_memory(Vec::from(
|
||||
match (is_my_address, traffic_type) {
|
||||
(true, _) => COMPUTER,
|
||||
|
|
|
|||
165
src/gui/app.rs
165
src/gui/app.rs
|
|
@ -4,11 +4,14 @@
|
|||
|
||||
use std::time::Duration;
|
||||
|
||||
use iced::keyboard::{Event, KeyCode, Modifiers};
|
||||
use iced::widget::{Column, Container, Row};
|
||||
use iced::Event::{Keyboard, Window};
|
||||
use iced::{executor, font, subscription, window, Application, Command, Element, Subscription, Renderer, Theme, Settings};
|
||||
use iced::application::StyleSheet;
|
||||
use iced::keyboard::{Event, KeyCode, Modifiers};
|
||||
use iced::widget::{container, Column, Container, Row};
|
||||
use iced::Event::{Keyboard, Window};
|
||||
use iced::{
|
||||
executor, font, subscription, window, Application, Command, Element, Renderer, Settings,
|
||||
Subscription, Theme,
|
||||
};
|
||||
|
||||
use crate::gui::components::footer::footer;
|
||||
use crate::gui::components::header::header;
|
||||
|
|
@ -61,80 +64,88 @@ impl Application for Sniffer {
|
|||
self.update(message)
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
let status = *self.status_pair.0.lock().unwrap();
|
||||
let style = self.style;
|
||||
let font = get_font(style);
|
||||
|
||||
let header = match status {
|
||||
Status::Init => header(
|
||||
style,
|
||||
self.color_gradient,
|
||||
false,
|
||||
self.language,
|
||||
self.last_opened_setting,
|
||||
),
|
||||
Status::Running => header(
|
||||
style,
|
||||
self.color_gradient,
|
||||
true,
|
||||
self.language,
|
||||
self.last_opened_setting,
|
||||
),
|
||||
};
|
||||
|
||||
let body = match status {
|
||||
Status::Init => initial_page(self),
|
||||
Status::Running => match self.running_page {
|
||||
RunningPage::Overview => overview_page(self),
|
||||
RunningPage::Inspect => inspect_page(self),
|
||||
RunningPage::Notifications => notifications_page(self),
|
||||
},
|
||||
};
|
||||
|
||||
let footer = footer(
|
||||
self.language,
|
||||
fn view(&self) -> Element<Message, Renderer<StyleType>> {
|
||||
container(header(
|
||||
self.style,
|
||||
self.color_gradient,
|
||||
style,
|
||||
&self.newer_release_available.clone(),
|
||||
);
|
||||
|
||||
let content = Column::new().push(header).push(body).push(footer);
|
||||
|
||||
match self.modal {
|
||||
None => {
|
||||
if let Some(settings_page) = self.settings_page {
|
||||
let overlay = match settings_page {
|
||||
SettingsPage::Notifications => settings_notifications_page(self),
|
||||
SettingsPage::Appearance => settings_style_page(self),
|
||||
SettingsPage::Language => settings_language_page(self),
|
||||
};
|
||||
|
||||
Modal::new(content, overlay)
|
||||
.on_blur(Message::CloseSettings)
|
||||
.into()
|
||||
} else {
|
||||
content.into()
|
||||
}
|
||||
}
|
||||
Some(modal) => {
|
||||
let overlay = match modal {
|
||||
MyModal::Quit => {
|
||||
get_exit_overlay(style, self.color_gradient, font, self.language)
|
||||
}
|
||||
MyModal::ClearAll => {
|
||||
get_clear_all_overlay(style, self.color_gradient, font, self.language)
|
||||
}
|
||||
MyModal::ConnectionDetails(connection_index) => {
|
||||
connection_details_page(self, connection_index)
|
||||
}
|
||||
};
|
||||
|
||||
Modal::new(content, overlay)
|
||||
.on_blur(Message::HideModal)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
false,
|
||||
self.language,
|
||||
self.last_opened_setting,
|
||||
))
|
||||
.into()
|
||||
// let status = *self.status_pair.0.lock().unwrap();
|
||||
// let style = self.style;
|
||||
// let font = get_font(style);
|
||||
//
|
||||
// let header = match status {
|
||||
// Status::Init => header(
|
||||
// style,
|
||||
// self.color_gradient,
|
||||
// false,
|
||||
// self.language,
|
||||
// self.last_opened_setting,
|
||||
// ),
|
||||
// Status::Running => header(
|
||||
// style,
|
||||
// self.color_gradient,
|
||||
// true,
|
||||
// self.language,
|
||||
// self.last_opened_setting,
|
||||
// ),
|
||||
// };
|
||||
//
|
||||
// let body = match status {
|
||||
// Status::Init => initial_page(self),
|
||||
// Status::Running => match self.running_page {
|
||||
// RunningPage::Overview => overview_page(self),
|
||||
// RunningPage::Inspect => inspect_page(self),
|
||||
// RunningPage::Notifications => notifications_page(self),
|
||||
// },
|
||||
// };
|
||||
//
|
||||
// let footer = footer(
|
||||
// self.language,
|
||||
// self.color_gradient,
|
||||
// style,
|
||||
// &self.newer_release_available.clone(),
|
||||
// );
|
||||
//
|
||||
// let content = Column::new().push(header).push(body).push(footer);
|
||||
//
|
||||
// match self.modal {
|
||||
// None => {
|
||||
// if let Some(settings_page) = self.settings_page {
|
||||
// let overlay = match settings_page {
|
||||
// SettingsPage::Notifications => settings_notifications_page(self),
|
||||
// SettingsPage::Appearance => settings_style_page(self),
|
||||
// SettingsPage::Language => settings_language_page(self),
|
||||
// };
|
||||
//
|
||||
// Modal::new(content, overlay)
|
||||
// .on_blur(Message::CloseSettings)
|
||||
// .into()
|
||||
// } else {
|
||||
// content.into()
|
||||
// }
|
||||
// }
|
||||
// Some(modal) => {
|
||||
// let overlay = match modal {
|
||||
// MyModal::Quit => {
|
||||
// get_exit_overlay(style, self.color_gradient, font, self.language)
|
||||
// }
|
||||
// MyModal::ClearAll => {
|
||||
// get_clear_all_overlay(style, self.color_gradient, font, self.language)
|
||||
// }
|
||||
// MyModal::ConnectionDetails(connection_index) => {
|
||||
// connection_details_page(self, connection_index)
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// Modal::new(content, overlay)
|
||||
// .on_blur(Message::HideModal)
|
||||
// .into()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use iced::alignment::{Horizontal, Vertical};
|
|||
use iced::widget::horizontal_space;
|
||||
use iced::widget::tooltip::Position;
|
||||
use iced::widget::{button, Container, Row, Text, Tooltip};
|
||||
use iced::{Alignment, Color, Font, Length};
|
||||
use iced::{Alignment, Color, Font, Length, Renderer};
|
||||
|
||||
use crate::gui::styles::button::{ButtonStyleTuple, ButtonType};
|
||||
use crate::gui::styles::container::{ContainerStyleTuple, ContainerType};
|
||||
|
|
@ -26,7 +26,7 @@ pub fn footer(
|
|||
color_gradient: GradientType,
|
||||
style: StyleType,
|
||||
newer_release_available: &Arc<Mutex<Result<bool, String>>>,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font_footer = get_font_headers(style);
|
||||
|
||||
let release_details_row =
|
||||
|
|
@ -57,7 +57,7 @@ pub fn footer(
|
|||
.style(ContainerType::Gradient(color_gradient))
|
||||
}
|
||||
|
||||
fn get_button_website(style: StyleType) -> Tooltip<'static, Message> {
|
||||
fn get_button_website(style: StyleType) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new('c'.to_string())
|
||||
.font(ICONS)
|
||||
|
|
@ -67,7 +67,7 @@ fn get_button_website(style: StyleType) -> Tooltip<'static, Message> {
|
|||
)
|
||||
.height(Length::Fixed(30.0))
|
||||
.width(Length::Fixed(30.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::OpenWebPage(WebPage::Website));
|
||||
|
||||
Tooltip::new(content, "Website", Position::Top)
|
||||
|
|
@ -75,7 +75,7 @@ fn get_button_website(style: StyleType) -> Tooltip<'static, Message> {
|
|||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
fn get_button_github(style: StyleType) -> Tooltip<'static, Message> {
|
||||
fn get_button_github(style: StyleType) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new('H'.to_string())
|
||||
.font(ICONS)
|
||||
|
|
@ -85,7 +85,7 @@ fn get_button_github(style: StyleType) -> Tooltip<'static, Message> {
|
|||
)
|
||||
.height(Length::Fixed(40.0))
|
||||
.width(Length::Fixed(40.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::OpenWebPage(WebPage::Repo));
|
||||
|
||||
Tooltip::new(content, "GitHub", Position::Top)
|
||||
|
|
@ -93,7 +93,7 @@ fn get_button_github(style: StyleType) -> Tooltip<'static, Message> {
|
|||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
fn get_button_sponsor(style: StyleType) -> Tooltip<'static, Message> {
|
||||
fn get_button_sponsor(style: StyleType) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new('❤'.to_string())
|
||||
.size(23)
|
||||
|
|
@ -104,12 +104,12 @@ fn get_button_sponsor(style: StyleType) -> Tooltip<'static, Message> {
|
|||
.padding([2, 0, 0, 0])
|
||||
.height(Length::Fixed(30.0))
|
||||
.width(Length::Fixed(30.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::OpenWebPage(WebPage::Sponsor));
|
||||
|
||||
Tooltip::new(content, "Sponsor", Position::Top)
|
||||
.font(get_font(style))
|
||||
.style( ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
fn get_release_details(
|
||||
|
|
@ -117,7 +117,7 @@ fn get_release_details(
|
|||
style: StyleType,
|
||||
font_footer: Font,
|
||||
newer_release_available: &Arc<Mutex<Result<bool, String>>>,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.height(Length::Fill)
|
||||
|
|
@ -140,7 +140,7 @@ fn get_release_details(
|
|||
.padding(0)
|
||||
.height(Length::Fixed(35.0))
|
||||
.width(Length::Fixed(35.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Alert).into())
|
||||
.style(ButtonType::Alert)
|
||||
.on_press(Message::OpenWebPage(WebPage::WebsiteDownload));
|
||||
let tooltip = Tooltip::new(
|
||||
button,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use iced::widget::text::LineHeight;
|
|||
use iced::widget::tooltip::Position;
|
||||
use iced::widget::{button, Container, Row, Text, Tooltip};
|
||||
use iced::Length::FillPortion;
|
||||
use iced::{Alignment, Length};
|
||||
use iced::{Alignment, Length, Renderer};
|
||||
|
||||
use crate::gui::pages::types::settings_page::SettingsPage;
|
||||
use crate::gui::styles::button::{ButtonStyleTuple, ButtonType};
|
||||
|
|
@ -22,7 +22,7 @@ pub fn header(
|
|||
back_button: bool,
|
||||
language: Language,
|
||||
last_opened_setting: SettingsPage,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let logo = Text::new('A'.to_string())
|
||||
.font(ICONS)
|
||||
.horizontal_alignment(Horizontal::Center)
|
||||
|
|
@ -68,7 +68,10 @@ pub fn header(
|
|||
.style(ContainerType::Gradient(color_gradient))
|
||||
}
|
||||
|
||||
fn get_button_reset(style: StyleType, language: Language) -> Tooltip<'static, Message> {
|
||||
fn get_button_reset(
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new('C'.to_string())
|
||||
.font(ICONS)
|
||||
|
|
@ -79,7 +82,7 @@ fn get_button_reset(style: StyleType, language: Language) -> Tooltip<'static, Me
|
|||
.padding(10)
|
||||
.height(Length::Fixed(40.0))
|
||||
.width(Length::Fixed(60.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::ResetButtonPressed);
|
||||
|
||||
Tooltip::new(
|
||||
|
|
@ -88,14 +91,14 @@ fn get_button_reset(style: StyleType, language: Language) -> Tooltip<'static, Me
|
|||
Position::Right,
|
||||
)
|
||||
.font(get_font(style))
|
||||
.style( ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
pub fn get_button_settings(
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
open_overlay: SettingsPage,
|
||||
) -> Tooltip<'static, Message> {
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new("a")
|
||||
.font(ICONS)
|
||||
|
|
@ -106,10 +109,10 @@ pub fn get_button_settings(
|
|||
.padding(0)
|
||||
.height(Length::Fixed(40.0))
|
||||
.width(Length::Fixed(60.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::OpenSettings(open_overlay));
|
||||
|
||||
Tooltip::new(content, settings_translation(language), Position::Left)
|
||||
.font(get_font(style))
|
||||
.style( ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use iced::widget::{
|
|||
button, horizontal_space, vertical_space, Column, Container, Row, Text, Tooltip,
|
||||
};
|
||||
use iced::{
|
||||
event, mouse, BorderRadius, Color, Element, Event, Font, Length, Point, Rectangle, Size,
|
||||
event, mouse, BorderRadius, Color, Element, Event, Font, Length, Point, Rectangle, Renderer,
|
||||
Size,
|
||||
};
|
||||
|
||||
use crate::gui::styles::button::{ButtonStyleTuple, ButtonType};
|
||||
|
|
@ -28,7 +29,7 @@ pub fn get_exit_overlay(
|
|||
color_gradient: GradientType,
|
||||
font: Font,
|
||||
language: Language,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let row_buttons = confirm_button_row(language, font, style, Message::Reset);
|
||||
|
||||
let content = Column::new()
|
||||
|
|
@ -60,7 +61,7 @@ pub fn get_clear_all_overlay(
|
|||
color_gradient: GradientType,
|
||||
font: Font,
|
||||
language: Language,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let row_buttons = confirm_button_row(language, font, style, Message::ClearAllNotifications);
|
||||
|
||||
let content = Column::new()
|
||||
|
|
@ -92,7 +93,7 @@ fn get_modal_header(
|
|||
color_gradient: GradientType,
|
||||
language: Language,
|
||||
title: String,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let tooltip = hide_translation(language).to_string();
|
||||
//tooltip.push_str(" [esc]");
|
||||
|
|
@ -119,14 +120,13 @@ fn get_modal_header(
|
|||
.padding(2)
|
||||
.height(Length::Fixed(20.0))
|
||||
.width(Length::Fixed(20.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::HideModal),
|
||||
tooltip,
|
||||
Position::Right,
|
||||
)
|
||||
.font(font)
|
||||
.style(
|
||||
ContainerType::Tooltip, ),
|
||||
.style(ContainerType::Tooltip),
|
||||
)
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Horizontal::Center),
|
||||
|
|
@ -144,7 +144,7 @@ fn confirm_button_row(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
message: Message,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
Row::new()
|
||||
.height(Length::Fill)
|
||||
.align_items(Alignment::Center)
|
||||
|
|
@ -158,7 +158,7 @@ fn confirm_button_row(
|
|||
.padding(5)
|
||||
.height(Length::Fixed(40.0))
|
||||
.width(Length::Fixed(80.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Alert).into())
|
||||
.style(ButtonType::Alert)
|
||||
.on_press(message),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use iced::widget::horizontal_space;
|
||||
use iced::widget::{Column, Radio, Row, Text};
|
||||
use iced::{Alignment, Font, Length};
|
||||
use iced::{Alignment, Font, Length, Renderer};
|
||||
|
||||
use crate::gui::styles::radio::{RadioStyleTuple, RadioType};
|
||||
use crate::gui::styles::style_constants::FONT_SIZE_SUBTITLE;
|
||||
|
|
@ -20,7 +20,7 @@ pub fn ip_version_radios(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Column::new().spacing(10).padding(0).push(
|
||||
ip_version_translation(language)
|
||||
.font(font)
|
||||
|
|
@ -51,7 +51,7 @@ pub fn transport_protocol_radios(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Column::new().spacing(10).push(
|
||||
Text::new(transport_protocol_translation(language))
|
||||
.font(font)
|
||||
|
|
@ -82,7 +82,7 @@ pub fn language_radios(
|
|||
collection: &[Language],
|
||||
font: Font,
|
||||
style: StyleType,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Row::new().spacing(10).align_items(Alignment::Center);
|
||||
for option in collection {
|
||||
ret_val =
|
||||
|
|
@ -118,7 +118,7 @@ pub fn sound_packets_threshold_radios(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Row::new()
|
||||
.spacing(20)
|
||||
.push(Text::new(format!("{}:", sound_translation(language))).font(font));
|
||||
|
|
@ -154,7 +154,7 @@ pub fn sound_bytes_threshold_radios(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Row::new()
|
||||
.spacing(20)
|
||||
.push(Text::new(format!("{}:", sound_translation(language))).font(font));
|
||||
|
|
@ -190,7 +190,7 @@ pub fn sound_favorite_radios(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Row::new()
|
||||
.spacing(20)
|
||||
.push(Text::new(format!("{}:", sound_translation(language))).font(font));
|
||||
|
|
@ -226,7 +226,7 @@ pub fn chart_radios(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Column::new()
|
||||
.padding([0, 0, 0, 25])
|
||||
.spacing(5)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Tab buttons to be used in the various pages just under the header
|
||||
|
||||
use iced::widget::{button, horizontal_space, Button, Row, Text};
|
||||
use iced::{alignment, Alignment, Font, Length};
|
||||
use iced::{alignment, Alignment, Font, Length, Renderer};
|
||||
|
||||
use crate::gui::pages::types::settings_page::SettingsPage;
|
||||
use crate::gui::styles::button::{ButtonStyleTuple, ButtonType};
|
||||
|
|
@ -17,7 +17,7 @@ pub fn get_settings_tabs(
|
|||
active: SettingsPage,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let mut tabs = Row::new()
|
||||
.width(Length::Fill)
|
||||
|
|
@ -48,7 +48,7 @@ pub fn get_pages_tabs(
|
|||
style: StyleType,
|
||||
language: Language,
|
||||
unread_notifications: usize,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let mut tabs = Row::new()
|
||||
.width(Length::Fill)
|
||||
|
|
@ -84,7 +84,7 @@ fn new_tab(
|
|||
style: StyleType,
|
||||
font: Font,
|
||||
unread: Option<usize>,
|
||||
) -> Button<'static, Message> {
|
||||
) -> Button<'static, Message, Renderer<StyleType>> {
|
||||
let mut content = Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.push(horizontal_space(Length::FillPortion(1)))
|
||||
|
|
@ -130,7 +130,7 @@ fn new_tab(
|
|||
)
|
||||
.padding([2, 4, 0, 4])
|
||||
.height(Length::Fixed(20.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Badge).into());
|
||||
.style(ButtonType::Badge);
|
||||
content = content
|
||||
.push(horizontal_space(Length::Fixed(7.0)))
|
||||
.push(notifications_badge);
|
||||
|
|
@ -143,16 +143,10 @@ fn new_tab(
|
|||
.height(Length::Fixed(if active { 35.0 } else { 30.0 }))
|
||||
.padding(0)
|
||||
.width(Length::FillPortion(1))
|
||||
.style(
|
||||
ButtonStyleTuple(
|
||||
style,
|
||||
if active {
|
||||
ButtonType::TabActive
|
||||
} else {
|
||||
ButtonType::TabInactive
|
||||
},
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.style(if active {
|
||||
ButtonType::TabActive
|
||||
} else {
|
||||
ButtonType::TabInactive
|
||||
})
|
||||
.on_press(action)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use iced::widget::tooltip::Position;
|
|||
use iced::widget::{button, horizontal_space, lazy, vertical_space, Rule};
|
||||
use iced::widget::{Column, Container, Row, Text, Tooltip};
|
||||
use iced::Length::Fixed;
|
||||
use iced::{Alignment, Font, Length};
|
||||
use iced::{Alignment, Font, Length, Renderer};
|
||||
|
||||
use crate::countries::country_utils::{get_computer_tooltip, get_flag_tooltip};
|
||||
use crate::countries::flags_pictures::FLAGS_WIDTH_BIG;
|
||||
|
|
@ -33,14 +33,20 @@ use crate::translations::translations_2::{
|
|||
use crate::utils::formatted_strings::{get_formatted_bytes_string_with_b, get_socket_address};
|
||||
use crate::{Language, Sniffer, StyleType};
|
||||
|
||||
pub fn connection_details_page(sniffer: &Sniffer, connection_index: usize) -> Container<Message> {
|
||||
pub fn connection_details_page(
|
||||
sniffer: &Sniffer,
|
||||
connection_index: usize,
|
||||
) -> Container<Message, Renderer<StyleType>> {
|
||||
Container::new(lazy(
|
||||
sniffer.runtime_data.tot_sent_packets + sniffer.runtime_data.tot_received_packets,
|
||||
move |_| page_content(sniffer, connection_index),
|
||||
))
|
||||
}
|
||||
|
||||
fn page_content(sniffer: &Sniffer, connection_index: usize) -> Container<'static, Message> {
|
||||
fn page_content(
|
||||
sniffer: &Sniffer,
|
||||
connection_index: usize,
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
let info_traffic_lock = sniffer
|
||||
|
|
@ -139,7 +145,7 @@ fn page_header(
|
|||
style: StyleType,
|
||||
color_gradient: GradientType,
|
||||
language: Language,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let tooltip = hide_translation(language).to_string();
|
||||
Container::new(
|
||||
|
|
@ -165,14 +171,13 @@ fn page_header(
|
|||
.padding(2)
|
||||
.height(Fixed(20.0))
|
||||
.width(Fixed(20.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::HideModal),
|
||||
tooltip,
|
||||
Position::Right,
|
||||
)
|
||||
.font(font)
|
||||
.style(ContainerType::Tooltip,
|
||||
),
|
||||
.style(ContainerType::Tooltip),
|
||||
)
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Horizontal::Center),
|
||||
|
|
@ -191,7 +196,7 @@ fn col_info(
|
|||
font: Font,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
Column::new()
|
||||
.spacing(10)
|
||||
.padding([0, 0, 0, 40])
|
||||
|
|
@ -243,7 +248,7 @@ fn get_host_info_col(
|
|||
host: &Host,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let mut host_info_col = Column::new().spacing(4);
|
||||
if r_dns.parse::<IpAddr>().is_err() || (!host.asn.name.is_empty() && host.asn.number > 0) {
|
||||
host_info_col =
|
||||
|
|
@ -275,7 +280,7 @@ fn get_local_tooltip(
|
|||
sniffer: &Sniffer,
|
||||
address_to_lookup: &str,
|
||||
key: &AddressPortPair,
|
||||
) -> Tooltip<'static, Message> {
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let my_interface_addresses = &*sniffer.device.addresses.lock().unwrap();
|
||||
get_computer_tooltip(
|
||||
is_my_address(
|
||||
|
|
@ -301,13 +306,13 @@ fn get_local_tooltip(
|
|||
}
|
||||
|
||||
fn get_src_or_dest_col(
|
||||
caption: Row<'static, Message>,
|
||||
caption: Row<'static, Message, Renderer<StyleType>>,
|
||||
ip: &String,
|
||||
port: u16,
|
||||
mac: &str,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
Column::new()
|
||||
.spacing(4)
|
||||
.push(
|
||||
|
|
@ -333,11 +338,11 @@ fn get_src_or_dest_col(
|
|||
}
|
||||
|
||||
fn assemble_widgets(
|
||||
col_info: Column<'static, Message>,
|
||||
source_col: Column<'static, Message>,
|
||||
dest_col: Column<'static, Message>,
|
||||
col_info: Column<'static, Message, Renderer<StyleType>>,
|
||||
source_col: Column<'static, Message, Renderer<StyleType>>,
|
||||
dest_col: Column<'static, Message, Renderer<StyleType>>,
|
||||
style: StyleType,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let [source_container, dest_container] = [source_col, dest_col].map(|col| {
|
||||
Container::new(col)
|
||||
.padding(7)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use iced::widget::{
|
|||
Text, Tooltip,
|
||||
};
|
||||
use iced::Length::FillPortion;
|
||||
use iced::{alignment, Alignment, Font, Length};
|
||||
use iced::{alignment, Alignment, Font, Length, Renderer};
|
||||
use pcap::Device;
|
||||
|
||||
use crate::gui::components::radio::{ip_version_radios, transport_protocol_radios};
|
||||
|
|
@ -29,7 +29,7 @@ use crate::translations::translations::{
|
|||
use crate::{AppProtocol, Language, StyleType};
|
||||
|
||||
/// Computes the body of gui initial page
|
||||
pub fn initial_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn initial_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
let col_adapter = get_col_adapter(sniffer, font);
|
||||
|
|
@ -116,14 +116,14 @@ pub fn initial_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
|
||||
Container::new(body)
|
||||
.height(Length::Fill)
|
||||
.style( ContainerType::Standard)
|
||||
.style(ContainerType::Standard)
|
||||
}
|
||||
|
||||
fn button_start(
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
color_gradient: GradientType,
|
||||
) -> Tooltip<'static, Message> {
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new("S")
|
||||
.font(ICONS)
|
||||
|
|
@ -134,7 +134,7 @@ fn button_start(
|
|||
.padding(10)
|
||||
.height(Length::Fixed(80.0))
|
||||
.width(Length::Fixed(160.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Gradient(color_gradient)).into())
|
||||
.style(ButtonType::Gradient(color_gradient))
|
||||
.on_press(Message::Start);
|
||||
|
||||
let tooltip = start_translation(language).to_string();
|
||||
|
|
@ -145,7 +145,7 @@ fn button_start(
|
|||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
fn get_col_adapter(sniffer: &Sniffer, font: Font) -> Column<Message> {
|
||||
fn get_col_adapter(sniffer: &Sniffer, font: Font) -> Column<Message, Renderer<StyleType>> {
|
||||
let mut dev_str_list = vec![];
|
||||
for dev in Device::list().expect("Error retrieving device list\r\n") {
|
||||
let mut dev_str = String::new();
|
||||
|
|
@ -199,17 +199,11 @@ fn get_col_adapter(sniffer: &Sniffer, font: Font) -> Column<Message> {
|
|||
Button::new(Text::new(description).font(font))
|
||||
.padding([20, 30])
|
||||
.width(Length::Fill)
|
||||
.style(
|
||||
ButtonStyleTuple(
|
||||
sniffer.style,
|
||||
if name == sniffer.device.name {
|
||||
ButtonType::BorderedRoundSelected
|
||||
} else {
|
||||
ButtonType::BorderedRound
|
||||
},
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.style(if name == sniffer.device.name {
|
||||
ButtonType::BorderedRoundSelected
|
||||
} else {
|
||||
ButtonType::BorderedRound
|
||||
})
|
||||
.on_press(Message::AdapterSelection(name)),
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use iced::widget::{button, horizontal_space, vertical_space, Rule};
|
|||
use iced::widget::{
|
||||
lazy, Button, Checkbox, Column, Container, PickList, Row, Scrollable, Text, TextInput, Tooltip,
|
||||
};
|
||||
use iced::{alignment, Alignment, Font, Length};
|
||||
use iced::{alignment, Alignment, Font, Length, Renderer};
|
||||
|
||||
use crate::gui::components::tab::get_pages_tabs;
|
||||
use crate::gui::components::types::my_modal::MyModal;
|
||||
|
|
@ -31,7 +31,7 @@ use crate::utils::formatted_strings::{get_connection_color, get_open_report_tool
|
|||
use crate::{Language, ReportSortType, RunningPage, Sniffer, StyleType};
|
||||
|
||||
/// Computes the body of gui inspect page
|
||||
pub fn inspect_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn inspect_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
let mut body = Column::new()
|
||||
|
|
@ -124,15 +124,14 @@ pub fn inspect_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
)
|
||||
.height(Length::Fixed(165.0))
|
||||
.padding(10)
|
||||
.style(ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
.push(report);
|
||||
|
||||
Container::new(Column::new().push(tab_and_body.push(body)))
|
||||
.height(Length::Fill)
|
||||
Container::new(Column::new().push(tab_and_body.push(body))).height(Length::Fill)
|
||||
}
|
||||
|
||||
fn lazy_report(sniffer: &Sniffer) -> Row<'static, Message> {
|
||||
fn lazy_report(sniffer: &Sniffer) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
let (search_results, results_number) = get_searched_entries(sniffer);
|
||||
|
|
@ -161,7 +160,7 @@ fn lazy_report(sniffer: &Sniffer) -> Row<'static, Message> {
|
|||
button(entry_row)
|
||||
.padding(2)
|
||||
.on_press(Message::ShowModal(MyModal::ConnectionDetails(val.index)))
|
||||
.style(ButtonStyleTuple(sniffer.style, ButtonType::Neutral).into()),
|
||||
.style(ButtonType::Neutral),
|
||||
);
|
||||
}
|
||||
if results_number > 0 {
|
||||
|
|
@ -222,7 +221,7 @@ fn lazy_report(sniffer: &Sniffer) -> Row<'static, Message> {
|
|||
Container::new(col_report)
|
||||
.padding([10, 7, 7, 7])
|
||||
.width(Length::Fixed(1042.0))
|
||||
.style( ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
.push(
|
||||
Container::new(get_button_open_report(
|
||||
|
|
@ -238,7 +237,7 @@ fn filters_col(
|
|||
search_params: &SearchParameters,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let search_params2 = search_params.clone();
|
||||
|
||||
|
|
@ -280,13 +279,11 @@ fn filters_col(
|
|||
)),
|
||||
)
|
||||
.padding([5, 8])
|
||||
.style(
|
||||
if search_params.only_favorites {
|
||||
ContainerType::Badge
|
||||
} else {
|
||||
ContainerType::Neutral
|
||||
}
|
||||
)
|
||||
.style(if search_params.only_favorites {
|
||||
ContainerType::Badge
|
||||
} else {
|
||||
ContainerType::Neutral
|
||||
}),
|
||||
)
|
||||
.push(
|
||||
Row::new()
|
||||
|
|
@ -344,7 +341,7 @@ fn filter_input(
|
|||
search_params: SearchParameters,
|
||||
font: Font,
|
||||
style: StyleType,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let is_filter_active = !filter_value.is_empty();
|
||||
|
||||
let button_clear = button_clear_filter(
|
||||
|
|
@ -416,16 +413,17 @@ fn filter_input(
|
|||
|
||||
Container::new(content)
|
||||
.padding(5)
|
||||
.style(
|
||||
if is_filter_active {
|
||||
ContainerType::Badge
|
||||
} else {
|
||||
ContainerType::Neutral
|
||||
}
|
||||
)
|
||||
.style(if is_filter_active {
|
||||
ContainerType::Badge
|
||||
} else {
|
||||
ContainerType::Neutral
|
||||
})
|
||||
}
|
||||
|
||||
fn get_button_change_page(style: StyleType, increment: bool) -> Button<'static, Message> {
|
||||
fn get_button_change_page(
|
||||
style: StyleType,
|
||||
increment: bool,
|
||||
) -> Button<'static, Message, Renderer<StyleType>> {
|
||||
button(
|
||||
Text::new(if increment { "j" } else { "i" })
|
||||
.size(8.0)
|
||||
|
|
@ -436,7 +434,7 @@ fn get_button_change_page(style: StyleType, increment: bool) -> Button<'static,
|
|||
.padding(2)
|
||||
.height(Length::Fixed(20.0))
|
||||
.width(Length::Fixed(25.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::UpdatePageNumber(increment))
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +445,7 @@ fn get_change_page_row(
|
|||
start_entry_num: usize,
|
||||
end_entry_num: usize,
|
||||
results_number: usize,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
Row::new()
|
||||
.height(Length::FillPortion(2))
|
||||
.align_items(Alignment::Center)
|
||||
|
|
@ -478,7 +476,7 @@ fn get_button_open_report(
|
|||
style: StyleType,
|
||||
language: Language,
|
||||
font: Font,
|
||||
) -> Tooltip<'static, Message> {
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new('8'.to_string())
|
||||
.font(ICONS)
|
||||
|
|
@ -489,20 +487,20 @@ fn get_button_open_report(
|
|||
.padding(10)
|
||||
.height(Length::Fixed(50.0))
|
||||
.width(Length::Fixed(75.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::OpenReport);
|
||||
|
||||
Tooltip::new(content, get_open_report_tooltip(language), Position::Top)
|
||||
.gap(5)
|
||||
.font(font)
|
||||
.style( ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
fn button_clear_filter(
|
||||
new_search_parameters: SearchParameters,
|
||||
style: StyleType,
|
||||
font: Font,
|
||||
) -> Button<'static, Message> {
|
||||
) -> Button<'static, Message, Renderer<StyleType>> {
|
||||
button(
|
||||
Text::new("×")
|
||||
.font(font)
|
||||
|
|
@ -513,6 +511,6 @@ fn button_clear_filter(
|
|||
.padding(2)
|
||||
.height(Length::Fixed(20.0))
|
||||
.width(Length::Fixed(20.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::Search(new_search_parameters))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use iced::widget::tooltip::Position;
|
|||
use iced::widget::{button, vertical_space};
|
||||
use iced::widget::{lazy, Column, Container, Row, Scrollable, Text, Tooltip};
|
||||
use iced::Length::FillPortion;
|
||||
use iced::{Alignment, Font, Length};
|
||||
use iced::{Alignment, Font, Length, Renderer};
|
||||
|
||||
use crate::countries::country_utils::get_flag_tooltip;
|
||||
use crate::countries::flags_pictures::FLAGS_WIDTH_BIG;
|
||||
|
|
@ -32,7 +32,7 @@ use crate::utils::formatted_strings::get_formatted_bytes_string_with_b;
|
|||
use crate::{Language, RunningPage, Sniffer, StyleType};
|
||||
|
||||
/// Computes the body of gui notifications page
|
||||
pub fn notifications_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn notifications_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let notifications = sniffer.notifications;
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ fn body_no_notifications_set(
|
|||
style: StyleType,
|
||||
font: Font,
|
||||
language: Language,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
Column::new()
|
||||
.padding(5)
|
||||
.spacing(5)
|
||||
|
|
@ -148,7 +148,7 @@ fn body_no_notifications_received(
|
|||
font: Font,
|
||||
language: Language,
|
||||
waiting: &str,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
Column::new()
|
||||
.padding(5)
|
||||
.spacing(5)
|
||||
|
|
@ -168,7 +168,7 @@ fn packets_notification_log(
|
|||
logged_notification: PacketsThresholdExceeded,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let threshold_str = format!(
|
||||
"{}: {} {}",
|
||||
|
|
@ -195,7 +195,7 @@ fn packets_notification_log(
|
|||
Position::FollowCursor,
|
||||
)
|
||||
.font(font)
|
||||
.style(ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip),
|
||||
)
|
||||
.push(
|
||||
Column::new()
|
||||
|
|
@ -243,7 +243,7 @@ fn bytes_notification_log(
|
|||
logged_notification: BytesThresholdExceeded,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let mut threshold_str = threshold_translation(language);
|
||||
threshold_str.push_str(": ");
|
||||
|
|
@ -275,7 +275,7 @@ fn bytes_notification_log(
|
|||
Position::FollowCursor,
|
||||
)
|
||||
.font(font)
|
||||
.style(ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip),
|
||||
)
|
||||
.push(
|
||||
Column::new()
|
||||
|
|
@ -318,14 +318,14 @@ fn bytes_notification_log(
|
|||
.height(Length::Fixed(120.0))
|
||||
.width(Length::Fixed(800.0))
|
||||
.padding(10)
|
||||
.style( ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound)
|
||||
}
|
||||
|
||||
fn favorite_notification_log(
|
||||
logged_notification: FavoriteTransmitted,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let domain = logged_notification.host.domain;
|
||||
let country = logged_notification.host.country;
|
||||
|
|
@ -360,7 +360,7 @@ fn favorite_notification_log(
|
|||
Position::FollowCursor,
|
||||
)
|
||||
.font(font)
|
||||
.style( ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip),
|
||||
)
|
||||
.push(
|
||||
Column::new()
|
||||
|
|
@ -391,7 +391,10 @@ fn favorite_notification_log(
|
|||
.style(ContainerType::BorderedRound)
|
||||
}
|
||||
|
||||
fn get_button_clear_all(style: StyleType, language: Language) -> Tooltip<'static, Message> {
|
||||
fn get_button_clear_all(
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Tooltip<'static, Message, Renderer<StyleType>> {
|
||||
let content = button(
|
||||
Text::new('h'.to_string())
|
||||
.font(ICONS)
|
||||
|
|
@ -402,7 +405,7 @@ fn get_button_clear_all(style: StyleType, language: Language) -> Tooltip<'static
|
|||
.padding(10)
|
||||
.height(Length::Fixed(50.0))
|
||||
.width(Length::Fixed(75.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::ShowModal(MyModal::ClearAll));
|
||||
|
||||
Tooltip::new(content, clear_all_translation(language), Position::Top)
|
||||
|
|
@ -411,7 +414,7 @@ fn get_button_clear_all(style: StyleType, language: Language) -> Tooltip<'static
|
|||
.style(ContainerType::Tooltip)
|
||||
}
|
||||
|
||||
fn lazy_logged_notifications(sniffer: &Sniffer) -> Column<'static, Message> {
|
||||
fn lazy_logged_notifications(sniffer: &Sniffer) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let mut ret_val = Column::new()
|
||||
.width(Length::Fixed(830.0))
|
||||
.padding(5)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use iced::widget::scrollable::Direction;
|
|||
use iced::widget::{button, lazy, vertical_space, Column, Container, Row, Scrollable, Text};
|
||||
use iced::widget::{horizontal_space, Rule};
|
||||
use iced::Length::{Fill, FillPortion};
|
||||
use iced::{Alignment, Font, Length};
|
||||
use iced::{Alignment, Font, Length, Renderer};
|
||||
|
||||
use crate::countries::country_utils::get_flag_tooltip;
|
||||
use crate::countries::flags_pictures::FLAGS_WIDTH_BIG;
|
||||
|
|
@ -43,7 +43,7 @@ use crate::utils::formatted_strings::{
|
|||
use crate::{AppProtocol, ChartType, Language, RunningPage, StyleType};
|
||||
|
||||
/// Computes the body of gui overview page
|
||||
pub fn overview_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn overview_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
let mut body = Column::new();
|
||||
|
|
@ -127,9 +127,7 @@ pub fn overview_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
.width(Fill)
|
||||
.align_x(Horizontal::Center)
|
||||
.align_y(Vertical::Center)
|
||||
.style(
|
||||
ContainerType::BorderedRound
|
||||
);
|
||||
.style(ContainerType::BorderedRound);
|
||||
|
||||
let col_info = lazy(
|
||||
(
|
||||
|
|
@ -168,9 +166,7 @@ pub fn overview_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
.padding([10, 5, 5, 5])
|
||||
.height(Length::Fill)
|
||||
.align_x(Horizontal::Center)
|
||||
.style(
|
||||
ContainerType::BorderedRound,
|
||||
)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
.push(col_chart),
|
||||
)
|
||||
|
|
@ -191,8 +187,7 @@ pub fn overview_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
);
|
||||
}
|
||||
|
||||
Container::new(Column::new().push(tab_and_body.push(body)))
|
||||
.height(Length::Fill)
|
||||
Container::new(Column::new().push(tab_and_body.push(body))).height(Length::Fill)
|
||||
}
|
||||
|
||||
fn body_no_packets(
|
||||
|
|
@ -200,7 +195,7 @@ fn body_no_packets(
|
|||
font: Font,
|
||||
language: Language,
|
||||
waiting: &str,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let adapter_name = device.name.clone();
|
||||
let (icon_text, nothing_to_see_text) = if device.addresses.lock().unwrap().is_empty() {
|
||||
(
|
||||
|
|
@ -237,7 +232,7 @@ fn body_no_observed(
|
|||
style: StyleType,
|
||||
language: Language,
|
||||
waiting: &str,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
|
||||
let tot_packets_text = some_observed_translation(language, observed)
|
||||
|
|
@ -263,7 +258,7 @@ fn body_pcap_error(
|
|||
waiting: &str,
|
||||
language: Language,
|
||||
font: Font,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
// let err_string = pcap_error.clone().unwrap();
|
||||
let error_text = error_translation(language, pcap_error)
|
||||
.horizontal_alignment(Horizontal::Center)
|
||||
|
|
@ -282,7 +277,7 @@ fn body_pcap_error(
|
|||
.push(vertical_space(FillPortion(2)))
|
||||
}
|
||||
|
||||
fn lazy_row_report(sniffer: &Sniffer) -> Row<'static, Message> {
|
||||
fn lazy_row_report(sniffer: &Sniffer) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let mut row_report = Row::new()
|
||||
.padding(10)
|
||||
.height(Length::Fill)
|
||||
|
|
@ -304,11 +299,11 @@ fn lazy_row_report(sniffer: &Sniffer) -> Row<'static, Message> {
|
|||
Container::new(row_report)
|
||||
.height(Length::Fill)
|
||||
.width(Length::Fixed(1170.0))
|
||||
.style(ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
}
|
||||
|
||||
fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message> {
|
||||
fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
let chart_type = sniffer.traffic_chart.chart_type;
|
||||
|
||||
|
|
@ -345,17 +340,11 @@ fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message> {
|
|||
.padding(0)
|
||||
.height(Length::Fixed(FLAGS_WIDTH_BIG * 0.75))
|
||||
.width(Length::Fixed(FLAGS_WIDTH_BIG))
|
||||
.style(
|
||||
ButtonStyleTuple(
|
||||
sniffer.style,
|
||||
if data_info_host.is_favorite {
|
||||
ButtonType::Starred
|
||||
} else {
|
||||
ButtonType::NotStarred
|
||||
},
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.style(if data_info_host.is_favorite {
|
||||
ButtonType::Starred
|
||||
} else {
|
||||
ButtonType::NotStarred
|
||||
})
|
||||
.on_press(Message::AddOrRemoveFavorite(
|
||||
host.clone(),
|
||||
!data_info_host.is_favorite,
|
||||
|
|
@ -444,7 +433,7 @@ fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message> {
|
|||
as_name: host.asn.name.clone(),
|
||||
..SearchParameters::default()
|
||||
}))
|
||||
.style(ButtonStyleTuple(sniffer.style, ButtonType::Neutral).into()),
|
||||
.style(ButtonType::Neutral),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -471,7 +460,7 @@ fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message> {
|
|||
col_host
|
||||
}
|
||||
|
||||
fn col_app(width: f32, sniffer: &Sniffer) -> Column<'static, Message> {
|
||||
fn col_app(width: f32, sniffer: &Sniffer) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
let chart_type = sniffer.traffic_chart.chart_type;
|
||||
|
||||
|
|
@ -562,7 +551,7 @@ fn col_app(width: f32, sniffer: &Sniffer) -> Column<'static, Message> {
|
|||
app: format!("{app:?}"),
|
||||
..SearchParameters::default()
|
||||
}))
|
||||
.style(ButtonStyleTuple(sniffer.style, ButtonType::Neutral).into()),
|
||||
.style(ButtonType::Neutral),
|
||||
);
|
||||
}
|
||||
col_app = col_app.push(
|
||||
|
|
@ -584,7 +573,7 @@ fn lazy_col_info(
|
|||
filtered: u128,
|
||||
dropped: u32,
|
||||
sniffer: &Sniffer,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
let filtered_bytes =
|
||||
sniffer.runtime_data.tot_sent_bytes + sniffer.runtime_data.tot_received_bytes;
|
||||
|
|
@ -659,7 +648,7 @@ fn col_device_filters(
|
|||
style: StyleType,
|
||||
filters: &Filters,
|
||||
device: &MyDevice,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let adapter_info = &device.name;
|
||||
#[cfg(target_os = "windows")]
|
||||
|
|
@ -682,7 +671,7 @@ fn col_data_representation(
|
|||
font: Font,
|
||||
style: StyleType,
|
||||
chart_type: ChartType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
Column::new()
|
||||
.width(Length::FillPortion(1))
|
||||
.push(
|
||||
|
|
@ -701,7 +690,7 @@ fn col_bytes_packets(
|
|||
all_bytes: u128,
|
||||
filtered_bytes: u128,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let dropped_val = if dropped > 0 {
|
||||
format!(
|
||||
"{} {}",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use iced::widget::vertical_space;
|
||||
use iced::widget::{Column, Container, Text};
|
||||
use iced::Length::Fixed;
|
||||
use iced::{Alignment, Length};
|
||||
use iced::{Alignment, Length, Renderer};
|
||||
|
||||
use crate::gui::components::radio::language_radios;
|
||||
use crate::gui::components::tab::get_settings_tabs;
|
||||
|
|
@ -12,9 +12,9 @@ use crate::gui::styles::style_constants::{get_font, FONT_SIZE_SUBTITLE};
|
|||
use crate::gui::styles::text::{TextStyleTuple, TextType};
|
||||
use crate::gui::types::message::Message;
|
||||
use crate::translations::translations::languages_title_translation;
|
||||
use crate::{Language, Sniffer};
|
||||
use crate::{Language, Sniffer, StyleType};
|
||||
|
||||
pub fn settings_language_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn settings_language_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
|
||||
let language_active = sniffer.language;
|
||||
|
|
@ -73,7 +73,7 @@ pub fn settings_language_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
Text::new("The selected language is not fully updated to version 1.2").font(font),
|
||||
)
|
||||
.padding(10.0)
|
||||
.style( ContainerType::Badge)
|
||||
.style(ContainerType::Badge),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use iced::widget::{
|
|||
TextInput, Tooltip,
|
||||
};
|
||||
use iced::Length::Fixed;
|
||||
use iced::{Alignment, Length};
|
||||
use iced::{Alignment, Length, Renderer};
|
||||
|
||||
use crate::gui::components::radio::{
|
||||
sound_bytes_threshold_radios, sound_favorite_radios, sound_packets_threshold_radios,
|
||||
|
|
@ -36,7 +36,7 @@ use crate::translations::translations::{
|
|||
};
|
||||
use crate::{Language, Sniffer, StyleType};
|
||||
|
||||
pub fn settings_notifications_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn settings_notifications_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
let mut content = Column::new()
|
||||
.width(Length::Fill)
|
||||
|
|
@ -114,14 +114,14 @@ pub fn settings_notifications_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
Container::new(content)
|
||||
.height(Fixed(400.0))
|
||||
.width(Fixed(800.0))
|
||||
.style( ContainerType::Modal)
|
||||
.style(ContainerType::Modal)
|
||||
}
|
||||
|
||||
fn get_packets_notify(
|
||||
packets_notification: PacketsNotification,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let checkbox = Checkbox::new(
|
||||
packets_threshold_translation(language),
|
||||
|
|
@ -159,7 +159,7 @@ fn get_packets_notify(
|
|||
Container::new(ret_val)
|
||||
.padding(10)
|
||||
.width(Fixed(700.0))
|
||||
.style( ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
} else {
|
||||
let input_row = Row::new()
|
||||
|
|
@ -183,7 +183,7 @@ fn get_packets_notify(
|
|||
Container::new(ret_val)
|
||||
.padding(10)
|
||||
.width(Fixed(700.0))
|
||||
.style( ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ fn get_bytes_notify(
|
|||
bytes_notification: BytesNotification,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let checkbox = Checkbox::new(
|
||||
bytes_threshold_translation(language),
|
||||
|
|
@ -230,7 +230,7 @@ fn get_bytes_notify(
|
|||
Container::new(ret_val)
|
||||
.padding(10)
|
||||
.width(Fixed(700.0))
|
||||
.style( ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
} else {
|
||||
let input_row = Row::new()
|
||||
|
|
@ -254,7 +254,7 @@ fn get_bytes_notify(
|
|||
Container::new(ret_val)
|
||||
.padding(10)
|
||||
.width(Fixed(700.0))
|
||||
.style(ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ fn get_favorite_notify(
|
|||
favorite_notification: FavoriteNotification,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let checkbox = Checkbox::new(
|
||||
favorite_notification_translation(language),
|
||||
|
|
@ -301,14 +301,14 @@ fn get_favorite_notify(
|
|||
Container::new(ret_val)
|
||||
.padding(10)
|
||||
.width(Fixed(700.0))
|
||||
.style( ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
} else {
|
||||
Column::new().padding(5).push(
|
||||
Container::new(ret_val)
|
||||
.padding(10)
|
||||
.width(Fixed(700.0))
|
||||
.style(ContainerType::BorderedRound)
|
||||
.style(ContainerType::BorderedRound),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ fn input_group_packets(
|
|||
packets_notification: PacketsNotification,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let curr_threshold_str = &packets_notification.threshold.unwrap().to_string();
|
||||
let input_row = Row::new()
|
||||
|
|
@ -361,7 +361,7 @@ fn input_group_bytes(
|
|||
bytes_notification: BytesNotification,
|
||||
style: StyleType,
|
||||
language: Language,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let mut info_str = per_second_translation(language).to_string();
|
||||
info_str.push_str(specify_multiples_translation(language));
|
||||
|
|
@ -402,7 +402,11 @@ fn input_group_bytes(
|
|||
.align_y(Vertical::Center)
|
||||
}
|
||||
|
||||
fn volume_slider(language: Language, style: StyleType, volume: u8) -> Container<'static, Message> {
|
||||
fn volume_slider(
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
volume: u8,
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
Container::new(
|
||||
Column::new()
|
||||
|
|
@ -446,7 +450,7 @@ pub fn settings_header(
|
|||
style: StyleType,
|
||||
color_gradient: GradientType,
|
||||
language: Language,
|
||||
) -> Container<'static, Message> {
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
let tooltip = hide_translation(language).to_string();
|
||||
//tooltip.push_str(" [esc]");
|
||||
|
|
@ -473,14 +477,13 @@ pub fn settings_header(
|
|||
.padding(2)
|
||||
.height(Fixed(20.0))
|
||||
.width(Fixed(20.0))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Standard).into())
|
||||
.style(ButtonType::Standard)
|
||||
.on_press(Message::CloseSettings),
|
||||
tooltip,
|
||||
Position::Right,
|
||||
)
|
||||
.font(font)
|
||||
.style(
|
||||
ContainerType::Tooltip)
|
||||
.style(ContainerType::Tooltip),
|
||||
)
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Horizontal::Center),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use iced::widget::scrollable::Direction;
|
|||
use iced::widget::{button, horizontal_space, vertical_space, Rule};
|
||||
use iced::widget::{Button, Column, Container, Row, Scrollable, Space, Text};
|
||||
use iced::Length::Fixed;
|
||||
use iced::{Alignment, Element, Length};
|
||||
use iced::{Alignment, Element, Length, Renderer};
|
||||
|
||||
use crate::gui::components::tab::get_settings_tabs;
|
||||
use crate::gui::pages::settings_notifications_page::settings_header;
|
||||
|
|
@ -25,7 +25,7 @@ use crate::translations::translations_2::color_gradients_translation;
|
|||
use crate::StyleType::{Day, DeepSea, MonAmour, Night};
|
||||
use crate::{Language, Sniffer, StyleType};
|
||||
|
||||
pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
|
||||
pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message, Renderer<StyleType>> {
|
||||
let font = get_font(sniffer.style);
|
||||
let mut content = Column::new()
|
||||
.align_items(Alignment::Center)
|
||||
|
|
@ -54,7 +54,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
.push(vertical_space(Length::Fixed(15.0)))
|
||||
.push(
|
||||
appearance_title_translation(sniffer.language)
|
||||
.style(TextStyleTuple(sniffer.style, TextType::Subtitle))
|
||||
.style(TextType::Subtitle)
|
||||
.font(font)
|
||||
.size(FONT_SIZE_SUBTITLE),
|
||||
)
|
||||
|
|
@ -109,7 +109,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
|
|||
|
||||
let styles_scroll = Scrollable::new(styles_col)
|
||||
.direction(Direction::Vertical(ScrollbarType::properties()))
|
||||
.style(ScrollbarStyleTuple(sniffer.style, ScrollbarType::Standard));
|
||||
.style(ScrollbarType::Standard);
|
||||
|
||||
content = content.push(styles_scroll);
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ fn gradients_row(
|
|||
style: StyleType,
|
||||
color_gradient: GradientType,
|
||||
language: Language,
|
||||
) -> Row<'static, Message> {
|
||||
) -> Row<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
|
|
@ -144,7 +144,7 @@ fn gradients_row(
|
|||
} else {
|
||||
20.0
|
||||
}))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Gradient(GradientType::None)).into())
|
||||
.style(ButtonType::Gradient(GradientType::None))
|
||||
.on_press(Message::GradientsSelection(GradientType::None)),
|
||||
)
|
||||
.push(
|
||||
|
|
@ -163,7 +163,7 @@ fn gradients_row(
|
|||
20.0
|
||||
}))
|
||||
.on_press(Message::GradientsSelection(GradientType::Mild))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Gradient(GradientType::Mild)).into()),
|
||||
.style(ButtonType::Gradient(GradientType::Mild)),
|
||||
)
|
||||
.push(
|
||||
button(
|
||||
|
|
@ -181,7 +181,7 @@ fn gradients_row(
|
|||
20.0
|
||||
}))
|
||||
.on_press(Message::GradientsSelection(GradientType::Wild))
|
||||
.style(ButtonStyleTuple(style, ButtonType::Gradient(GradientType::Wild)).into()),
|
||||
.style(ButtonType::Gradient(GradientType::Wild)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ fn get_palette_container(
|
|||
name: String,
|
||||
description: String,
|
||||
on_press: StyleType,
|
||||
) -> Button<'static, Message> {
|
||||
) -> Button<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
|
||||
let is_custom = matches!(on_press, StyleType::Custom(_));
|
||||
|
|
@ -210,59 +210,60 @@ fn get_palette_container(
|
|||
.height(Length::Fixed(if is_custom { 75.0 } else { 110.0 }))
|
||||
.width(Length::Fixed(380.0))
|
||||
.padding(5)
|
||||
.style(
|
||||
ButtonStyleTuple(
|
||||
style,
|
||||
if on_press.eq(&style) {
|
||||
ButtonType::BorderedRoundSelected
|
||||
} else {
|
||||
ButtonType::BorderedRound
|
||||
},
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.style(if on_press.eq(&style) {
|
||||
ButtonType::BorderedRoundSelected
|
||||
} else {
|
||||
ButtonType::BorderedRound
|
||||
})
|
||||
.on_press(Message::Style(on_press))
|
||||
}
|
||||
|
||||
fn get_palette(style: StyleType, is_custom: bool) -> Container<'static, Message> {
|
||||
fn get_palette(
|
||||
style: StyleType,
|
||||
is_custom: bool,
|
||||
) -> Container<'static, Message, Renderer<StyleType>> {
|
||||
let height = if is_custom { 25.0 } else { 40.0 };
|
||||
|
||||
Container::new(
|
||||
Row::new()
|
||||
.padding(0)
|
||||
.push(Row::new().padding(0).width(Length::Fixed(120.0)).push(
|
||||
Rule::horizontal(height).style(<RuleStyleTuple as Into<iced::theme::Rule>>::into(
|
||||
RuleStyleTuple(style, RuleType::PalettePrimary),
|
||||
)),
|
||||
))
|
||||
.push(Row::new().padding(0).width(Length::Fixed(80.0)).push(
|
||||
Rule::horizontal(height).style(<RuleStyleTuple as Into<iced::theme::Rule>>::into(
|
||||
RuleStyleTuple(style, RuleType::PaletteSecondary),
|
||||
)),
|
||||
))
|
||||
.push(Row::new().padding(0).width(Length::Fixed(60.0)).push(
|
||||
Rule::horizontal(height).style(<RuleStyleTuple as Into<iced::theme::Rule>>::into(
|
||||
RuleStyleTuple(style, RuleType::PaletteOutgoing),
|
||||
)),
|
||||
))
|
||||
.push(Row::new().padding(0).width(Length::Fixed(40.0)).push(
|
||||
Rule::horizontal(height).style(<RuleStyleTuple as Into<iced::theme::Rule>>::into(
|
||||
RuleStyleTuple(style, RuleType::PaletteButtons),
|
||||
)),
|
||||
)),
|
||||
.push(
|
||||
Row::new()
|
||||
.padding(0)
|
||||
.width(Length::Fixed(120.0))
|
||||
.push(Rule::horizontal(height).style(RuleType::PalettePrimary)),
|
||||
)
|
||||
.push(
|
||||
Row::new()
|
||||
.padding(0)
|
||||
.width(Length::Fixed(80.0))
|
||||
.push(Rule::horizontal(height).style(RuleType::PaletteSecondary)),
|
||||
)
|
||||
.push(
|
||||
Row::new()
|
||||
.padding(0)
|
||||
.width(Length::Fixed(60.0))
|
||||
.push(Rule::horizontal(height).style(RuleType::PaletteOutgoing)),
|
||||
)
|
||||
.push(
|
||||
Row::new()
|
||||
.padding(0)
|
||||
.width(Length::Fixed(40.0))
|
||||
.push(Rule::horizontal(height).style(RuleType::PaletteButtons)),
|
||||
),
|
||||
)
|
||||
.align_x(Horizontal::Center)
|
||||
.align_y(Vertical::Center)
|
||||
.width(300.0 + 2.0 * BORDER_WIDTH)
|
||||
.height(height + 1.7 * BORDER_WIDTH)
|
||||
.style( ContainerType::Palette)
|
||||
.style(ContainerType::Palette)
|
||||
}
|
||||
|
||||
// Buttons for each extra style arranged in rows of two
|
||||
fn get_extra_palettes(
|
||||
styles: &[ExtraStyles],
|
||||
current_style: StyleType,
|
||||
) -> Vec<Element<'static, Message>> {
|
||||
) -> Vec<Element<'static, Message, Renderer<StyleType>>> {
|
||||
// Map each extra style into a palette container
|
||||
let mut styles = styles.iter().map(|&style| {
|
||||
let name = style.to_string();
|
||||
|
|
@ -286,12 +287,16 @@ fn get_extra_palettes(
|
|||
.push(horizontal_space(Length::Fixed(15.0)))
|
||||
.push(second)
|
||||
.into(),
|
||||
<Space as Into<Element<Message>>>::into(vertical_space(Length::Fixed(10.0))),
|
||||
<Space as Into<Element<Message, Renderer<StyleType>>>>::into(vertical_space(
|
||||
Length::Fixed(10.0),
|
||||
)),
|
||||
]);
|
||||
} else {
|
||||
children.extend([
|
||||
Row::new().push(first).into(),
|
||||
<Space as Into<Element<Message>>>::into(vertical_space(Length::Fixed(10.0))),
|
||||
<Space as Into<Element<Message, Renderer<StyleType>>>>::into(vertical_space(
|
||||
Length::Fixed(10.0),
|
||||
)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ use crate::gui::styles::types::gradient_type::{
|
|||
use crate::gui::styles::types::palette::mix_colors;
|
||||
use crate::{get_colors, StyleType};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub enum ButtonType {
|
||||
#[default]
|
||||
Standard,
|
||||
BorderedRound,
|
||||
BorderedRoundSelected,
|
||||
|
|
@ -32,81 +33,69 @@ pub enum ButtonType {
|
|||
#[derive(Clone)]
|
||||
pub struct ButtonStyleTuple(pub StyleType, pub ButtonType);
|
||||
|
||||
impl From<ButtonStyleTuple> for iced::theme::Button {
|
||||
fn from(tuple: ButtonStyleTuple) -> Self {
|
||||
iced::theme::Button::Custom(Box::new(tuple))
|
||||
}
|
||||
}
|
||||
// impl From<ButtonType> for iced::theme::Button {
|
||||
// fn from(value: ButtonType) -> Self {
|
||||
// iced::theme::Button::Custom(Box::new(value))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl button::StyleSheet for ButtonStyleTuple {
|
||||
type Style = iced::Theme;
|
||||
impl button::StyleSheet for StyleType {
|
||||
type Style = ButtonType;
|
||||
|
||||
fn active(&self, _: &Self::Style) -> button::Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
fn active(&self, style: &Self::Style) -> button::Appearance {
|
||||
let colors = get_colors(*self);
|
||||
button::Appearance {
|
||||
background: Some(match self {
|
||||
ButtonStyleTuple(_, ButtonType::TabActive | ButtonType::BorderedRoundSelected) => {
|
||||
background: Some(match style {
|
||||
ButtonType::TabActive | ButtonType::BorderedRoundSelected => {
|
||||
Background::Color(mix_colors(colors.primary, colors.buttons))
|
||||
}
|
||||
ButtonStyleTuple(_, ButtonType::Starred) => {
|
||||
Background::Color(get_starred_color(self.0))
|
||||
}
|
||||
ButtonStyleTuple(_, ButtonType::Badge) => Background::Color(colors.secondary),
|
||||
ButtonStyleTuple(_, ButtonType::BorderedRound) => Background::Color(Color {
|
||||
a: get_alpha_round_containers(self.0),
|
||||
ButtonType::Starred => Background::Color(get_starred_color(*self)),
|
||||
ButtonType::Badge => Background::Color(colors.secondary),
|
||||
ButtonType::BorderedRound => Background::Color(Color {
|
||||
a: get_alpha_round_containers(*self),
|
||||
..colors.buttons
|
||||
}),
|
||||
ButtonStyleTuple(_, ButtonType::Neutral | ButtonType::NotStarred) => {
|
||||
ButtonType::Neutral | ButtonType::NotStarred => {
|
||||
Background::Color(Color::TRANSPARENT)
|
||||
}
|
||||
ButtonStyleTuple(_, ButtonType::Gradient(GradientType::None)) => {
|
||||
Background::Color(colors.secondary)
|
||||
}
|
||||
ButtonStyleTuple(_, ButtonType::Gradient(gradient_type)) => Background::Gradient(
|
||||
get_gradient_buttons(&colors, *gradient_type, self.0.is_nightly()),
|
||||
),
|
||||
ButtonType::Gradient(GradientType::None) => Background::Color(colors.secondary),
|
||||
ButtonType::Gradient(gradient_type) => Background::Gradient(get_gradient_buttons(
|
||||
&colors,
|
||||
*gradient_type,
|
||||
self.is_nightly(),
|
||||
)),
|
||||
_ => Background::Color(colors.buttons),
|
||||
}),
|
||||
border_radius: match self {
|
||||
ButtonStyleTuple(_, ButtonType::Neutral) => 0.0.into(),
|
||||
ButtonStyleTuple(_, ButtonType::TabActive | ButtonType::TabInactive) => {
|
||||
[0.0, 0.0, 30.0, 30.0].into()
|
||||
}
|
||||
ButtonStyleTuple(
|
||||
_,
|
||||
ButtonType::BorderedRound | ButtonType::BorderedRoundSelected,
|
||||
) => 12.0.into(),
|
||||
ButtonStyleTuple(_, ButtonType::Starred | ButtonType::NotStarred) => 100.0.into(),
|
||||
border_radius: match style {
|
||||
ButtonType::Neutral => 0.0.into(),
|
||||
ButtonType::TabActive | ButtonType::TabInactive => [0.0, 0.0, 30.0, 30.0].into(),
|
||||
ButtonType::BorderedRound | ButtonType::BorderedRoundSelected => 12.0.into(),
|
||||
ButtonType::Starred | ButtonType::NotStarred => 100.0.into(),
|
||||
_ => BORDER_BUTTON_RADIUS.into(),
|
||||
},
|
||||
border_width: match self {
|
||||
ButtonStyleTuple(
|
||||
_,
|
||||
ButtonType::TabActive
|
||||
| ButtonType::TabInactive
|
||||
| ButtonType::Starred
|
||||
| ButtonType::NotStarred
|
||||
| ButtonType::Neutral
|
||||
| ButtonType::Badge,
|
||||
) => 0.0,
|
||||
ButtonStyleTuple(_, ButtonType::BorderedRound) => BORDER_WIDTH * 2.0,
|
||||
border_width: match style {
|
||||
ButtonType::TabActive
|
||||
| ButtonType::TabInactive
|
||||
| ButtonType::Starred
|
||||
| ButtonType::NotStarred
|
||||
| ButtonType::Neutral
|
||||
| ButtonType::Badge => 0.0,
|
||||
ButtonType::BorderedRound => BORDER_WIDTH * 2.0,
|
||||
_ => BORDER_WIDTH,
|
||||
},
|
||||
shadow_offset: match self.1 {
|
||||
shadow_offset: match style {
|
||||
ButtonType::TabActive | ButtonType::TabInactive => Vector::new(3.0, 2.0),
|
||||
_ => Vector::new(0.0, 0.0),
|
||||
},
|
||||
text_color: match self {
|
||||
ButtonStyleTuple(_, ButtonType::Starred) => Color::BLACK,
|
||||
ButtonStyleTuple(_, ButtonType::Badge | ButtonType::Gradient(_)) => {
|
||||
colors.text_headers
|
||||
}
|
||||
text_color: match style {
|
||||
ButtonType::Starred => Color::BLACK,
|
||||
ButtonType::Badge | ButtonType::Gradient(_) => colors.text_headers,
|
||||
_ => colors.text_body,
|
||||
},
|
||||
border_color: match self {
|
||||
ButtonStyleTuple(_, ButtonType::Alert) => Color::new(0.8, 0.15, 0.15, 1.0),
|
||||
ButtonStyleTuple(_, ButtonType::BorderedRound) => Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
border_color: match style {
|
||||
ButtonType::Alert => Color::new(0.8, 0.15, 0.15, 1.0),
|
||||
ButtonType::BorderedRound => Color {
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
_ => colors.secondary,
|
||||
|
|
@ -114,62 +103,49 @@ impl button::StyleSheet for ButtonStyleTuple {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, _: &Self::Style) -> button::Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
fn hovered(&self, style: &Self::Style) -> button::Appearance {
|
||||
let colors = get_colors(*self);
|
||||
button::Appearance {
|
||||
shadow_offset: match self.1 {
|
||||
shadow_offset: match style {
|
||||
ButtonType::Neutral => Vector::default(),
|
||||
ButtonType::TabActive | ButtonType::TabInactive => Vector::new(3.0, 3.0),
|
||||
_ => Vector::new(0.0, 2.0),
|
||||
},
|
||||
background: Some(match self {
|
||||
ButtonStyleTuple(_, ButtonType::Starred) => {
|
||||
Background::Color(get_starred_color(self.0))
|
||||
}
|
||||
ButtonStyleTuple(_, ButtonType::Gradient(GradientType::None)) => {
|
||||
background: Some(match style {
|
||||
ButtonType::Starred => Background::Color(get_starred_color(*self)),
|
||||
ButtonType::Gradient(GradientType::None) => {
|
||||
Background::Color(mix_colors(colors.primary, colors.secondary))
|
||||
}
|
||||
ButtonStyleTuple(_, ButtonType::Gradient(gradient_type)) => Background::Gradient(
|
||||
get_gradient_hovered_buttons(&colors, *gradient_type, self.0.is_nightly()),
|
||||
ButtonType::Gradient(gradient_type) => Background::Gradient(
|
||||
get_gradient_hovered_buttons(&colors, *gradient_type, self.is_nightly()),
|
||||
),
|
||||
_ => Background::Color(mix_colors(colors.primary, colors.buttons)),
|
||||
}),
|
||||
border_radius: match self {
|
||||
ButtonStyleTuple(_, ButtonType::Neutral) => 0.0.into(),
|
||||
ButtonStyleTuple(_, ButtonType::TabActive | ButtonType::TabInactive) => {
|
||||
[0.0, 0.0, 30.0, 30.0].into()
|
||||
}
|
||||
ButtonStyleTuple(
|
||||
_,
|
||||
ButtonType::BorderedRound | ButtonType::BorderedRoundSelected,
|
||||
) => 12.0.into(),
|
||||
ButtonStyleTuple(_, ButtonType::Starred | ButtonType::NotStarred) => 100.0.into(),
|
||||
border_radius: match style {
|
||||
ButtonType::Neutral => 0.0.into(),
|
||||
ButtonType::TabActive | ButtonType::TabInactive => [0.0, 0.0, 30.0, 30.0].into(),
|
||||
ButtonType::BorderedRound | ButtonType::BorderedRoundSelected => 12.0.into(),
|
||||
ButtonType::Starred | ButtonType::NotStarred => 100.0.into(),
|
||||
_ => BORDER_BUTTON_RADIUS.into(),
|
||||
},
|
||||
border_width: match self {
|
||||
ButtonStyleTuple(
|
||||
_,
|
||||
ButtonType::Starred
|
||||
| ButtonType::TabActive
|
||||
| ButtonType::TabInactive
|
||||
| ButtonType::BorderedRound,
|
||||
) => 0.0,
|
||||
border_width: match style {
|
||||
ButtonType::Starred
|
||||
| ButtonType::TabActive
|
||||
| ButtonType::TabInactive
|
||||
| ButtonType::BorderedRound => 0.0,
|
||||
_ => BORDER_WIDTH,
|
||||
},
|
||||
border_color: match self {
|
||||
ButtonStyleTuple(_, ButtonType::Alert) => Color::new(0.8, 0.15, 0.15, 1.0),
|
||||
ButtonStyleTuple(
|
||||
_,
|
||||
ButtonType::BorderedRound | ButtonType::Neutral | ButtonType::NotStarred,
|
||||
) => Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
border_color: match style {
|
||||
ButtonType::Alert => Color::new(0.8, 0.15, 0.15, 1.0),
|
||||
ButtonType::BorderedRound | ButtonType::Neutral | ButtonType::NotStarred => Color {
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
_ => colors.secondary,
|
||||
},
|
||||
text_color: match self {
|
||||
ButtonStyleTuple(_, ButtonType::Starred) => Color::BLACK,
|
||||
ButtonStyleTuple(_, ButtonType::Gradient(_)) => colors.text_headers,
|
||||
text_color: match style {
|
||||
ButtonType::Starred => Color::BLACK,
|
||||
ButtonType::Gradient(_) => colors.text_headers,
|
||||
_ => colors.text_body,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
//! Containers style
|
||||
|
||||
use iced::theme::Container;
|
||||
use iced::widget::container::Appearance;
|
||||
use iced::Theme;
|
||||
use iced::{Background, Color};
|
||||
use iced::theme::Container;
|
||||
|
||||
use crate::gui::styles::style_constants::{
|
||||
get_alpha_chart_badge, get_alpha_round_borders, get_alpha_round_containers,
|
||||
|
|
@ -31,6 +31,12 @@ pub enum ContainerType {
|
|||
#[derive(Clone)]
|
||||
pub struct ContainerStyleTuple(pub StyleType, pub ContainerType);
|
||||
|
||||
// impl From<ContainerType> for iced::theme::Container {
|
||||
// fn from(value: ContainerType) -> Self {
|
||||
// iced::theme::Container::Custom(Box::new(value))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl iced::widget::container::StyleSheet for StyleType {
|
||||
type Style = ContainerType;
|
||||
|
||||
|
|
@ -42,9 +48,7 @@ impl iced::widget::container::StyleSheet for StyleType {
|
|||
_ => colors.text_body,
|
||||
}),
|
||||
background: Some(match style {
|
||||
ContainerType::Gradient(GradientType::None) => {
|
||||
Background::Color(colors.secondary)
|
||||
}
|
||||
ContainerType::Gradient(GradientType::None) => Background::Color(colors.secondary),
|
||||
ContainerType::Tooltip => Background::Color(colors.buttons),
|
||||
ContainerType::BorderedRound => Background::Color(Color {
|
||||
a: get_alpha_round_containers(*self),
|
||||
|
|
@ -57,32 +61,26 @@ impl iced::widget::container::StyleSheet for StyleType {
|
|||
a: get_alpha_chart_badge(*self),
|
||||
..colors.secondary
|
||||
}),
|
||||
ContainerType::Gradient(gradient_type) => {
|
||||
Background::Gradient(get_gradient_headers(
|
||||
&colors,
|
||||
*gradient_type,
|
||||
self.is_nightly(),
|
||||
))
|
||||
}
|
||||
ContainerType::Gradient(gradient_type) => Background::Gradient(
|
||||
get_gradient_headers(&colors, *gradient_type, self.is_nightly()),
|
||||
),
|
||||
_ => Background::Color(colors.primary),
|
||||
}),
|
||||
border_radius: match style {
|
||||
ContainerType::BorderedRound | ContainerType::Alert => {
|
||||
BORDER_ROUNDED_RADIUS.into()
|
||||
}
|
||||
ContainerType::Modal => {
|
||||
ContainerType::BorderedRound | ContainerType::Alert => BORDER_ROUNDED_RADIUS.into(),
|
||||
ContainerType::Modal => {
|
||||
[0.0, 0.0, BORDER_ROUNDED_RADIUS, BORDER_ROUNDED_RADIUS].into()
|
||||
}
|
||||
ContainerType::Tooltip => 7.0.into(),
|
||||
ContainerType::Badge => 100.0.into(),
|
||||
ContainerType::Badge => 100.0.into(),
|
||||
_ => 0.0.into(),
|
||||
},
|
||||
border_width: match style {
|
||||
ContainerType::Standard
|
||||
| ContainerType::Modal
|
||||
| ContainerType::Neutral
|
||||
| ContainerType::Gradient(_) => 0.0,
|
||||
ContainerType::Tooltip => BORDER_WIDTH / 2.0,
|
||||
ContainerType::Standard
|
||||
| ContainerType::Modal
|
||||
| ContainerType::Neutral
|
||||
| ContainerType::Gradient(_) => 0.0,
|
||||
ContainerType::Tooltip => BORDER_WIDTH / 2.0,
|
||||
ContainerType::BorderedRound => BORDER_WIDTH * 2.0,
|
||||
_ => BORDER_WIDTH,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -21,34 +21,34 @@ pub enum RuleType {
|
|||
#[derive(Clone)]
|
||||
pub struct RuleStyleTuple(pub StyleType, pub RuleType);
|
||||
|
||||
impl From<RuleStyleTuple> for iced::theme::Rule {
|
||||
fn from(tuple: RuleStyleTuple) -> Self {
|
||||
iced::theme::Rule::Custom(Box::new(tuple))
|
||||
}
|
||||
}
|
||||
// impl From<RuleStyleTuple> for iced::theme::Rule {
|
||||
// fn from(tuple: RuleStyleTuple) -> Self {
|
||||
// iced::theme::Rule::Custom(Box::new(tuple))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl rule::StyleSheet for RuleStyleTuple {
|
||||
type Style = iced::Theme;
|
||||
impl rule::StyleSheet for StyleType {
|
||||
type Style = RuleType;
|
||||
|
||||
fn appearance(&self, _: &Self::Style) -> iced::widget::rule::Appearance {
|
||||
let colors = get_colors(self.0);
|
||||
fn appearance(&self, style: &Self::Style) -> iced::widget::rule::Appearance {
|
||||
let colors = get_colors(*self);
|
||||
iced::widget::rule::Appearance {
|
||||
color: match self.1 {
|
||||
color: match style {
|
||||
RuleType::Incoming | RuleType::PaletteSecondary => colors.secondary,
|
||||
RuleType::Outgoing | RuleType::PaletteOutgoing => colors.outgoing,
|
||||
RuleType::PalettePrimary => colors.primary,
|
||||
RuleType::PaletteButtons => colors.buttons,
|
||||
RuleType::Standard => Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
},
|
||||
width: match self.1 {
|
||||
width: match style {
|
||||
RuleType::Incoming | RuleType::Outgoing => 5,
|
||||
RuleType::PalettePrimary
|
||||
| RuleType::PaletteSecondary
|
||||
| RuleType::PaletteOutgoing
|
||||
| RuleType::PaletteButtons => match self.0 {
|
||||
| RuleType::PaletteButtons => match self {
|
||||
StyleType::Custom(_) => 25,
|
||||
_ => 40,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -23,28 +23,28 @@ impl ScrollbarType {
|
|||
#[derive(Clone)]
|
||||
pub struct ScrollbarStyleTuple(pub StyleType, pub ScrollbarType);
|
||||
|
||||
impl From<ScrollbarStyleTuple> for iced::theme::Scrollable {
|
||||
fn from(tuple: ScrollbarStyleTuple) -> Self {
|
||||
iced::theme::Scrollable::Custom(Box::new(tuple))
|
||||
}
|
||||
}
|
||||
// impl From<ScrollbarStyleTuple> for iced::theme::Scrollable {
|
||||
// fn from(tuple: ScrollbarStyleTuple) -> Self {
|
||||
// iced::theme::Scrollable::Custom(Box::new(tuple))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl iced::widget::scrollable::StyleSheet for ScrollbarStyleTuple {
|
||||
type Style = Theme;
|
||||
impl iced::widget::scrollable::StyleSheet for StyleType {
|
||||
type Style = ScrollbarType;
|
||||
|
||||
fn active(&self, _: &Self::Style) -> Scrollbar {
|
||||
let colors = get_colors(self.0);
|
||||
fn active(&self, style: &Self::Style) -> Scrollbar {
|
||||
let colors = get_colors(*self);
|
||||
Scrollbar {
|
||||
background: Some(Background::Color(Color::TRANSPARENT)),
|
||||
border_radius: BORDER_ROUNDED_RADIUS.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
scroller: Scroller {
|
||||
color: Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
border_radius: BORDER_ROUNDED_RADIUS.into(),
|
||||
|
|
@ -54,17 +54,17 @@ impl iced::widget::scrollable::StyleSheet for ScrollbarStyleTuple {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, _: &Self::Style, is_mouse_over_scrollbar: bool) -> Scrollbar {
|
||||
let colors = get_colors(self.0);
|
||||
fn hovered(&self, style: &Self::Style, is_mouse_over_scrollbar: bool) -> Scrollbar {
|
||||
let colors = get_colors(*self);
|
||||
Scrollbar {
|
||||
background: Some(Background::Color(Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
})),
|
||||
border_radius: BORDER_ROUNDED_RADIUS.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color {
|
||||
a: get_alpha_round_borders(self.0),
|
||||
a: get_alpha_round_borders(*self),
|
||||
..colors.buttons
|
||||
},
|
||||
scroller: Scroller {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
//! Text style
|
||||
|
||||
use iced::widget::text::Appearance;
|
||||
use iced::widget::{Column, Text};
|
||||
use iced::Color;
|
||||
use iced::{Color, Renderer};
|
||||
|
||||
use crate::gui::styles::style_constants::get_font;
|
||||
use crate::gui::types::message::Message;
|
||||
use crate::{get_colors, StyleType};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub enum TextType {
|
||||
#[default]
|
||||
Standard,
|
||||
Title,
|
||||
Subtitle,
|
||||
|
|
@ -20,12 +22,12 @@ impl TextType {
|
|||
subtitle: &str,
|
||||
desc: &str,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
Column::new()
|
||||
.push(
|
||||
Text::new(format!("{subtitle}:"))
|
||||
.style(TextStyleTuple(style, TextType::Subtitle))
|
||||
.style(TextType::Subtitle)
|
||||
.font(font),
|
||||
)
|
||||
.push(Text::new(format!(" {desc}")).font(font))
|
||||
|
|
@ -41,6 +43,16 @@ impl From<TextStyleTuple> for iced::theme::Text {
|
|||
}
|
||||
}
|
||||
|
||||
impl iced::widget::text::StyleSheet for StyleType {
|
||||
type Style = TextType;
|
||||
|
||||
fn appearance(&self, style: Self::Style) -> Appearance {
|
||||
Appearance {
|
||||
color: Some(highlight(*self, style)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the weighted average of two colors; color intensity is fixed to 100%
|
||||
pub fn highlight(style: StyleType, element: TextType) -> Color {
|
||||
let colors = get_colors(style);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use iced::{application, Background, Color};
|
||||
use iced::application::Appearance;
|
||||
use iced::widget::{container, text};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::get_colors;
|
||||
use crate::gui::styles::container::ContainerType;
|
||||
use iced::application::Appearance;
|
||||
use iced::widget::{container, text};
|
||||
use iced::{application, Background, Color};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::gui::styles::types::custom_palette::ExtraStyles;
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ impl application::StyleSheet for StyleType {
|
|||
let colors = get_colors(*self);
|
||||
Appearance {
|
||||
background_color: colors.primary,
|
||||
text_color: colors.text_body
|
||||
text_color: colors.text_body,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use iced::Renderer;
|
||||
use std::cmp::{min, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ use crate::networking::types::data_info::DataInfo;
|
|||
use crate::networking::types::data_info_host::DataInfoHost;
|
||||
use crate::networking::types::host::Host;
|
||||
use crate::networking::types::info_address_port_pair::InfoAddressPortPair;
|
||||
use crate::{AppProtocol, ChartType, InfoTraffic, ReportSortType, Sniffer};
|
||||
use crate::{AppProtocol, ChartType, InfoTraffic, ReportSortType, Sniffer, StyleType};
|
||||
|
||||
/// Returns the elements which satisfy the search constraints and belong to the given page,
|
||||
/// and the total number of elements which satisfy the search constraints
|
||||
|
|
@ -22,7 +23,7 @@ pub fn get_searched_entries(
|
|||
Vec<(
|
||||
AddressPortPair,
|
||||
InfoAddressPortPair,
|
||||
Tooltip<'static, Message>,
|
||||
Tooltip<'static, Message, Renderer<StyleType>>,
|
||||
)>,
|
||||
usize,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use crate::StyleType;
|
||||
use iced::widget::Text;
|
||||
use iced::Renderer;
|
||||
|
||||
use crate::translations::types::language::Language;
|
||||
|
||||
pub fn choose_adapters_translation(language: Language) -> Text<'static> {
|
||||
pub fn choose_adapters_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Select network adapter to inspect",
|
||||
Language::IT => "Seleziona la scheda di rete da ispezionare",
|
||||
|
|
@ -46,7 +48,7 @@ pub fn application_protocol_translation(language: Language) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn select_filters_translation(language: Language) -> Text<'static> {
|
||||
pub fn select_filters_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Select filters to be applied on network traffic",
|
||||
Language::IT => "Seleziona i filtri da applicare al traffico di rete",
|
||||
|
|
@ -129,7 +131,7 @@ pub fn addresses_translation(language: Language) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ip_version_translation(language: Language) -> Text<'static> {
|
||||
pub fn ip_version_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "IP version",
|
||||
Language::IT => "Versione IP",
|
||||
|
|
@ -172,7 +174,7 @@ pub fn transport_protocol_translation(language: Language) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn traffic_rate_translation(language: Language) -> Text<'static> {
|
||||
pub fn traffic_rate_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Traffic rate",
|
||||
Language::IT => "Intensità del traffico",
|
||||
|
|
@ -194,7 +196,7 @@ pub fn traffic_rate_translation(language: Language) -> Text<'static> {
|
|||
})
|
||||
}
|
||||
|
||||
// pub fn relevant_connections_translation(language: Language) -> Text<'static> {
|
||||
// pub fn relevant_connections_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
// Text::new(match language {
|
||||
// Language::EN => "Relevant connections:",
|
||||
// Language::IT => "Connessioni rilevanti:",
|
||||
|
|
@ -237,7 +239,7 @@ pub fn settings_translation(language: Language) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn yes_translation(language: Language) -> Text<'static> {
|
||||
pub fn yes_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Yes",
|
||||
Language::IT => "Sì",
|
||||
|
|
@ -258,7 +260,7 @@ pub fn yes_translation(language: Language) -> Text<'static> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn ask_quit_translation(language: Language) -> Text<'static> {
|
||||
pub fn ask_quit_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Are you sure you want to quit this analysis?",
|
||||
Language::IT => "Sei sicuro di voler interrompere questa analisi?",
|
||||
|
|
@ -302,7 +304,7 @@ pub fn quit_analysis_translation(language: Language) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ask_clear_all_translation(language: Language) -> Text<'static> {
|
||||
pub fn ask_clear_all_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Are you sure you want to clear notifications?",
|
||||
Language::IT => "Sei sicuro di voler eliminare le notifiche?",
|
||||
|
|
@ -390,7 +392,10 @@ pub fn network_adapter_translation(language: Language) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn no_addresses_translation(language: Language, adapter: &str) -> Text<'static> {
|
||||
pub fn no_addresses_translation(
|
||||
language: Language,
|
||||
adapter: &str,
|
||||
) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => format!("No traffic can be observed because the adapter you selected has no active addresses...\n\n\
|
||||
Network adapter: {adapter}\n\n\
|
||||
|
|
@ -446,7 +451,10 @@ pub fn no_addresses_translation(language: Language, adapter: &str) -> Text<'stat
|
|||
})
|
||||
}
|
||||
|
||||
pub fn waiting_translation(language: Language, adapter: &str) -> Text<'static> {
|
||||
pub fn waiting_translation(
|
||||
language: Language,
|
||||
adapter: &str,
|
||||
) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => format!("No traffic has been observed yet. Waiting for network packets...\n\n\
|
||||
Network adapter: {adapter}\n\n\
|
||||
|
|
@ -502,7 +510,10 @@ pub fn waiting_translation(language: Language, adapter: &str) -> Text<'static> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn some_observed_translation(language: Language, observed: u128) -> Text<'static> {
|
||||
pub fn some_observed_translation(
|
||||
language: Language,
|
||||
observed: u128,
|
||||
) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => format!("Total intercepted packets: {observed}\n\n\
|
||||
Filtered packets: 0\n\n\
|
||||
|
|
@ -637,7 +648,7 @@ pub fn of_total_translation(language: Language, percentage: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
// pub fn filtered_application_translation(language: Language) -> Text<'static> {
|
||||
// pub fn filtered_application_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
// Text::new(match language {
|
||||
// Language::EN => "Filtered packets per application protocol:",
|
||||
// Language::IT => "Pacchetti filtrati per protocollo applicativo:",
|
||||
|
|
@ -658,7 +669,7 @@ pub fn of_total_translation(language: Language, percentage: &str) -> String {
|
|||
// })
|
||||
// }
|
||||
|
||||
// pub fn no_favorites_translation(language: Language) -> Text<'static> {
|
||||
// pub fn no_favorites_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
// Text::new(match language {
|
||||
// Language::EN => "Nothing to show at the moment.\n\
|
||||
// To add a connection to your favorites, click on the star symbol near the connection.",
|
||||
|
|
@ -695,7 +706,7 @@ pub fn of_total_translation(language: Language, percentage: &str) -> String {
|
|||
// })
|
||||
// }
|
||||
|
||||
pub fn error_translation(language: Language, error: &str) -> Text<'static> {
|
||||
pub fn error_translation(language: Language, error: &str) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => format!(
|
||||
"An error occurred! \n\n\
|
||||
|
|
@ -993,7 +1004,7 @@ pub fn bytes_report_translation(language: Language) -> &'static str {
|
|||
// }
|
||||
// }
|
||||
|
||||
pub fn notifications_title_translation(language: Language) -> Text<'static> {
|
||||
pub fn notifications_title_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Customize your notifications",
|
||||
Language::IT => "Personalizza le tue notifiche",
|
||||
|
|
@ -1015,7 +1026,7 @@ pub fn notifications_title_translation(language: Language) -> Text<'static> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn appearance_title_translation(language: Language) -> Text<'static> {
|
||||
pub fn appearance_title_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Choose your favorite theme",
|
||||
Language::IT => "Scegli il tuo tema preferito",
|
||||
|
|
@ -1037,7 +1048,7 @@ pub fn appearance_title_translation(language: Language) -> Text<'static> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn languages_title_translation(language: Language) -> Text<'static> {
|
||||
pub fn languages_title_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "Select your language",
|
||||
Language::IT => "Seleziona la lingua",
|
||||
|
|
@ -1642,7 +1653,7 @@ pub fn favorite_transmitted_translation(language: Language) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn no_notifications_set_translation(language: Language) -> Text<'static> {
|
||||
pub fn no_notifications_set_translation(language: Language) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => "You haven't enabled notifications yet!\n\n\
|
||||
After enabling them, this page will display a log of your notifications\n\n\
|
||||
|
|
@ -1698,7 +1709,9 @@ pub fn no_notifications_set_translation(language: Language) -> Text<'static> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn no_notifications_received_translation(language: Language) -> Text<'static> {
|
||||
pub fn no_notifications_received_translation(
|
||||
language: Language,
|
||||
) -> Text<'static, Renderer<StyleType>> {
|
||||
Text::new(match language {
|
||||
Language::EN => {
|
||||
"Nothing to see at the moment...\n\n\
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::net::IpAddr;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use iced::widget::{Column, Text};
|
||||
use iced::Color;
|
||||
use iced::{Color, Renderer};
|
||||
|
||||
use crate::gui::styles::style_constants::get_font;
|
||||
use crate::gui::styles::text::{TextStyleTuple, TextType};
|
||||
|
|
@ -35,13 +35,13 @@ pub fn get_active_filters_col(
|
|||
filters: &Filters,
|
||||
language: Language,
|
||||
style: StyleType,
|
||||
) -> Column<'static, Message> {
|
||||
) -> Column<'static, Message, Renderer<StyleType>> {
|
||||
let font = get_font(style);
|
||||
|
||||
let mut ret_val = Column::new().push(
|
||||
Text::new(format!("{}:", active_filters_translation(language),))
|
||||
.font(font)
|
||||
.style(TextStyleTuple(style, TextType::Subtitle)),
|
||||
.style(TextType::Subtitle),
|
||||
);
|
||||
if filters.ip.eq(&IpVersion::Other)
|
||||
&& filters.application.eq(&AppProtocol::Other)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue