From d0e7be2bfa86add8de680f42a090f468b980c621 Mon Sep 17 00:00:00 2001 From: GyulyVGC Date: Sat, 14 Mar 2026 18:31:59 +0100 Subject: [PATCH] fix notifications page item bars alignment --- src/countries/country_utils.rs | 4 +-- src/gui/pages/notifications_page.rs | 56 ++++++++--------------------- src/gui/pages/overview_page.rs | 2 +- src/gui/types/favorite.rs | 28 +++++++++------ 4 files changed, 35 insertions(+), 55 deletions(-) diff --git a/src/countries/country_utils.rs b/src/countries/country_utils.rs index 81b8a2dc..8b0f051a 100644 --- a/src/countries/country_utils.rs +++ b/src/countries/country_utils.rs @@ -317,7 +317,7 @@ pub fn get_flag_tooltip<'a>( language: Language, thumbnail: bool, ) -> Tooltip<'a, Message, StyleType> { - let width = if thumbnail { + let size = if thumbnail { ICONS_SIZE_SMALL } else { ICONS_SIZE_BIG @@ -328,7 +328,7 @@ pub fn get_flag_tooltip<'a>( let traffic_type = host_info.traffic_type; let (content, tooltip) = get_flag_from_country( country, - width, + size, is_local, is_loopback, is_bogon, diff --git a/src/gui/pages/notifications_page.rs b/src/gui/pages/notifications_page.rs index 2d49651e..50cda140 100644 --- a/src/gui/pages/notifications_page.rs +++ b/src/gui/pages/notifications_page.rs @@ -1,9 +1,9 @@ -use crate::countries::country_utils::{get_computer_tooltip, get_flag_tooltip}; +use crate::countries::country_utils::get_flag_tooltip; use crate::countries::flags_pictures::ICONS_SIZE_BIG; use crate::gui::components::header::get_button_settings; use crate::gui::components::tab::get_pages_tabs; use crate::gui::components::types::my_modal::MyModal; -use crate::gui::pages::overview_page::{get_bars, item_bar}; +use crate::gui::pages::overview_page::item_bar; use crate::gui::pages::types::settings_page::SettingsPage; use crate::gui::styles::container::ContainerType; use crate::gui::styles::rule::RuleType; @@ -18,7 +18,6 @@ use crate::networking::types::data_representation::DataRepr; use crate::networking::types::host::Host; use crate::networking::types::program_lookup::ProgramLookup; use crate::networking::types::service::Service; -use crate::networking::types::traffic_type::TrafficType; use crate::notifications::types::logged_notification::{ BlacklistedTransmitted, DataThresholdExceeded, FavoriteTransmitted, LoggedNotification, }; @@ -135,7 +134,16 @@ fn data_notification_log<'a>( first_entry_data_info: DataInfo, language: Language, ) -> Container<'a, Message, StyleType> { + let data_info = logged_notification.data_info; let data_repr = logged_notification.data_repr; + let threshold_bar = item_bar( + Space::new().width(ICONS_SIZE_BIG), + String::new(), + &data_info, + data_repr, + first_entry_data_info, + ); + let data_string = data_repr.formatted_string(logged_notification.threshold.into()); let icon = if data_repr == DataRepr::Packets { Icon::PacketsThreshold @@ -174,11 +182,7 @@ fn data_notification_log<'a>( .size(FONT_SIZE_FOOTER), ), ) - .push(threshold_bar( - logged_notification, - first_entry_data_info, - language, - )); + .push(threshold_bar); let content_and_extra = Column::new() .spacing(10) .push(content) @@ -201,7 +205,7 @@ fn favorite_notification_log<'a>( program_lookup: Option<&'a ProgramLookup>, ) -> Container<'a, Message, StyleType> { let favorite = &logged_notification.favorite; - let icon = favorite.icon(language, false, program_lookup); + let icon = favorite.icon(language, program_lookup, true); let item_bar = item_bar( icon, favorite.to_entry_string(), @@ -353,38 +357,6 @@ fn logged_notifications(sniffer: &Sniffer) -> Column<'_, Message, StyleType> { ret_val } -fn threshold_bar<'a>( - logged_notification: &DataThresholdExceeded, - first_entry_data_info: DataInfo, - language: Language, -) -> Row<'a, Message, StyleType> { - let data_repr = logged_notification.data_repr; - let data_info = logged_notification.data_info; - - Row::new() - .align_y(Alignment::Center) - .spacing(5) - .push(get_computer_tooltip( - true, - true, - None, - TrafficType::Unicast, - language, - )) - .push( - Column::new() - .spacing(1) - .push( - Row::new() - .push(Space::new().width(Length::Fill)) - .push(Text::new( - data_repr.formatted_string(data_info.tot_data(data_repr)), - )), - ) - .push(get_bars(data_repr, &first_entry_data_info, &data_info)), - ) -} - fn button_expand<'a>( notification_id: usize, is_expanded: bool, @@ -406,7 +378,7 @@ fn button_expand<'a>( .on_press(Message::ExpandNotification(notification_id, !is_expanded)); Container::new(button) - .padding(Padding::ZERO.left(395)) + .padding(Padding::ZERO.left(427)) .align_y(Alignment::Center) } diff --git a/src/gui/pages/overview_page.rs b/src/gui/pages/overview_page.rs index e7780741..bd6f1cbd 100644 --- a/src/gui/pages/overview_page.rs +++ b/src/gui/pages/overview_page.rs @@ -114,7 +114,7 @@ fn col_favorite_item( for fi in &entries { let star_button = fi.star_button(); - let icon = fi.icon(language, false, program_lookup); + let icon = fi.icon(language, program_lookup, false); let item_bar = item_bar( icon, fi.to_entry_string(), diff --git a/src/gui/types/favorite.rs b/src/gui/types/favorite.rs index cb1fe124..04a6d2e9 100644 --- a/src/gui/types/favorite.rs +++ b/src/gui/types/favorite.rs @@ -1,4 +1,5 @@ use crate::countries::country_utils::get_flag_tooltip; +use crate::countries::flags_pictures::ICONS_SIZE_BIG; use crate::gui::sniffer::Sniffer; use crate::gui::styles::button::ButtonType; use crate::gui::styles::types::style_type::StyleType; @@ -20,7 +21,7 @@ use crate::translations::translations_3::service_translation; use crate::translations::translations_5::program_translation; use crate::translations::types::language::Language; use crate::utils::types::icon::Icon; -use iced::widget::{Button, Container, Tooltip, button}; +use iced::widget::{Button, Container, Space, button}; use iced::{Alignment, Element}; use std::cmp::min; @@ -144,20 +145,27 @@ impl FavoriteItem { pub fn icon<'a>( &self, language: Language, - thumbnail: bool, program_lookup: Option<&'a ProgramLookup>, + fill_empty: bool, ) -> impl Into> { match self { - FavoriteItem::Host((host, data_info_host)) => Some(get_flag_tooltip( - host.country, - data_info_host, - language, - thumbnail, - )), - FavoriteItem::Service(_) => None::>, + FavoriteItem::Host((host, data_info_host)) => { + Some(get_flag_tooltip(host.country, data_info_host, language, false).into()) + } + FavoriteItem::Service(_) => { + if fill_empty { + Some(Space::new().width(ICONS_SIZE_BIG).into()) + } else { + None::> + } + } FavoriteItem::Program((program, _)) => { let program_lookup = program_lookup?; - Some(program_lookup.picon_tooltip(program.icon_key(), program.path())) + Some( + program_lookup + .picon_tooltip(program.icon_key(), program.path()) + .into(), + ) } } }