@@ -35,6 +35,7 @@ impl View for LayoutView {
3535
3636 f. render_widget ( Block :: default ( ) . style ( app. theme ( ) . background ) , area) ;
3737 f. render_widget ( status_widget ( app) , rows[ 0 ] ) ;
38+ f. render_widget ( notification_widget ( app) , rows[ 0 ] ) ;
3839
3940 match app. view_current {
4041 SelectedView :: Listen => ListenView :: draw ( app, f, rows[ 1 ] ) ,
@@ -44,14 +45,34 @@ impl View for LayoutView {
4445 }
4546}
4647
48+ fn notification_widget ( app : & App ) -> Paragraph < ' _ > {
49+ Paragraph :: new ( vec ! [ Line :: from( Span :: styled(
50+ match app. notification. is_visible( ) {
51+ true => format!(
52+ "{} {}" ,
53+ app. notification. message. clone( ) ,
54+ app. notification. countdown_char( )
55+ ) ,
56+ false => "" . to_string( ) ,
57+ } ,
58+ match app. notification. level {
59+ NotificationLevel :: Error => app. theme( ) . notification_error,
60+ NotificationLevel :: Warning => app. theme( ) . notification_warning,
61+ NotificationLevel :: Info => app. theme( ) . notification_info,
62+ NotificationLevel :: None => Style :: default ( ) ,
63+ } ,
64+ ) )
65+ . alignment( ratatui:: layout:: Alignment :: Right ) ] )
66+ }
67+
4768fn status_widget ( app : & App ) -> Paragraph {
4869 Paragraph :: new ( vec ! [ Line :: from( vec![
4970 Span :: styled(
5071 format!(
5172 " {} " ,
5273 match app. listening_status {
5374 ListenStatus :: Connected => "connected" . to_string( ) ,
54-
75+
5576 ListenStatus :: Listening => app. config. listen. to_string( ) ,
5677 ListenStatus :: Refusing => "refusing" . to_string( ) ,
5778 } ,
@@ -76,39 +97,25 @@ fn status_widget(app: &App) -> Paragraph {
7697 true => format!( " {} / ∞" , app. history. offset + 1 ) ,
7798 false => " 0 / 0" . to_string( ) ,
7899 } ,
79- SessionViewMode :: History => {
80- match app. listening_status {
81- ListenStatus :: Connected => format!(
82- " {} / {} history [p] to go back [n] to go forwards [b] to return" ,
83- app. history. offset + 1 ,
84- app. history. len( )
85- ) ,
86- ListenStatus :: Refusing => format!(
87- " {} / {} terminated [p] to go back [n] to go forwards [b] to listen" ,
88- app. history. offset + 1 ,
89- app. history. len( )
90- ) ,
91- ListenStatus :: Listening => String :: new( ) ,
92- }
93- }
100+ SessionViewMode :: History => match app. listening_status {
101+ ListenStatus :: Connected => format!(
102+ " {} / {} history [p] to go back [n] to go forwards [b] to return" ,
103+ app. history. offset + 1 ,
104+ app. history. len( )
105+ ) ,
106+ ListenStatus :: Refusing => format!(
107+ " {} / {} terminated [p] to go back [n] to go forwards [b] to listen" ,
108+ app. history. offset + 1 ,
109+ app. history. len( )
110+ ) ,
111+ ListenStatus :: Listening => String :: new( ) ,
112+ } ,
94113 } )
95114 . to_string( ) ,
96115 match app. session_view. mode {
97116 SessionViewMode :: Current => app. theme( ) . widget_mode_debug,
98117 SessionViewMode :: History => app. theme( ) . widget_mode_history,
99118 } ,
100119 ) ,
101- Span :: styled(
102- match app. notification. is_visible( ) {
103- true => format!( " {} " , app. notification. message. clone( ) ) ,
104- false => "" . to_string( ) ,
105- } ,
106- match app. notification. level {
107- NotificationLevel :: Error => app. theme( ) . notification_error,
108- NotificationLevel :: Warning => app. theme( ) . notification_warning,
109- NotificationLevel :: Info => app. theme( ) . notification_info,
110- NotificationLevel :: None => Style :: default ( ) ,
111- } ,
112- ) ,
113120 ] ) ] )
114121}
0 commit comments