mattermost-mobile/app/store/ephemeral_store.ts
Avinash Lingaloo 2c193f2133
[GEKIDOU] Bottom Tab Navigation (#5600)
* Started with bottom tabs layout

* code clean up

* Added animation to bottom tab bar

* returns null if not focused

* code clean up

* Updating layout

* Updated modal screen

* Updated animation

* Updated animation

* Fix SafeArea on Home

* A few clean ups

* code clean up

* Fix issue with navigation on Android

* Use React Navigation in combination of RNN & create bottom tab bar

* Set tab bar line separator height to 0.5

* Fix snapshot tests

* Add home tab mention badge

* Apply new themes

* Home Tab badge

* Remove unused constants

Co-authored-by: Avinash Lingaloo <>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2021-08-31 14:58:53 -04:00

66 lines
2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
class EphemeralStore {
allNavigationComponentIds: string[] = [];
navigationComponentIdStack: string[] = [];
navigationModalStack: string[] = [];
theme: Theme | undefined;
getNavigationTopComponentId = () => {
return this.navigationComponentIdStack[0];
}
clearNavigationComponents = () => {
this.navigationComponentIdStack = [];
this.navigationModalStack = [];
this.allNavigationComponentIds = [];
};
clearNavigationModals = () => {
this.navigationModalStack = [];
}
addNavigationComponentId = (componentId: string) => {
this.addToNavigationComponentIdStack(componentId);
this.addToAllNavigationComponentIds(componentId);
};
addNavigationModal = (componentId: string) => {
this.navigationModalStack.unshift(componentId);
}
addToNavigationComponentIdStack = (componentId: string) => {
const index = this.navigationComponentIdStack.indexOf(componentId);
if (index >= 0) {
this.navigationComponentIdStack = this.navigationComponentIdStack.slice(index, 1);
}
this.navigationComponentIdStack.unshift(componentId);
}
addToAllNavigationComponentIds = (componentId: string) => {
if (!this.allNavigationComponentIds.includes(componentId)) {
this.allNavigationComponentIds.unshift(componentId);
}
}
hasModalsOpened = () => this.navigationModalStack.length > 0;
removeNavigationComponentId = (componentId: string) => {
const index = this.navigationComponentIdStack.indexOf(componentId);
if (index >= 0) {
this.navigationComponentIdStack.splice(index, 1);
}
}
removeNavigationModal = (componentId: string) => {
const index = this.navigationModalStack.indexOf(componentId);
if (index >= 0) {
this.navigationModalStack.splice(index, 1);
}
}
}
export default new EphemeralStore();