@@ -47,6 +47,10 @@ pub enum Message {
4747 ToggleOverAmplificationSink ( bool ) ,
4848 /// Toggle amplification for sink
4949 ToggleOverAmplificationSource ( bool ) ,
50+ /// Toggle the mute status of notifications.
51+ ToggleNotificationMute ,
52+ /// Set the volume of notifications.
53+ SetNotificationVolume ( u32 ) ,
5054}
5155
5256impl From < Message > for crate :: pages:: Message {
@@ -116,6 +120,7 @@ impl page::Page<crate::pages::Message> for Page {
116120 sections : & mut SlotMap < section:: Entity , Section < crate :: pages:: Message > > ,
117121 ) -> Option < page:: Content > {
118122 Some ( vec ! [
123+ sections. insert( alerts( ) ) ,
119124 sections. insert( output( ) ) ,
120125 sections. insert( input( ) ) ,
121126 sections. insert( device_profiles( ) ) ,
@@ -199,6 +204,8 @@ impl Page {
199204
200205 Message :: ToggleSourceMute => self . model . toggle_source_mute ( ) ,
201206
207+ Message :: ToggleNotificationMute => self . model . toggle_notification_mute ( ) ,
208+
202209 Message :: SetSinkVolume ( volume) => {
203210 return self
204211 . model
@@ -213,6 +220,13 @@ impl Page {
213220 . map ( |message| Message :: Subscription ( message) . into ( ) ) ;
214221 }
215222
223+ Message :: SetNotificationVolume ( volume) => {
224+ return self
225+ . model
226+ . set_notification_volume ( volume)
227+ . map ( |message| Message :: Subscription ( message) . into ( ) ) ;
228+ }
229+
216230 Message :: ToggleOverAmplificationSink ( enabled) => {
217231 self . amplification_sink = enabled;
218232
@@ -459,21 +473,53 @@ fn device_profiles() -> Section<crate::pages::Message> {
459473 } )
460474}
461475
462- // fn alerts() -> Section<crate::pages::Message> {
463- // let mut descriptions = Slab::new();
464- // let volume = descriptions.insert(fl!("sound-alerts", "volume"));
465- // let sound = descriptions.insert(fl!("sound-alerts", "sound"));
476+ fn alerts ( ) -> Section < crate :: pages:: Message > {
477+ let mut descriptions = Slab :: new ( ) ;
478+ let volume = descriptions. insert ( fl ! ( "sound-alerts" , "volume" ) ) ;
479+ let sound = descriptions. insert ( fl ! ( "sound-alerts" , "sound" ) ) ;
466480
467- // Section::default()
468- // .title(fl!("sound-alerts"))
469- // .descriptions(descriptions)
470- // .view::<Page>(move |_binder, _page, section| {
471- // settings::section().title(§ion.title)
472- // .add(settings::item(§ion.descriptions[volume], text::body("TODO")))
473- // .add(settings::item(§ion.descriptions[sound], text::body("TODO")))
474- // .into()
475- // })
476- // }
481+ Section :: default ( )
482+ . title ( fl ! ( "sound-alerts" ) )
483+ . descriptions ( descriptions)
484+ . view :: < Page > ( move |_binder, page, section| {
485+ let slider = if page. amplification_sink {
486+ widget:: slider ( 0 ..=150 , page. model . notification_volume , |change| {
487+ Message :: SetNotificationVolume ( change) . into ( )
488+ } )
489+ . breakpoints ( & [ 100 ] )
490+ } else {
491+ widget:: slider ( 0 ..=100 , page. model . notification_volume , |change| {
492+ Message :: SetNotificationVolume ( change) . into ( )
493+ } )
494+ } ;
495+
496+ let volume_control = widget:: row:: with_capacity ( 4 )
497+ . align_y ( Alignment :: Center )
498+ . push (
499+ widget:: button:: icon ( if page. model . notification_mute {
500+ widget:: icon:: from_name ( "audio-volume-muted-symbolic" )
501+ } else {
502+ widget:: icon:: from_name ( "audio-volume-high-symbolic" )
503+ } )
504+ . on_press ( Message :: ToggleNotificationMute . into ( ) ) ,
505+ )
506+ . push (
507+ widget:: text:: body ( & page. model . notification_volume_text )
508+ . width ( Length :: Fixed ( 22.0 ) )
509+ . align_x ( Alignment :: Center ) ,
510+ )
511+ . push ( widget:: horizontal_space ( ) . width ( 8 ) )
512+ . push ( slider) ;
513+
514+ settings:: section ( )
515+ . title ( & section. title )
516+ . add ( settings:: flex_item (
517+ & * section. descriptions [ volume] ,
518+ volume_control,
519+ ) )
520+ . into ( )
521+ } )
522+ }
477523
478524// fn applications() -> Section<crate::pages::Message> {
479525// let mut descriptions = Slab::new();
0 commit comments