Make navigation settings callback explicit
This commit is contained in:
@@ -46,11 +46,6 @@ public final class NavigationRail extends VBox {
|
||||
private MainWindow.NavItem selectedItem;
|
||||
private String selectedPluginId;
|
||||
|
||||
public NavigationRail(List<MainWindow.NavItem> items,
|
||||
Consumer<MainWindow.NavItem> navigator) {
|
||||
this(items, navigator, () -> { });
|
||||
}
|
||||
|
||||
public NavigationRail(List<MainWindow.NavItem> items,
|
||||
Consumer<MainWindow.NavItem> navigator,
|
||||
Runnable openSettings) {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class NativeUiVisualAcceptanceFixtureContractTest {
|
||||
void fixtureRendersTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
||||
List<String> renderedLabels = fx(() -> {
|
||||
NavigationRail rail = new NavigationRail(
|
||||
NativeUiVisualAcceptanceFixture.navigationItems(() -> { }), item -> { });
|
||||
NativeUiVisualAcceptanceFixture.navigationItems(() -> { }), item -> { }, () -> { });
|
||||
VBox root = new VBox(rail);
|
||||
new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 480);
|
||||
root.applyCss();
|
||||
|
||||
@@ -100,7 +100,7 @@ class NavigationRailTest {
|
||||
AppIcon.DIFF, "文本对比", "对比文本", () -> {
|
||||
}, "diff");
|
||||
NavigationRail rail = new NavigationRail(List.of(API_DOC, second), item -> {
|
||||
});
|
||||
}, () -> { });
|
||||
VBox root = new VBox(rail);
|
||||
Scene scene = new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 320);
|
||||
Theme.applyCustomCss(scene);
|
||||
@@ -187,7 +187,7 @@ class NavigationRailTest {
|
||||
void bottomSeparatorIsExactlyOnePixelWithoutPaddingOrBackgroundBand() throws Exception {
|
||||
fx(() -> {
|
||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||
});
|
||||
}, () -> { });
|
||||
VBox root = new VBox(rail);
|
||||
Scene scene = new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 320);
|
||||
Theme.applyCustomCss(scene);
|
||||
@@ -289,7 +289,7 @@ class NavigationRailTest {
|
||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||
selected.set(item);
|
||||
routed.incrementAndGet();
|
||||
});
|
||||
}, () -> { });
|
||||
|
||||
rail.selectPlugin("api-doc");
|
||||
rail.setExpanded(false);
|
||||
@@ -307,7 +307,8 @@ class NavigationRailTest {
|
||||
void reselectingCurrentPluginKeepsItSelectedWithoutRoutingAgain() throws Exception {
|
||||
fx(() -> {
|
||||
AtomicInteger routed = new AtomicInteger();
|
||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> routed.incrementAndGet());
|
||||
NavigationRail rail = new NavigationRail(
|
||||
List.of(API_DOC), item -> routed.incrementAndGet(), () -> { });
|
||||
ToggleButton apiDocButton = (ToggleButton) rail.lookup("#nav-api-doc");
|
||||
|
||||
apiDocButton.fire();
|
||||
@@ -329,7 +330,8 @@ class NavigationRailTest {
|
||||
AppIcon.SCANNER, "Second", "Second item", () -> {
|
||||
});
|
||||
List<MainWindow.NavItem> routed = new ArrayList<>();
|
||||
NavigationRail rail = new NavigationRail(List.of(first, second), routed::add);
|
||||
NavigationRail rail = new NavigationRail(
|
||||
List.of(first, second), routed::add, () -> { });
|
||||
|
||||
rail.setExpanded(false);
|
||||
ToggleButton firstButton = (ToggleButton) rail.lookup("#nav-item-0");
|
||||
@@ -357,7 +359,7 @@ class NavigationRailTest {
|
||||
AppIcon.APP, "No ID", "No ID item", () -> {
|
||||
});
|
||||
NavigationRail rail = new NavigationRail(List.of(withoutId, API_DOC),
|
||||
item -> routed.incrementAndGet());
|
||||
item -> routed.incrementAndGet(), () -> { });
|
||||
|
||||
rail.selectPlugin(null);
|
||||
rail.selectPlugin("unknown-plugin");
|
||||
@@ -377,7 +379,8 @@ class NavigationRailTest {
|
||||
MainWindow.NavItem second = new MainWindow.NavItem(
|
||||
AppIcon.SCANNER, "Second", "Second item", () -> {
|
||||
}, "second");
|
||||
NavigationRail rail = new NavigationRail(List.of(first), item -> routed.incrementAndGet());
|
||||
NavigationRail rail = new NavigationRail(
|
||||
List.of(first), item -> routed.incrementAndGet(), () -> { });
|
||||
ToggleButton oldButton = (ToggleButton) rail.lookup("#nav-first");
|
||||
oldButton.fire();
|
||||
|
||||
@@ -508,7 +511,7 @@ class NavigationRailTest {
|
||||
void collapsedRailUsesExactFixedWidthAndCollapsedPseudoClass() throws Exception {
|
||||
fx(() -> {
|
||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||
});
|
||||
}, () -> { });
|
||||
|
||||
assertEquals(DesignTokens.NAV_EXPANDED_WIDTH, rail.getMinWidth());
|
||||
assertEquals(DesignTokens.NAV_EXPANDED_WIDTH, rail.getPrefWidth());
|
||||
@@ -526,7 +529,7 @@ class NavigationRailTest {
|
||||
void collapsedItemKeepsARealTooltipWithItsVisibleLabel() throws Exception {
|
||||
fx(() -> {
|
||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||
});
|
||||
}, () -> { });
|
||||
|
||||
rail.setExpanded(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user