Skip to content

Commit

Permalink
add bottom tab navigation and stack navigation with Typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lupascu authored and Daniel Lupascu committed Jun 19, 2020
0 parents commit 9e604db
Show file tree
Hide file tree
Showing 40 changed files with 7,386 additions and 0 deletions.
30 changes: 30 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { StyleSheet } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { AppLoading } from "expo";

import TabNavigation from "./navigation/BottomTabNavigation";
import { useLoadFonts } from "./hooks/loadFonts.tsx";

export default function App() {
const fontsLoaded = useLoadFonts();

if (!fontsLoaded) {
return <AppLoading />;
} else {
return (
<NavigationContainer>
<TabNavigation />
</NavigationContainer>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
28 changes: 28 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"expo": {
"name": "CoverToCover",
"slug": "CoverToCover",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
}
}
93 changes: 93 additions & 0 deletions assets/fonts/poppins/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2014-2017 Indian Type Foundry ([email protected])

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added assets/fonts/poppins/Poppins-Black.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-BlackItalic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-Bold.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-BoldItalic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-ExtraBold.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-ExtraBoldItalic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-ExtraLight.ttf
Binary file not shown.
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-Italic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-Light.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-LightItalic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-Medium.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-MediumItalic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-SemiBold.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-SemiBoldItalic.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-Thin.ttf
Binary file not shown.
Binary file added assets/fonts/poppins/Poppins-ThinItalic.ttf
Binary file not shown.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/icons/tabNavigation/DashboardIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { View } from "react-native";
import Svg, { Rect } from "react-native-svg";

type PropsType = {
color: string;
};

const DashboardIcon = ({ color }: PropsType) => {
return (
<View>
<Svg
width="19"
height="20"
fill="none"
// xmlns="http://www.w3.org/2000/svg"
>
<Rect y="12" width="5" height="8" rx="2" fill={color} />
<Rect x="7" y="7" width="5" height="13" rx="2" fill={color} />
<Rect x="14" width="5" height="20" rx="2" fill={color} />
</Svg>
</View>
);
};

export default DashboardIcon;
34 changes: 34 additions & 0 deletions assets/icons/tabNavigation/LoansIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import { View } from "react-native";
import Svg, { Rect } from "react-native-svg";

type PropsType = {
color: string;
};

const LoansIcon = ({ color }: PropsType) => {
return (
<View>
<Svg
width="25"
height="25"
fill="none"
// xmlns="http://www.w3.org/2000/svg"
>
<Rect width="5" height="20" rx="2" fill={color} />
<Rect x="7" width="5" height="20" rx="2" fill={color} />
<Rect
x="14"
y=".858154"
width="5"
height="20"
rx="2"
transform="rotate(-9.883 14 .858154)"
fill={color}
/>
</Svg>
</View>
);
};

export default LoansIcon;
25 changes: 25 additions & 0 deletions assets/icons/tabNavigation/TrackingIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { View } from "react-native";
import Svg, { Circle } from "react-native-svg";

type PropsType = {
color: string;
};

const TrackingIcon = ({ color }: PropsType) => {
return (
<View>
<Svg
width="20"
height="20"
fill="none"
// xmlns="http://www.w3.org/2000/svg"
>
<Circle cx="10" cy="10" r="4" fill={color} />
<Circle cx="10" cy="10" r="9" stroke={color} strokeWidth="2" />
</Svg>
</View>
);
};

export default TrackingIcon;
Binary file added assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
13 changes: 13 additions & 0 deletions components/HeaderTItle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

import TextComponent from "./Text";

type PropsType = {
title: string;
};

const HeaderTitle = (props: PropsType) => {
return <TextComponent>{props.title}</TextComponent>;
};

export default HeaderTitle;
21 changes: 21 additions & 0 deletions components/Text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import { Text } from "react-native";
import { StyleSheet } from "react-native";

const styles = StyleSheet.create({
text: {
color: "pink",
fontFamily: "Poppins-Medium",
fontSize: 20,
},
});

type PropsType = {
children: React.ReactNode;
};

const TextComponent = ({ children }: PropsType) => (
<Text style={styles.text}>{children}</Text>
);

export default TextComponent;
26 changes: 26 additions & 0 deletions hooks/loadFonts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useFonts } from "@use-expo/font";

export const useLoadFonts = () => {
let [fontsLoaded] = useFonts({
"Poppins-Black": require("../assets/fonts/poppins/Poppins-Black.ttf"),
"Poppins-BlackItalic": require("../assets/fonts/poppins/Poppins-BlackItalic.ttf"),
"Poppins-Bold": require("../assets/fonts/poppins/Poppins-Bold.ttf"),
"Poppins-BoldItalic": require("../assets/fonts/poppins/Poppins-BoldItalic.ttf"),
"Poppins-ExtraBold": require("../assets/fonts/poppins/Poppins-ExtraBold.ttf"),
"Poppins-ExtraBoldItalic": require("../assets/fonts/poppins/Poppins-ExtraBoldItalic.ttf"),
"Poppins-ExtraLight": require("../assets/fonts/poppins/Poppins-ExtraLight.ttf"),
"Poppins-ExtraLightItalic": require("../assets/fonts/poppins/Poppins-ExtraLightItalic.ttf"),
"Poppins-Italic": require("../assets/fonts/poppins/Poppins-Italic.ttf"),
"Poppins-Light": require("../assets/fonts/poppins/Poppins-Light.ttf"),
"Poppins-LightItalic": require("../assets/fonts/poppins/Poppins-LightItalic.ttf"),
"Poppins-Medium": require("../assets/fonts/poppins/Poppins-Medium.ttf"),
"Poppins-MediumItalic": require("../assets/fonts/poppins/Poppins-MediumItalic.ttf"),
"Poppins-Regular": require("../assets/fonts/poppins/Poppins-Regular.ttf"),
"Poppins-SemiBold": require("../assets/fonts/poppins/Poppins-SemiBold.ttf"),
"Poppins-SemiBoldItalic": require("../assets/fonts/poppins/Poppins-SemiBoldItalic.ttf"),
"Poppins-Thin": require("../assets/fonts/poppins/Poppins-Thin.ttf"),
"Poppins-ThinItalic": require("../assets/fonts/poppins/Poppins-ThinItalic.ttf"),
});

return fontsLoaded;
};
55 changes: 55 additions & 0 deletions navigation/BottomTabNavigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from "react";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";

import DashboardStackNavigation from "./DashboardStackNavigation";
import TrackingStackNavigation from "./TrackingStackNavigation";
import DashboardIcon from "../assets/icons/tabNavigation/DashboardIcon";
import TrackingIcon from "../assets/icons/tabNavigation/TrackingIcon";
import LoansIcon from "../assets/icons/tabNavigation/LoansIcon";

const Tab = createBottomTabNavigator();

const TabNavigation = () => {
return (
<Tab.Navigator
tabBarOptions={{
showLabel: false,
activeTintColor: "pink",
inactiveTintColor: "#DEDEDE",
labelStyle: {
marginTop: -5,
fontSize: 12,
fontFamily: "Poppins-Medium",
},
tabStyle: { width: 100 },
}}
>
<Tab.Screen
options={{
// tabBarLabel: "Dashboard",
tabBarIcon: ({ color }) => <DashboardIcon color={color} />,
}}
name="Dashboard"
component={DashboardStackNavigation}
/>
<Tab.Screen
options={{
tabBarLabel: "Tracking",
tabBarIcon: ({ color }) => <TrackingIcon color={color} />,
}}
name="Tracking"
component={TrackingStackNavigation}
/>
<Tab.Screen
options={{
tabBarLabel: "Loans",
tabBarIcon: ({ color }) => <LoansIcon color={color} />,
}}
name="Loans"
component={TrackingStackNavigation}
/>
</Tab.Navigator>
);
};

export default TabNavigation;
Loading

0 comments on commit 9e604db

Please sign in to comment.