@@ -8,10 +8,7 @@ use std::borrow::Cow;
8
8
/// A section within a settings view column.
9
9
#[ deprecated( note = "use `settings::section().title()` instead" ) ]
10
10
pub 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)
15
12
}
16
13
17
14
/// A section within a settings view column.
@@ -22,21 +19,26 @@ pub fn section<'a, Message: 'static>() -> Section<'a, Message> {
22
19
/// A section with a pre-defined list column.
23
20
pub fn with_column < Message : ' static > ( children : ListColumn < ' _ , Message > ) -> Section < ' _ , Message > {
24
21
Section {
25
- title : Cow :: Borrowed ( "" ) ,
22
+ header : None ,
26
23
children,
27
24
}
28
25
}
29
26
30
27
#[ must_use]
31
28
pub struct Section < ' a , Message > {
32
- title : Cow < ' a , str > ,
29
+ header : Option < Element < ' a , Message > > ,
33
30
children : ListColumn < ' a , Message > ,
34
31
}
35
32
36
33
impl < ' a , Message : ' static > Section < ' a , Message > {
37
34
/// Define an optional title for the section.
38
35
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 ( ) ) ;
40
42
self
41
43
}
42
44
@@ -69,11 +71,7 @@ impl<'a, Message: 'static> From<Section<'a, Message>> for Element<'a, Message> {
69
71
fn from ( data : Section < ' a , Message > ) -> Self {
70
72
column:: with_capacity ( 2 )
71
73
. 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 )
77
75
. push ( data. children )
78
76
. into ( )
79
77
}
0 commit comments