-
-
Save truongluu/6a10515a6468e3317e2bd2998e1202fb to your computer and use it in GitHub Desktop.
React Native Navigation with react-native-vector-icons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment