@@ -7,26 +7,42 @@ use crate::Element;
77use std:: borrow:: Cow ;
88
99/// A section within a settings view column.
10- #[ must_use]
1110pub fn view_section < ' a , Message : ' static > ( title : impl Into < Cow < ' a , str > > ) -> Section < ' a , Message > {
1211 Section {
1312 title : title. into ( ) ,
1413 children : ListColumn :: default ( ) ,
1514 }
1615}
1716
17+ /// A section with a pre-defined list column.
18+ pub fn with_column < ' a , Message : ' static > (
19+ children : ListColumn < ' a , Message > ,
20+ ) -> Section < ' a , Message > {
21+ Section {
22+ title : Cow :: Borrowed ( "" ) ,
23+ children,
24+ }
25+ }
26+
27+ #[ must_use]
1828pub struct Section < ' a , Message > {
1929 title : Cow < ' a , str > ,
2030 children : ListColumn < ' a , Message > ,
2131}
2232
2333impl < ' a , Message : ' static > Section < ' a , Message > {
24- # [ must_use ]
34+ /// Add a child element to the section's list column.
2535 #[ allow( clippy:: should_implement_trait) ]
2636 pub fn add ( mut self , item : impl Into < Element < ' a , Message > > ) -> Self {
2737 self . children = self . children . add ( item. into ( ) ) ;
2838 self
2939 }
40+
41+ /// Define an optional title for the section.
42+ pub fn title ( mut self , title : impl Into < Cow < ' a , str > > ) -> Self {
43+ self . title = title. into ( ) ;
44+ self
45+ }
3046}
3147
3248impl < ' a , Message : ' static > From < Section < ' a , Message > > for Element < ' a , Message > {
0 commit comments