refactor Navigation
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.imyeyu.fx.ui.examples.view.pages.component;
|
||||
|
||||
import com.imyeyu.fx.ui.TimiFXUI;
|
||||
import com.imyeyu.fx.ui.components.Navigation;
|
||||
import com.imyeyu.fx.ui.components.navigation.Navigation;
|
||||
import com.imyeyu.fx.ui.components.navigation.NavigationGroup;
|
||||
import com.imyeyu.fx.ui.components.navigation.NavigationItem;
|
||||
import com.imyeyu.fx.ui.examples.component.AbstractDemoPane;
|
||||
import com.imyeyu.fx.ui.examples.component.sidebar.SidebarItem;
|
||||
import com.imyeyu.fx.utils.Column;
|
||||
@@ -10,7 +12,6 @@ import com.imyeyu.inject.annotation.Component;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
/**
|
||||
@@ -32,40 +33,55 @@ public class NavigationDemo extends AbstractDemoPane {
|
||||
Label labelCommonly = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("commonly"));
|
||||
labelCommonly.setAlignment(Pos.CENTER);
|
||||
Navigation commonly = new Navigation();
|
||||
commonly.add(new ToggleButton("item 0"));
|
||||
commonly.add(new ToggleButton("item 1"));
|
||||
commonly.add(new ToggleButton("item 2"));
|
||||
commonly.setPrefWidth(240);
|
||||
commonly.add(new NavigationItem("item 0"));
|
||||
commonly.add(new NavigationItem("item 1"));
|
||||
commonly.add(new NavigationItem("item 2"));
|
||||
|
||||
// 二级
|
||||
Label labelSecond = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"));
|
||||
labelSecond.setAlignment(Pos.CENTER);
|
||||
Navigation second = new Navigation();
|
||||
second.add(new ToggleButton("item 0"));
|
||||
second.add(new ToggleButton("item 1"));
|
||||
second.add(new ToggleButton("item 2"));
|
||||
second.addGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"), new ToggleButton("item 0"), new ToggleButton("item 1"));
|
||||
second.add(new NavigationItem("item 0"));
|
||||
second.add(new NavigationItem("item 1"));
|
||||
second.add(new NavigationItem("item 2"));
|
||||
second.add(new NavigationGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"))
|
||||
.add(new NavigationItem("item 0"), new NavigationItem("item 1")));
|
||||
|
||||
// 默认展开
|
||||
Label labelExpanded = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.expanded"));
|
||||
labelExpanded.setAlignment(Pos.CENTER);
|
||||
Navigation expanded = new Navigation();
|
||||
expanded.add(new ToggleButton("item 0"));
|
||||
expanded.add(new ToggleButton("item 1"));
|
||||
expanded.add(new ToggleButton("item 2"));
|
||||
expanded.addExpandedGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"), new ToggleButton("item 0"), new ToggleButton("item 1"));
|
||||
expanded.add(new NavigationItem("item 0"));
|
||||
expanded.add(new NavigationItem("item 1"));
|
||||
expanded.add(new NavigationItem("item 2"));
|
||||
expanded.add(new NavigationGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"))
|
||||
.expanded(true)
|
||||
.add(new NavigationItem("item 0"), new NavigationItem("item 1")));
|
||||
|
||||
// 多个二级
|
||||
// 三级
|
||||
Label labelMulti = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.multi"));
|
||||
labelMulti.setAlignment(Pos.CENTER);
|
||||
Navigation multi = new Navigation();
|
||||
multi.add(new ToggleButton("item 0"));
|
||||
multi.add(new ToggleButton("item 1"));
|
||||
multi.add(new ToggleButton("item 2"));
|
||||
multi.addExpandedGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"), new ToggleButton("item 0"), new ToggleButton("item 1"));
|
||||
multi.addExpandedGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"), new ToggleButton("item 0"), new ToggleButton("item 1"));
|
||||
multi.add(new NavigationItem("item 0"));
|
||||
multi.add(new NavigationItem("item 1"));
|
||||
multi.add(new NavigationItem("item 2"));
|
||||
multi.add(
|
||||
new NavigationGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"))
|
||||
.expanded(true)
|
||||
.add(
|
||||
new NavigationItem("item 0"),
|
||||
new NavigationGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.multi"))
|
||||
.expanded(true)
|
||||
.add(new NavigationItem("item 0"), new NavigationItem("item 1"))
|
||||
),
|
||||
new NavigationGroup(TimiFXUI.MULTILINGUAL.text("fx.example.navigation.second"))
|
||||
.expanded(true)
|
||||
.add(new NavigationItem("item 0"), new NavigationItem("item 1"))
|
||||
);
|
||||
|
||||
setCenter(new GridPane() {{
|
||||
Column col = Column.build().width(120);
|
||||
Column col = Column.build().width(220);
|
||||
getColumnConstraints().addAll(col, col, col, col);
|
||||
getRowConstraints().addAll(Row.build(), Row.build().alwaysPriority());
|
||||
setVgap(5);
|
||||
|
||||
Reference in New Issue
Block a user