Skip to content
Snippets Groups Projects
Commit dbea22c9 authored by zshan2's avatar zshan2
Browse files

final commit

parent 0406e34c
Branches master
No related tags found
1 merge request!1<Assignment-3.0>
......@@ -6,6 +6,7 @@ import Loading from './Components/Loading'
import Profile from './Components/Profile'
import Repo from './Components/Repo'
import Unfound from './Components/Unfound'
import DataGenerator from './Components/DataGenerator'
const Stack = createStackNavigator();
const styles = StyleSheet.create({
......@@ -19,23 +20,7 @@ const styles = StyleSheet.create({
marginHorizontal: 10, paddingVertical:10, paddingHorizontal: 50, alignItems: 'flex-start'}
});
/** Home page **/
function HomeScreen({ navigation }) {
return (
<View style={styles.container}>
<ImageBackground source={require('C:/Coding/cs242-assignment3/GitView/assets/ice.jpg')} style={styles.image}>
<View style={styles.viewStyleVertical}>
<Pressable style={styles.pressableStyle} onPress={() => navigation.navigate('LoadingProfile')}>
<Text> Start </Text>
</Pressable>
</View>
</ImageBackground>
</View>
);
}
/** Profile page **/
function ProfileScreen({ route, navigation }) {
function generateData(route, navigation) {
const {name, login, avatarUrl, bio, createdAt, email, websiteUrl, repositories} = route.params;
const dataFile = {}
dataFile['navi'] = navigation
......@@ -46,7 +31,6 @@ function ProfileScreen({ route, navigation }) {
dataFile['emailContent'] = 'Email: \n' + email
dataFile['websiteLink'] = 'Website: \n' + websiteUrl
dataFile['repoCount'] = 'Repository count: ' + repositories['nodes'].length
console.log(avatarUrl)
var iconUrl
if (avatarUrl != null) {
iconUrl = { uri: avatarUrl }
......@@ -54,6 +38,28 @@ function ProfileScreen({ route, navigation }) {
iconUrl = require('C:/Coding/cs242-assignment3/GitView/assets/default.png')
}
dataFile['iconUrl'] = iconUrl
return dataFile
}
/** Home page **/
function HomeScreen({ navigation }) {
return (
<View style={styles.container}>
<ImageBackground source={require('C:/Coding/cs242-assignment3/GitView/assets/ice.jpg')} style={styles.image}>
<View style={styles.viewStyleVertical}>
<Pressable style={styles.pressableStyle} onPress={() => navigation.navigate('LoadingProfile')}>
<Text> Start </Text>
</Pressable>
</View>
</ImageBackground>
</View>
);
}
/** Profile page **/
function ProfileScreen({ route, navigation }) {
var dataFile = generateData(route, navigation)
return (
<Profile data={dataFile}/>
);
......
function generateData(route, navigation) {
const {name, login, avatarUrl, bio, createdAt, email, websiteUrl, repositories} = route.params;
const dataFile = {}
dataFile['navi'] = navigation
dataFile['nameContent'] = 'Name: \n' + name
dataFile['userNameContent'] = 'UserName\n: ' + login
dataFile['bioContent'] = 'Bio: \n' + bio
dataFile['createDate'] = 'Create at: \n' + createdAt
dataFile['emailContent'] = 'Email: \n' + email
dataFile['websiteLink'] = 'Website: \n' + websiteUrl
dataFile['repoCount'] = 'Repository count: ' + repositories['nodes'].length
var iconUrl
if (avatarUrl != null) {
iconUrl = { uri: avatarUrl }
} else {
iconUrl = require('C:/Coding/cs242-assignment3/GitView/assets/default.png')
}
dataFile['iconUrl'] = iconUrl
return dataFile
}
module.exports = generateData;
\ No newline at end of file
......@@ -6,23 +6,60 @@ import renderer from 'react-test-renderer';
import Loading from '../Components/Loading';
import Repo from '../Components/Repo';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import Unfound from '../Components/Unfound';
const Stack = createStackNavigator();
test('renders correctly', ({}) => {
// const dataFile = {
// iconUrl: "https://avatars.githubusercontent.com/u/42978932?u=b4a7beb2752bb6059cd13d12ca26d097767abf77&v=4",
// nameContent: null,
// userNameContent: null,
// bioContent: null,
// websiteLink: null,
// emailContent: null,
// createData: null,
// repoCount: 0,
// navigation: navigation
// }
test('renders correctly', () => {
const tree = renderer.create(
<Loading />
).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly', ({navigation}) => {
const dataFile = {
iconUrl: "https://avatars.githubusercontent.com/u/42978932?u=b4a7beb2752bb6059cd13d12ca26d097767abf77&v=4",
nameContent: null,
userNameContent: null,
bioContent: null,
websiteLink: null,
emailContent: null,
createData: null,
repoCount: 0,
navi: navigation
}
const tree = renderer.create(
<Profile data={dataFile}/>
).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly', ({navigation}) => {
const dataFile = {
iconUrl: "https://avatars.githubusercontent.com/u/42978932?u=b4a7beb2752bb6059cd13d12ca26d097767abf77&v=4",
nameContent: null,
userNameContent: null,
bioContent: null,
websiteLink: null,
emailContent: null,
createData: null,
repoCount: 0,
navi: navigation
}
const tree = renderer.create(
<Repo data={dataFile}/>
).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly', ({navigation}) => {
const dataFile = {
navi: navigation
}
const tree = renderer.create(
<Unfound data={dataFile}/>
).toJSON();
expect(tree).toMatchSnapshot();
});
\ No newline at end of file
import 'react-native';
import React from 'react';
import Profile from '../Components/Profile';
import App from '../App'
import renderer from 'react-test-renderer';
import Loading from '../Components/Loading';
import Repo from '../Components/Repo';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import Unfound from '../Components/Unfound';
const Stack = createStackNavigator();
const generateData = require()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment