Skip to content

Instantly share code, notes, and snippets.

@hariDasu
Created March 31, 2019 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hariDasu/44ba8f1f2d4455929f8bd9aedef76335 to your computer and use it in GitHub Desktop.
Save hariDasu/44ba8f1f2d4455929f8bd9aedef76335 to your computer and use it in GitHub Desktop.
RNN-v2 Helper Functions with Flow Typing
import { Navigation } from "react-native-navigation";
class NavigationHelpers {
// @flow
static showModal = (
modalName: string,
modalTitleText: string,
props?: Object = {}
) => {
Navigation.showModal({
stack: {
children: [
{
component: {
name: modalName,
passProps: { ...props },
options: {
topBar: {
title: {
text: modalTitleText
},
//just an example, you would need your own <CloseModalButton/>
// leftButtons: [
// {
// id: "close",
// component: { name: "CloseModalButton" }
// }
// ]
}
}
}
}
]
}
});
};
// @flow
static pushComponent = (
componentId: string,
componentName: string,
title: string,
props?: Object = {}
) => {
Navigation.push(componentId, {
component: {
name: componentName,
passProps: {
...props
},
options: {
topBar: {
title: {
text: title
}
}
}
}
});
};
}
export { NavigationHelpers };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment