Skip to content

Instantly share code, notes, and snippets.

@xxRockOnxx
Last active April 27, 2020 13:49
Show Gist options
  • Save xxRockOnxx/5bed9bac44d867e7ffabdbdb223b95a1 to your computer and use it in GitHub Desktop.
Save xxRockOnxx/5bed9bac44d867e7ffabdbdb223b95a1 to your computer and use it in GitHub Desktop.
React Native Navigation with react-native-vector-icons
interface Layouts {
[name: string]: LayoutRoot;
}
const layouts: Promise<Layouts> = new Promise(resolve => {
Promise.all([
Icon.getImageSource("people"),
Icon.getImageSource("message")
]).then(icons => {
resolve({
auth: {
root: {
component: {
name: "auth.LoginScreen"
}
}
},
home: {
root: {
bottomTabs: {
id: "BottomTabs",
children: [
{
stack: {
children: [
{
component: {
name: "collab.CollabScreen"
}
}
],
options: {
bottomTab: {
text: "Collab",
icon: icons[0]
}
}
}
},
{
stack: {
children: [
{
component: {
name: "messages.MessagesScreen"
}
}
],
options: {
bottomTab: {
text: "Messages",
icon: icons[1]
}
}
}
}
]
}
}
}
});
});
});
export function goToAuthScreen() {
layouts.then(({ auth }) => {
Navigation.setRoot(auth);
});
}
export function goToHomeScreen() {
layouts.then(({ home }) => {
Navigation.setRoot(home);
});
}
@davinctor
Copy link

Thank you, it helps me.

P.S. I have integrated it together with react-native-dark-theme and react-native-navigation works pretty bad with style changing on the fly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment