Skip to content

Commit

Permalink
chore(tabstore): getters for tabstore vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Kounex committed Jan 31, 2024
1 parent 45cf037 commit 9008750
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/stores/shared/tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ abstract class _TabsStore with Store {
@observable
bool performTabClickAction = false;

GlobalKey<NavigatorState> keyForCurrentTab() =>
this.navigatorKeys[this.activeTab]!;

String activeRouteForCurrentTab() =>
this.activeRoutePerNavigator[this.activeTab]!;

@action
void setActiveTab(Tabs activeTab) => this.activeTab = activeTab;

Expand Down
5 changes: 2 additions & 3 deletions lib/tab_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ class _TabBaseState extends State<TabBase> {
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (tabsStore.navigatorKeys[tabsStore.activeTab]!.currentState!
.canPop()) {
tabsStore.navigatorKeys[tabsStore.activeTab]!.currentState!.pop();
if (tabsStore.keyForCurrentTab().currentState!.canPop()) {
tabsStore.keyForCurrentTab().currentState!.pop();
} else if (tabsStore.activeTab != Tabs.Home) {
tabsStore.setActiveTab(Tabs.Home);
}
Expand Down

0 comments on commit 9008750

Please sign in to comment.