Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static BottomTabOptions parse(Context context, TypefaceLoader typefaceMan
options.selectedFontSize = NumberParser.parse(json, "selectedFontSize");
options.dotIndicator = DotIndicatorOptions.parse(context, json.optJSONObject("dotIndicator"));
options.selectTabOnPress = BoolParser.parse(json, "selectTabOnPress");
options.popToRoot = BoolParser.parse(json, "popToRoot");

return options;
}
Expand All @@ -64,6 +65,7 @@ public static BottomTabOptions parse(Context context, TypefaceLoader typefaceMan
public Number fontSize = new NullNumber();
public Number selectedFontSize = new NullNumber();
public Bool selectTabOnPress = new NullBool();
public Bool popToRoot = new NullBool();
public FontOptions font = new FontOptions();


Expand All @@ -87,6 +89,7 @@ void mergeWith(final BottomTabOptions other) {
font.mergeWith(other.font);
if (other.dotIndicator.hasValue()) dotIndicator = other.dotIndicator;
if (other.selectTabOnPress.hasValue()) selectTabOnPress = other.selectTabOnPress;
if (other.popToRoot.hasValue()) popToRoot = other.popToRoot;
}

void mergeWithDefault(final BottomTabOptions defaultOptions) {
Expand All @@ -109,6 +112,7 @@ void mergeWithDefault(final BottomTabOptions defaultOptions) {
if (!testId.hasValue()) testId = defaultOptions.testId;
if (!dotIndicator.hasValue()) dotIndicator = defaultOptions.dotIndicator;
if (!selectTabOnPress.hasValue()) selectTabOnPress = defaultOptions.selectTabOnPress;
if (!popToRoot.hasValue()) popToRoot = defaultOptions.popToRoot;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public boolean onTabSelected(int index, boolean wasSelected) {
}
}

if (wasSelected && stack instanceof StackController) {
if (options.popToRoot.get(false) && wasSelected && stack instanceof StackController) {
((StackController) stack).popToRoot(Options.EMPTY, new CommandListenerAdapter());
}

Expand Down
5 changes: 5 additions & 0 deletions lib/src/interfaces/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,11 @@ export interface OptionsBottomTab {
* instead it will emit a bottomTabPressedEvent
*/
selectTabOnPress?: boolean;
/**
* Pop to root of stack by tapping on already selected tab
* #### (Android specific)
*/
popToRoot?: boolean;
}

export interface SideMenuSide {
Expand Down
8 changes: 8 additions & 0 deletions website/docs/api/options-bottomTab.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const options = {
| ------- | -------- | -------- |
| boolean | No | Both |

## `popToRoot`

Pop to root of stack by tapping on already selected tab.

| Type | Required | Platform |
| ------- | -------- | --------- |
| boolean | No | Android |

## `badge`

| Type | Required | Platform |
Expand Down