22
33import com .flowingcode .vaadin .addons .DemoLayout ;
44import com .vaadin .flow .component .checkbox .Checkbox ;
5+ import com .vaadin .flow .component .dependency .StyleSheet ;
56import com .vaadin .flow .component .html .IFrame ;
7+ import com .vaadin .flow .component .orderedlayout .HorizontalLayout ;
68import com .vaadin .flow .component .orderedlayout .VerticalLayout ;
79import com .vaadin .flow .component .splitlayout .SplitLayout ;
810import com .vaadin .flow .component .splitlayout .SplitLayout .Orientation ;
1113import com .vaadin .flow .router .Route ;
1214
1315@ SuppressWarnings ("serial" )
16+ @ StyleSheet ("context://frontend/styles/demo-styles.css" )
1417@ Route (value = "chipfield" , layout = DemoLayout .class )
1518public class ChipfieldDemoView extends VerticalLayout {
1619
@@ -34,24 +37,45 @@ public ChipfieldDemoView() {
3437 iframe .setSizeFull ();
3538 layout .addToSecondary (iframe );
3639
40+ Tabs tabs = new Tabs ();
41+ Tab demo1 = new Tab (DATAPROVIDER_DEMO );
42+ Tab demo2 = new Tab (RESTRICTED_DEMO );
43+ Tab demo3 = new Tab (DISABLED_DEMO );
44+ Tab demo4 = new Tab (BINDER_DEMO );
45+ tabs .setWidthFull ();
46+ tabs .add (demo1 , demo2 , demo3 , demo4 );
47+
48+ Checkbox orientationCB = new Checkbox ("Toggle Orientation" );
49+ orientationCB .setValue (true );
50+ orientationCB .addClassName ("smallcheckbox" );
51+ orientationCB .addValueChangeListener (cb -> {
52+ if (cb .getValue ()) {
53+ layout .setOrientation (Orientation .HORIZONTAL );
54+ } else {
55+ layout .setOrientation (Orientation .VERTICAL );
56+ }
57+ layout .setSplitterPosition (50 );
58+ layout .getPrimaryComponent ().getElement ().setAttribute ("style" , "width: 100%; height: 100%" );
59+ iframe .setSizeFull ();
60+ });
3761 Checkbox codeCB = new Checkbox ("Show Source Code" );
3862 codeCB .setValue (true );
63+ codeCB .addClassName ("smallcheckbox" );
3964 codeCB .addValueChangeListener (cb -> {
4065 if (cb .getValue ()) {
4166 layout .setSplitterPosition (50 );
67+ orientationCB .setEnabled (true );
4268 } else {
4369 layout .setSplitterPosition (100 );
70+ orientationCB .setEnabled (false );
4471 }
4572 });
46- Tabs tabs = new Tabs ();
47- Tab demo1 = new Tab (DATAPROVIDER_DEMO );
48- Tab demo2 = new Tab (RESTRICTED_DEMO );
49- Tab demo3 = new Tab (DISABLED_DEMO );
50- Tab demo4 = new Tab (BINDER_DEMO );
51- tabs .setWidthFull ();
52- tabs .add (demo1 , demo2 , demo3 , demo4 , codeCB );
53- add (tabs , layout );
54-
73+ HorizontalLayout footer = new HorizontalLayout ();
74+ footer .setWidthFull ();
75+ footer .setJustifyContentMode (JustifyContentMode .END );
76+ footer .add (codeCB , orientationCB );
77+ add (tabs , layout , footer );
78+
5579 setSizeFull ();
5680
5781 tabs .addSelectedChangeListener (e -> {
@@ -61,28 +85,31 @@ public ChipfieldDemoView() {
6185 iframe .getElement ().setAttribute ("srcdoc" , getSrcdoc (DATAPROVIDER_SOURCE ));
6286 layout .addToPrimary (new DataProviderDemo ());
6387 layout .addToSecondary (iframe );
64- add (tabs , layout );
88+ add (tabs , layout , footer );
6589 break ;
6690 case RESTRICTED_DEMO :
6791 iframe .getElement ().setAttribute ("srcdoc" , getSrcdoc (RESTRICTED_SOURCE ));
6892 layout .addToPrimary (new RestrictedDemo ());
6993 layout .addToSecondary (iframe );
70- add (tabs , layout );
94+ add (tabs , layout , footer );
7195 break ;
7296 case DISABLED_DEMO :
7397 iframe .getElement ().setAttribute ("srcdoc" , getSrcdoc (DISABLED_SOURCE ));
7498 layout .addToPrimary (new DisabledDemo ());
7599 layout .addToSecondary (iframe );
76- add (tabs , layout );
100+ add (tabs , layout , footer );
77101 break ;
78102 case BINDER_DEMO :
79103 iframe .getElement ().setAttribute ("srcdoc" , getSrcdoc (BINDER_SOURCE ));
80104 layout .addToPrimary (new BinderDemo ());
81105 layout .addToSecondary (iframe );
82- add (tabs , layout );
106+ add (tabs , layout , footer );
83107 break ;
84108 default :
85- add (tabs , new DataProviderDemo ());
109+ iframe .getElement ().setAttribute ("srcdoc" , getSrcdoc (DATAPROVIDER_SOURCE ));
110+ layout .addToPrimary (new DataProviderDemo ());
111+ layout .addToSecondary (iframe );
112+ add (tabs , layout , footer );
86113 break ;
87114 }
88115 });
0 commit comments