@@ -8,10 +8,7 @@ use std::borrow::Cow;
88/// A section within a settings view column.
99#[ deprecated( note = "use `settings::section().title()` instead" ) ]
1010pub fn view_section < ' a , Message : ' static > ( title : impl Into < Cow < ' a , str > > ) -> Section < ' a , Message > {
11- Section {
12- title : title. into ( ) ,
13- children : ListColumn :: default ( ) ,
14- }
11+ section ( ) . title ( title)
1512}
1613
1714/// A section within a settings view column.
@@ -22,21 +19,26 @@ pub fn section<'a, Message: 'static>() -> Section<'a, Message> {
2219/// A section with a pre-defined list column.
2320pub fn with_column < Message : ' static > ( children : ListColumn < ' _ , Message > ) -> Section < ' _ , Message > {
2421 Section {
25- title : Cow :: Borrowed ( "" ) ,
22+ header : None ,
2623 children,
2724 }
2825}
2926
3027#[ must_use]
3128pub struct Section < ' a , Message > {
32- title : Cow < ' a , str > ,
29+ header : Option < Element < ' a , Message > > ,
3330 children : ListColumn < ' a , Message > ,
3431}
3532
3633impl < ' a , Message : ' static > Section < ' a , Message > {
3734 /// Define an optional title for the section.
3835 pub fn title ( mut self , title : impl Into < Cow < ' a , str > > ) -> Self {
39- self . title = title. into ( ) ;
36+ self . header ( text:: heading ( title. into ( ) ) )
37+ }
38+
39+ /// Define an optional custom header for the section.
40+ pub fn header ( mut self , header : impl Into < Element < ' a , Message > > ) -> Self {
41+ self . header = Some ( header. into ( ) ) ;
4042 self
4143 }
4244
@@ -69,11 +71,7 @@ impl<'a, Message: 'static> From<Section<'a, Message>> for Element<'a, Message> {
6971 fn from ( data : Section < ' a , Message > ) -> Self {
7072 column:: with_capacity ( 2 )
7173 . spacing ( 8 )
72- . push_maybe ( if data. title . is_empty ( ) {
73- None
74- } else {
75- Some ( text:: heading ( data. title ) )
76- } )
74+ . push_maybe ( data. header )
7775 . push ( data. children )
7876 . into ( )
7977 }
0 commit comments