Skip to content

Commit

Permalink
nomadcoders#13.2 TabBar, Styles, Loader
Browse files Browse the repository at this point in the history
  • Loading branch information
serranoarevalo committed Jun 24, 2019
1 parent d29c9e3 commit 27e5200
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 20 deletions.
1 change: 1 addition & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from "react";
import { View } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { AppLoading } from "expo";
import { Asset } from "expo-asset";
Expand Down
16 changes: 16 additions & 0 deletions components/Loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { ActivityIndicator } from "react-native";
import styled from "styled-components";
import styles from "../styles";

const Container = styled.View`
flex: 1;
justify-content: center;
align-items: center;
`;

export default () => (
<Container>
<ActivityIndicator color={styles.blackColor} />
</Container>
);
7 changes: 1 addition & 6 deletions components/NavController.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import React from "react";
import { View } from "react-native";
import { useIsLoggedIn } from "../AuthContext";
import AuthNavigation from "../navigation/AuthNavigation";
import MainNavigation from "../navigation/MainNavigation";

export default () => {
const isLoggedIn = useIsLoggedIn();
return (
<View style={{ flex: "1" }}>
{isLoggedIn ? <MainNavigation /> : <AuthNavigation />}
</View>
);
return isLoggedIn ? <MainNavigation /> : <AuthNavigation />;
};
6 changes: 6 additions & 0 deletions navigation/MainNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createStackNavigator, createAppContainer } from "react-navigation";
import TabNavigation from "./TabNavigation";
import PhotoNavigation from "./PhotoNavigation";
import MessageNavigation from "./MessageNavigation";
import { stackStyles } from "./config";

const MainNavigation = createStackNavigator(
{
Expand All @@ -10,6 +11,11 @@ const MainNavigation = createStackNavigator(
MessageNavigation
},
{
defaultNavigationOptions: {
headerStyle: {
...stackStyles
}
},
headerMode: "none",
mode: "modal"
}
Expand Down
18 changes: 14 additions & 4 deletions navigation/MessageNavigation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import { createStackNavigator } from "react-navigation";
import Messages from "../screens/Messages/Messages";
import Message from "../screens/Messages/Message";
import { stackStyles } from "./config";

export default createStackNavigator({
Messages,
Message
});
export default createStackNavigator(
{
Messages,
Message
},
{
defaultNavigationOptions: {
headerStyle: {
...stackStyles
}
}
}
);
18 changes: 14 additions & 4 deletions navigation/PhotoNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import SelectPhoto from "../screens/Photo/SelectPhoto";
import TakePhoto from "../screens/Photo/TakePhoto";
import UploadPhoto from "../screens/Photo/UploadPhoto";
import { stackStyles } from "./config";

const PhotoTabs = createMaterialTopTabNavigator(
{
Expand All @@ -16,7 +17,16 @@ const PhotoTabs = createMaterialTopTabNavigator(
}
);

export default createStackNavigator({
PhotoTabs,
UploadPhoto
});
export default createStackNavigator(
{
PhotoTabs,
UploadPhoto
},
{
defaultNavigationOptions: {
headerStyle: {
...stackStyles
}
}
}
);
7 changes: 4 additions & 3 deletions navigation/TabNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import Profile from "../screens/Tabs/Profile";
import MessagesLink from "../components/MessagesLink";
import { View } from "react-native";
import NavIcon from "../components/NavIcon";
import { stackStyles } from "./config";

const stackFactory = (initialRoute, customConfig) =>
createStackNavigator({
InitialRoute: {
screen: initialRoute,
navigationOptions: {
...customConfig,
headerStyle: { backgroundColor: "#EFEEEF" }
headerStyle: { ...stackStyles }
}
}
});
Expand Down Expand Up @@ -104,8 +105,8 @@ export default createBottomTabNavigator(
{
tabBarOptions: {
showLabel: false,
tabStyle: {
backgroundColor: "#EFEEEF"
style: {
backgroundColor: "#FAFAFA"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions navigation/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const stackStyles = {
backgroundColor: "#FAFAFA"
};
5 changes: 2 additions & 3 deletions screens/Tabs/Home.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from "react";
import styled from "styled-components";
import Loader from "../../components/Loader";

const View = styled.View`
justify-content: center;
align-items: center;
flex: 1;
`;

const Text = styled.Text``;

export default () => (
<View>
<Text>Home</Text>
<Loader />
</View>
);

0 comments on commit 27e5200

Please sign in to comment.