aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeon Jiang <35908040+leonyjiang@users.noreply.github.com>2020-06-25 16:28:00 -0700
committerLeon Jiang <35908040+leonyjiang@users.noreply.github.com>2020-06-25 16:28:00 -0700
commitbc8184b1a402af0c3e54edb79b38ed8e09a6798d (patch)
tree2ac23485a81086ab4e5df2989e2002c7e67cd56a /src
parent36a6781faad4380e7c401f32506707c0e48a15f5 (diff)
cleanup file structure, add react-navigation & basic routes
Diffstat (limited to 'src')
-rw-r--r--src/App.tsx23
-rw-r--r--src/__tests__/App-test.tsx16
-rw-r--r--src/index.ts1
-rw-r--r--src/routes/Routes.tsx24
-rw-r--r--src/routes/index.ts2
-rw-r--r--src/screens/Login.tsx27
-rw-r--r--src/screens/Registration.tsx14
-rw-r--r--src/screens/index.ts2
8 files changed, 109 insertions, 0 deletions
diff --git a/src/App.tsx b/src/App.tsx
new file mode 100644
index 00000000..6c247f7c
--- /dev/null
+++ b/src/App.tsx
@@ -0,0 +1,23 @@
+/**
+ * Sample React Native App
+ * https://github.com/facebook/react-native
+ *
+ * Generated with the TypeScript template
+ * https://github.com/react-native-community/react-native-template-typescript
+ *
+ * @format
+ */
+
+import React from 'react';
+import Routes from './routes';
+import {NavigationContainer} from '@react-navigation/native';
+
+const App = () => {
+ return (
+ <NavigationContainer>
+ <Routes />
+ </NavigationContainer>
+ );
+};
+
+export default App;
diff --git a/src/__tests__/App-test.tsx b/src/__tests__/App-test.tsx
new file mode 100644
index 00000000..e362fb52
--- /dev/null
+++ b/src/__tests__/App-test.tsx
@@ -0,0 +1,16 @@
+/**
+ * @format
+ */
+
+import 'react-native';
+import React from 'react';
+import App from '../App';
+
+// Note: test renderer must be required after react-native.
+import renderer from 'react-test-renderer';
+
+jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
+
+it('renders correctly', () => {
+ renderer.create(<App />);
+});
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 00000000..ab7fd11d
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1 @@
+export {default} from './App';
diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx
new file mode 100644
index 00000000..9c2efada
--- /dev/null
+++ b/src/routes/Routes.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+import {createStackNavigator} from '@react-navigation/stack';
+
+import {Login, Registration} from '../screens';
+
+export type RootStackParams = {
+ Login: undefined;
+ Registration: undefined;
+};
+
+const RootStack = createStackNavigator<RootStackParamList>();
+
+interface RoutesProps {}
+
+const Routes: React.FC<RoutesProps> = ({}) => {
+ return (
+ <RootStack.Navigator initialRouteName="Login">
+ <RootStack.Screen name="Login" component={Login} />
+ <RootStack.Screen name="Registration" component={Registration} />
+ </RootStack.Navigator>
+ );
+};
+
+export default Routes;
diff --git a/src/routes/index.ts b/src/routes/index.ts
new file mode 100644
index 00000000..cfa05fcb
--- /dev/null
+++ b/src/routes/index.ts
@@ -0,0 +1,2 @@
+export {default} from './Routes';
+export * from './Routes';
diff --git a/src/screens/Login.tsx b/src/screens/Login.tsx
new file mode 100644
index 00000000..0305b907
--- /dev/null
+++ b/src/screens/Login.tsx
@@ -0,0 +1,27 @@
+import React from 'react';
+import {RouteProp} from '@react-navigation/native';
+import {StackNavigationProp} from '@react-navigation/stack';
+import {View, Text, Button} from 'react-native';
+
+import {RootStackParams} from '../routes';
+
+type LoginScreenRouteProp = RouteProp<RootStackParams, 'Login'>;
+type LoginScreenNavigationProp = StackNavigationProp<RootStackParams, 'Login'>;
+
+interface LoginProps {
+ route: LoginScreenRouteProp;
+ navigation: LoginScreenNavigationProp;
+}
+const Login = ({navigation}: LoginProps) => {
+ return (
+ <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
+ <Text style={{fontSize: 18}}>Welcome to Tagg! Login page goes here.</Text>
+ <Button
+ title="Register"
+ onPress={() => navigation.navigate('Registration')}
+ />
+ </View>
+ );
+};
+
+export default Login;
diff --git a/src/screens/Registration.tsx b/src/screens/Registration.tsx
new file mode 100644
index 00000000..44658591
--- /dev/null
+++ b/src/screens/Registration.tsx
@@ -0,0 +1,14 @@
+import React from 'react';
+import {View, Text} from 'react-native';
+
+interface RegistrationProps {}
+
+const Registration: React.FC<RegistrationProps> = ({}) => {
+ return (
+ <View style={{flex: 1, alignSelf: 'center', justifyContent: 'center'}}>
+ <Text style={{fontSize: 18}}>Registration sequence begins here!</Text>
+ </View>
+ );
+};
+
+export default Registration;
diff --git a/src/screens/index.ts b/src/screens/index.ts
new file mode 100644
index 00000000..60b26b4c
--- /dev/null
+++ b/src/screens/index.ts
@@ -0,0 +1,2 @@
+export {default as Login} from './Login';
+export {default as Registration} from './Registration';