Skip to content

Commit b4b58a4

Browse files
committed
Initialize and setup lecture starter
1 parent 3839bcc commit b4b58a4

28 files changed

+687
-21
lines changed

Diff for: App.tsx

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import { StatusBar } from 'expo-status-bar';
2-
import { StyleSheet, Text, View } from 'react-native';
1+
import { StatusBar } from "expo-status-bar";
2+
import { StyleSheet } from "react-native";
3+
import { SafeAreaProvider } from "react-native-safe-area-context";
4+
5+
import { RootNavigator } from "./navigation";
6+
import { COLORS_LIGHT } from "./constants";
7+
import { ThemeProvider } from "./contexts";
38

49
export default function App() {
5-
return (
6-
<View style={styles.container}>
7-
<Text>Open up App.tsx to start working on your app!</Text>
8-
<StatusBar style="auto" />
9-
</View>
10-
);
10+
return (
11+
<SafeAreaProvider style={styles.container}>
12+
<ThemeProvider>
13+
<RootNavigator />
14+
</ThemeProvider>
15+
</SafeAreaProvider>
16+
);
1117
}
1218

1319
const styles = StyleSheet.create({
14-
container: {
15-
flex: 1,
16-
backgroundColor: '#fff',
17-
alignItems: 'center',
18-
justifyContent: 'center',
19-
},
20+
container: {
21+
flex: 1,
22+
alignItems: "center",
23+
justifyContent: "center",
24+
},
2025
});

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Dmytro Revenets
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# bsa-rn-base-starter

Diff for: app.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"web": {
2424
"favicon": "./assets/favicon.png"
25-
}
25+
},
26+
"plugins": ["expo-font"]
2627
}
2728
}

Diff for: babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ module.exports = function(api) {
22
api.cache(true);
33
return {
44
presets: ['babel-preset-expo'],
5+
plugins: [
6+
"react-native-reanimated/plugin",
7+
],
58
};
69
};

Diff for: constants/api.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const API = {
2+
QUOTE_URL: 'http://api.forismatic.com/api/1.0',
3+
IMAGE_URL: 'https://picsum.photos'
4+
}
5+
6+
export { API };

Diff for: constants/colors.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const COLORS_LIGHT = {
2+
appBackground: "#EEECEC",
3+
primary900: "#00146D",
4+
primary300: "#6d78bd",
5+
primary200: "#969ecf",
6+
primary100: "#B0B7E5",
7+
secondary800: "#6d0014",
8+
grey600: "#757575",
9+
grey300: "#BDBDBD",
10+
fontMain: "#000000",
11+
fontInverse: "#FFFFFF",
12+
} as const;
13+
14+
const COLORS_DARK = {
15+
appBackground: "#262626",
16+
primary900: "#BA68C8",
17+
primary300: "#e1bee7",
18+
primary200: "#514951",
19+
primary100: "#351401",
20+
secondary800: "#c86876",
21+
grey300: "#757575",
22+
grey600: "#BDBDBD",
23+
fontInverse: "#000000",
24+
fontMain: "#FFFFFF",
25+
} as const;
26+
27+
export { COLORS_DARK, COLORS_LIGHT };

Diff for: constants/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { API } from './api';
2+
export { COLORS_DARK, COLORS_LIGHT } from './colors';

Diff for: contexts/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ThemeProvider, ThemeContext } from './theme-context';

Diff for: contexts/theme-context.tsx

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { createContext, useState, useEffect, ReactNode } from 'react';
2+
import AsyncStorage from '@react-native-async-storage/async-storage';
3+
4+
import { COLORS_LIGHT, COLORS_DARK } from '../constants';
5+
6+
type ThemeType = typeof COLORS_LIGHT | typeof COLORS_DARK;
7+
8+
interface ThemeContextProps {
9+
theme: ThemeType;
10+
toggleTheme: () => void;
11+
}
12+
13+
const ThemeContext = createContext<ThemeContextProps | undefined>(undefined);
14+
15+
const ThemeProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
16+
const [theme, setTheme] = useState<ThemeType>(COLORS_LIGHT);
17+
18+
// Add logic to retrieve theme from AsyncStorage here
19+
20+
const toggleTheme = async () => {
21+
// Add logic to toggle theme here
22+
};
23+
24+
return (
25+
<ThemeContext.Provider value={{ theme, toggleTheme }}>
26+
{children}
27+
</ThemeContext.Provider>
28+
);
29+
};
30+
31+
export { ThemeProvider, ThemeContext };

Diff for: helpers/get-random-number.helper.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const getRandomNumber = (min?: number, max?: number): number => {
2+
if (min && max) {
3+
return Math.floor(Math.random() * (max - min + 1)) + min;
4+
}
5+
6+
return Math.floor(Math.random() * 100);
7+
}
8+
9+
export { getRandomNumber };

Diff for: helpers/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { getRandomNumber } from './get-random-number.helper';

Diff for: hooks/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { useTheme } from './use-theme';

Diff for: hooks/use-theme.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { useContext } from 'react';
2+
3+
import { ThemeContext } from '../contexts';
4+
5+
const useTheme = () => {
6+
const context = useContext(ThemeContext);
7+
8+
return context;
9+
};
10+
11+
export { useTheme };

Diff for: navigation/drawer-navigator.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { createDrawerNavigator } from "@react-navigation/drawer";
2+
3+
import { Dashboard, Settings } from '../screens';
4+
import { Text } from "react-native";
5+
6+
const Drawer = createDrawerNavigator();
7+
8+
const DrawerNavigator = () => {
9+
return (
10+
// Add Drawer.Navigator here
11+
<Text>Hello world!!!</Text>
12+
)
13+
}
14+
15+
export { DrawerNavigator };

Diff for: navigation/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { RootNavigator } from './root-navigator';

Diff for: navigation/root-navigator.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { NavigationContainer } from "@react-navigation/native";
2+
import { StatusBar } from "expo-status-bar";
3+
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
4+
5+
import { DrawerNavigator } from "./drawer-navigator";
6+
7+
const RootNavigator = () => {
8+
const insets = useSafeAreaInsets();
9+
10+
return (
11+
<SafeAreaView style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
12+
<StatusBar />
13+
<NavigationContainer>
14+
<>
15+
{/* Replace with navigator */}
16+
</>
17+
</NavigationContainer>
18+
</SafeAreaView>
19+
);
20+
};
21+
22+
export { RootNavigator };

0 commit comments

Comments
 (0)