Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/models
amplify-codegen-temp/models
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,25 @@ yarn-error.log

# testing
/coverage

#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/logs
amplify/mock-data
amplify/mock-api-resources
amplify/backend/amplify-meta.json
amplify/backend/.temp
build/
dist/
node_modules/
aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplifyconfiguration.dart
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end
18 changes: 18 additions & 0 deletions .graphqlconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
projects:
teamup:
schemaPath: amplify/backend/api/teamup/build/schema.graphql
includes:
- src/graphql/**/*.js
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: javascript
generatedFileName: ''
docsFilePath: src/graphql
region: eu-west-2
apiId: null
maxDepth: 2
extensions:
amplify:
version: 3
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.exclude": {
"amplify/.config": true,
"amplify/**/*-parameters.json": true,
"amplify/**/amplify.state": true,
"amplify/**/transform.conf.json": true,
"amplify/#current-cloud-backend": true,
"amplify/backend/amplify-meta.json": true,
"amplify/backend/awscloudformation": true
}
}
91 changes: 81 additions & 10 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,94 @@
import React from "react";
import React, {useState, useEffect} from 'react';
import 'react-native-gesture-handler';
import {View, StyleSheet } from "react-native";
import HomeScreen from "./src/screens/Home";
import MachesScreen from "./src/screens/MachesScreen";
import {
View,
StyleSheet,
SafeAreaView,
Pressable,
ActivityIndicator,
} from 'react-native';
import {createStackNavigator} from '@react-navigation/stack';
import {Amplify, Auth} from 'aws-amplify';
import awsExports from './src/aws-exports';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import Chats from './src/screens/Chat/Chat';
import Navigation from './src/navigation/MainNavigation';
import MainNavigation from './src/navigation/MainNavigation';
import AuthNavigation from './src/navigation/AuthNavigation';
import {Hub} from 'aws-amplify';
import {enableLatestRenderer} from 'react-native-maps';

Amplify.configure({
...awsExports,
oauth: {
...awsExports.oauth,
},
DataStore: {
authModeStrategyType: 'MULTI_AUTH',
},
aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS',
});

const Stack = createStackNavigator();
enableLatestRenderer();

const App = () => {
const [user, setUser] = useState(null);
const [isLoading, setLoading] = useState(true);

const checkUser = async () => {
setLoading(true);
try {
const authUser = await Auth.currentAuthenticatedUser({bypassCache: true});
setUser(authUser);
} catch (e) {
setUser(null);
}
setLoading(false);
};

useEffect(() => {
checkUser();
}, []);

useEffect(() => {
const listener = data => {
if (data.payload.event === 'signIn' || data.payload.event === 'signOut') {
checkUser();
}
};
Hub.listen('auth', listener);
return () => Hub.remove('auth', listener);
}, []);

// Auth.signOut()
return (
<View style={styles.container}>
<HomeScreen/>
</View>
<SafeAreaView style={{flex: 1}}>
<GestureHandlerRootView style={{flex: 1}}>
<View style={styles.root}>
{!isLoading && user && <MainNavigation />}
{!isLoading && !user && <AuthNavigation />}
{isLoading && <ActivityIndicator />}
</View>
</GestureHandlerRootView>
</SafeAreaView>
);
};

const styles = StyleSheet.create({
root: {
flex: 1,
},
container: {
justifyContent: "center",
alignItems: "center",
justifyContent: 'center',
alignItems: 'center',
flex: 1,
width: '100%'
},
topNavigation: {
flexDirection: 'row',
justifyContent: 'space-around',
width: '100%',
padding: 10,
},
});

Expand Down
100 changes: 0 additions & 100 deletions Gemfile.lock

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ If everything is set up _correctly_, you should see your new app running in your

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

## Get Access To Amplify Data
`amplify pull --appId d3mwunpa3xc3o3 --envName dev`

This will help to get access to backend of the application

## Step 3: Modifying your App

Now that you have successfully run the app, let's modify it.
Expand Down
21 changes: 21 additions & 0 deletions __tests__/components/Card.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import Card from '../src/components/Card';

const Profile = {
name: 'John Doe',
image: 'https://i.pinimg.com/564x/6b/5d/f2/6b5df2cbfdd8074930c227fae2843a1a.jpg',
bio: 'A bio for testing purposes.',
};

test('Card component renders correctly', () => {
const { getByText } = render(<Card user={Profile} />);

const nameElement = getByText('John Doe');
const bioElement = getByText('A bio for testing purposes.');

expect(nameElement).toBeDefined();
expect(bioElement).toBeDefined();
});


29 changes: 29 additions & 0 deletions __tests__/components/ChatRoomItem.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import renderer from 'react-test-renderer';
import ChatRoomItem from '../../src/components/Chat/ChatRoomItem';

jest.mock('@react-navigation/native', () => ({
useNavigation: () => ({ navigate: jest.fn() }),
}));

const chatRoom = {
id: '1',
users: [
{
name: 'John Doe',
imageUri: 'https://example.com/john.jpg',
},

],
newMessages: 3,
lastMessage: {
content: 'Hello, how are you?',
createdAt: '2023-09-21T12:00:00Z',
},
};

test('ChatRoomItem component renders correctly', () => {
const tree = renderer.create(<ChatRoomItem chatRoom={chatRoom} />).toJSON();

expect(tree).toMatchSnapshot();
});
19 changes: 19 additions & 0 deletions __tests__/components/MessageInput.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import MessageInput from '../../src/components/MessageInput';

describe('MessageInput component', () => {
it('renders correctly', () => {
const { getByPlaceholderText } = render(<MessageInput />);
const inputElement = getByPlaceholderText('Send a message....');
expect(inputElement).toBeTruthy();
});

it('updates message state on input change', () => {
const { getByPlaceholderText } = render(<MessageInput />);
const inputElement = getByPlaceholderText('Send a message....');

fireEvent.changeText(inputElement, 'Test message');
expect(inputElement.props.value).toBe('Test message');
});
});
3 changes: 3 additions & 0 deletions __tests__/components/__snapshots__/ChatRoomItem.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ChatRoomItem component renders correctly 1`] = `null`;
17 changes: 17 additions & 0 deletions amplify/.config/project-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"providers": [
"awscloudformation"
],
"projectName": "TeamUp",
"version": "3.1",
"frontend": "javascript",
"javascript": {
"framework": "react-native",
"config": {
"SourceDir": "src",
"DistributionDir": "/",
"BuildCommand": "npm run-script build",
"StartCommand": "npm run-script start"
}
}
}
17 changes: 17 additions & 0 deletions amplify/backend/api/TeamUp/cli-inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"serviceConfiguration": {
"apiName": "teamup",
"serviceName": "AppSync",
"defaultAuthType": {
"mode": "API_KEY",
"expirationTime": 7
},
"additionalAuthTypes": [
{
"mode": "AMAZON_COGNITO_USER_POOLS",
"cognitoUserPoolId": "authteamupd00d1cb5"
}
]
}
}
Loading