@@ -7,19 +7,19 @@ use iced::widget::{Space, button, vertical_space};
77use iced:: { Alignment , Font , Length , Padding } ;
88
99use crate :: chart:: types:: chart_type:: ChartType ;
10- use crate :: countries:: country_utils :: get_computer_tooltip ;
10+ use crate :: countries:: flags_pictures :: FLAGS_WIDTH_BIG ;
1111use crate :: gui:: components:: header:: get_button_settings;
1212use crate :: gui:: components:: tab:: get_pages_tabs;
1313use crate :: gui:: components:: types:: my_modal:: MyModal ;
1414use crate :: gui:: pages:: overview_page:: { get_bars, get_bars_length, host_bar} ;
1515use crate :: gui:: pages:: types:: settings_page:: SettingsPage ;
16+ use crate :: gui:: styles:: button:: ButtonType ;
1617use crate :: gui:: styles:: container:: ContainerType ;
1718use crate :: gui:: styles:: scrollbar:: ScrollbarType ;
1819use crate :: gui:: styles:: style_constants:: FONT_SIZE_FOOTER ;
1920use crate :: gui:: styles:: text:: TextType ;
2021use crate :: gui:: types:: message:: Message ;
2122use crate :: networking:: types:: data_info:: DataInfo ;
22- use crate :: networking:: types:: traffic_type:: TrafficType ;
2323use crate :: notifications:: types:: logged_notification:: {
2424 DataThresholdExceeded , FavoriteTransmitted , LoggedNotification ,
2525} ;
@@ -61,11 +61,11 @@ pub fn notifications_page(sniffer: &Sniffer) -> Container<Message, StyleType> {
6161 if notifications. packets_notification . threshold . is_none ( )
6262 && notifications. bytes_notification . threshold . is_none ( )
6363 && !notifications. favorite_notification . notify_on_favorite
64- && sniffer. logged_notifications . is_empty ( )
64+ && sniffer. logged_notifications . 0 . is_empty ( )
6565 {
6666 let body = body_no_notifications_set ( font, language) ;
6767 tab_and_body = tab_and_body. push ( body) ;
68- } else if sniffer. logged_notifications . is_empty ( ) {
68+ } else if sniffer. logged_notifications . 0 . is_empty ( ) {
6969 let body = body_no_notifications_received ( font, language, & sniffer. dots_pulse . 0 ) ;
7070 tab_and_body = tab_and_body. push ( body) ;
7171 } else {
@@ -74,7 +74,7 @@ pub fn notifications_page(sniffer: &Sniffer) -> Container<Message, StyleType> {
7474 . spacing ( 10 )
7575 . padding ( Padding :: new ( 10.0 ) . bottom ( 0 ) )
7676 . push (
77- Container :: new ( if sniffer. logged_notifications . len ( ) < 30 {
77+ Container :: new ( if sniffer. logged_notifications . 0 . len ( ) < 30 {
7878 Text :: new ( "" )
7979 } else {
8080 Text :: new ( only_last_30_translation ( language) ) . font ( font)
@@ -168,7 +168,6 @@ fn data_notification_log<'a>(
168168 ) ;
169169 let content = Row :: new ( )
170170 . align_y ( Alignment :: Center )
171- . height ( Length :: Fill )
172171 . spacing ( 30 )
173172 . push ( icon)
174173 . push (
@@ -179,7 +178,7 @@ fn data_notification_log<'a>(
179178 Row :: new ( )
180179 . spacing ( 8 )
181180 . push ( Icon :: Clock . to_text ( ) )
182- . push ( Text :: new ( logged_notification. timestamp ) . font ( font) ) ,
181+ . push ( Text :: new ( logged_notification. timestamp . clone ( ) ) . font ( font) ) ,
183182 )
184183 . push (
185184 Text :: new ( if chart_type == ChartType :: Bytes {
@@ -198,16 +197,21 @@ fn data_notification_log<'a>(
198197 ) ,
199198 )
200199 . push ( threshold_bar (
201- logged_notification. data_info ,
200+ & logged_notification,
202201 chart_type,
203202 first_entry_data_info,
204203 font,
205- language,
206204 ) ) ;
207- Container :: new ( content)
208- . height ( 120 )
205+ let content_and_extra = Column :: new ( )
206+ . push ( content)
207+ . push ( if logged_notification. is_expanded {
208+ Row :: new ( ) . push ( get_button_clear_all ( font, language) )
209+ } else {
210+ Row :: new ( )
211+ } ) ;
212+ Container :: new ( content_and_extra)
209213 . width ( Length :: Fill )
210- . padding ( 10 )
214+ . padding ( 15 )
211215 . class ( ContainerType :: BorderedRound )
212216}
213217
@@ -230,7 +234,6 @@ fn favorite_notification_log<'a>(
230234 let content = Row :: new ( )
231235 . spacing ( 30 )
232236 . align_y ( Alignment :: Center )
233- . height ( Length :: Fill )
234237 . push (
235238 Icon :: Star
236239 . to_text ( )
@@ -257,9 +260,8 @@ fn favorite_notification_log<'a>(
257260 . push ( host_bar) ;
258261
259262 Container :: new ( content)
260- . height ( 120 )
261263 . width ( Length :: Fill )
262- . padding ( 10 )
264+ . padding ( 15 )
263265 . class ( ContainerType :: BorderedRound )
264266}
265267
@@ -298,12 +300,13 @@ fn logged_notifications<'a>(sniffer: &Sniffer) -> Column<'a, Message, StyleType>
298300
299301 let first_entry_data_info = sniffer
300302 . logged_notifications
303+ . 0
301304 . iter ( )
302305 . map ( LoggedNotification :: data_info)
303306 . max_by ( |d1, d2| d1. compare ( d2, SortType :: Ascending , chart_type) )
304307 . unwrap_or_default ( ) ;
305308
306- for logged_notification in & sniffer. logged_notifications {
309+ for logged_notification in & sniffer. logged_notifications . 0 {
307310 ret_val = ret_val. push ( match logged_notification {
308311 LoggedNotification :: DataThresholdExceeded ( data_threshold_exceeded) => {
309312 data_notification_log (
@@ -328,26 +331,22 @@ fn logged_notifications<'a>(sniffer: &Sniffer) -> Column<'a, Message, StyleType>
328331}
329332
330333fn threshold_bar < ' a > (
331- data_info : DataInfo ,
334+ logged_notification : & DataThresholdExceeded ,
332335 chart_type : ChartType ,
333336 first_entry_data_info : DataInfo ,
334337 font : Font ,
335- language : Language ,
336338) -> Row < ' a , Message , StyleType > {
339+ let data_info = logged_notification. data_info ;
340+ let id = logged_notification. id ;
341+ let is_expanded = logged_notification. is_expanded ;
342+
337343 let ( incoming_bar_len, outgoing_bar_len) =
338344 get_bars_length ( chart_type, & first_entry_data_info, & data_info) ;
339345
340346 Row :: new ( )
341347 . align_y ( Alignment :: Center )
342348 . spacing ( 5 )
343- . push ( get_computer_tooltip (
344- true ,
345- true ,
346- None ,
347- TrafficType :: Unicast ,
348- language,
349- font,
350- ) )
349+ . push ( button_expand ( id, is_expanded) )
351350 . push (
352351 Column :: new ( )
353352 . spacing ( 1 )
@@ -364,3 +363,28 @@ fn threshold_bar<'a>(
364363 . push ( get_bars ( incoming_bar_len, outgoing_bar_len) ) ,
365364 )
366365}
366+
367+ fn button_expand < ' a > (
368+ notification_id : usize ,
369+ is_expanded : bool ,
370+ ) -> Container < ' a , Message , StyleType > {
371+ let button = button (
372+ if is_expanded {
373+ Icon :: Collapse
374+ } else {
375+ Icon :: Expand
376+ }
377+ . to_text ( )
378+ . size ( 25 )
379+ . align_x ( Alignment :: Center )
380+ . align_y ( Alignment :: Center ) ,
381+ )
382+ . width ( FLAGS_WIDTH_BIG )
383+ . padding ( Padding :: ZERO )
384+ . class ( ButtonType :: SortArrows )
385+ . on_press ( Message :: ExpandNotification ( notification_id, !is_expanded) ) ;
386+
387+ Container :: new ( button)
388+ . align_x ( Alignment :: Center )
389+ . align_y ( Alignment :: Center )
390+ }
0 commit comments