Skip to content

Commit

Permalink
TabNavigator: showTabBar style; PageNavigator: showPageIndicator style
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Aug 9, 2024
1 parent 6309a67 commit 6d56f24
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/feathers/controls/navigators/PageNavigator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ class PageNavigator extends BaseNavigator implements IIndexSelector implements I
return this._pageIndicatorFactory;
}

/**
Shows or hides the page indicator. If the page indicator is hidden, the
selection may only be changed programatically, or with a user swipe
gesture, if `swipeEnabled` is `true`.
@since 1.4.0
**/
@:style
public var showPageIndicator:Bool = true;

private var _ignoreSelectionChange = false;

private var _dragTransitionContext:EventToPositionEffectContext;
Expand Down Expand Up @@ -401,6 +411,7 @@ class PageNavigator extends BaseNavigator implements IIndexSelector implements I
override private function update():Void {
var dataInvalid = this.isInvalid(DATA);
var selectionInvalid = this.isInvalid(SELECTION);
var stylesInvalid = this.isInvalid(STYLES);
if (this._previousCustomPageIndicatorVariant != this.customPageIndicatorVariant) {
this.setInvalidationFlag(INVALIDATION_FLAG_PAGE_INDICATOR_FACTORY);
}
Expand All @@ -410,6 +421,10 @@ class PageNavigator extends BaseNavigator implements IIndexSelector implements I
this.createPageIndicator();
}

if (pageIndicatorInvalid || stylesInvalid) {
this.refreshPageIndicator();
}

if (dataInvalid) {
this._previousEdgePuller.simulateTouch = this._simulateTouch;
this._nextEdgePuller.simulateTouch = this._simulateTouch;
Expand All @@ -425,6 +440,9 @@ class PageNavigator extends BaseNavigator implements IIndexSelector implements I
}

override private function measure():Bool {
if (!this.showPageIndicator) {
return super.measure();
}
if (this.explicitWidth != null) {
this.pageIndicator.width = this.explicitWidth;
} else if (this._autoSizeMode == STAGE && this.stage != null) {
Expand Down Expand Up @@ -471,6 +489,10 @@ class PageNavigator extends BaseNavigator implements IIndexSelector implements I
this.pageIndicator = null;
}

private function refreshPageIndicator():Void {
this.pageIndicator.visible = this.showPageIndicator;
}

override private function layoutContent():Void {
this.pageIndicator.x = 0.0;
this.pageIndicator.width = this.actualWidth;
Expand Down
22 changes: 22 additions & 0 deletions src/feathers/controls/navigators/TabNavigator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ class TabNavigator extends BaseNavigator implements IIndexSelector implements ID
return this._tabBarFactory;
}

/**
Shows or hides the tab bar. If the tab bar is hidden, the selection
may only be changed programatically, or with a user swipe gesture, if
`swipeEnabled` is `true`.
@since 1.4.0
**/
@:style
public var showTabBar:Bool = true;

private var _ignoreSelectionChange = false;

override public function dispose():Void {
Expand Down Expand Up @@ -405,6 +415,7 @@ class TabNavigator extends BaseNavigator implements IIndexSelector implements ID
override private function update():Void {
var dataInvalid = this.isInvalid(DATA);
var selectionInvalid = this.isInvalid(SELECTION);
var stylesInvalid = this.isInvalid(STYLES);
if (this._previousCustomTabBarVariant != this.customTabBarVariant) {
this.setInvalidationFlag(INVALIDATION_FLAG_TAB_BAR_FACTORY);
}
Expand All @@ -414,6 +425,10 @@ class TabNavigator extends BaseNavigator implements IIndexSelector implements ID
this.createTabBar();
}

if (tabBarInvalid || stylesInvalid) {
this.refreshTabBar();
}

if (dataInvalid || tabBarInvalid) {
this.tabBar.itemToText = this.itemToText;
var oldIgnoreSelectionChange = this._ignoreSelectionChange;
Expand All @@ -437,6 +452,9 @@ class TabNavigator extends BaseNavigator implements IIndexSelector implements ID
}

override private function measure():Bool {
if (!this.showTabBar) {
return super.measure();
}
if (this.explicitWidth != null) {
this.tabBar.width = this.explicitWidth;
} else if (this._autoSizeMode == STAGE && this.stage != null) {
Expand Down Expand Up @@ -485,6 +503,10 @@ class TabNavigator extends BaseNavigator implements IIndexSelector implements ID
this.tabBar = null;
}

private function refreshTabBar():Void {
this.tabBar.visible = this.showTabBar;
}

override private function layoutContent():Void {
this.tabBar.x = 0.0;
this.tabBar.width = this.actualWidth;
Expand Down

0 comments on commit 6d56f24

Please sign in to comment.