Skip to content

Instantly share code, notes, and snippets.

@truongluu
Forked from xxRockOnxx/layouts.ts
Created April 27, 2020 13:49
Show Gist options
  • Save truongluu/6a10515a6468e3317e2bd2998e1202fb to your computer and use it in GitHub Desktop.
Save truongluu/6a10515a6468e3317e2bd2998e1202fb 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);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment