Skip to content

Commit 990868b

Browse files
committed
Adds homework 1
1 parent ad1bf6c commit 990868b

File tree

16 files changed

+7485
-0
lines changed

16 files changed

+7485
-0
lines changed

freetime-client

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit fb8cf8d419335fe43a69f04f67910cfc5d88c855

freetime-project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 64efe6c7e6e163cc5ed3af090af0c81f1a45f283

freetime-service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8f6f8d836b6ff0bfc8829973701dc4e7553a5196

homework1/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This homework exercise is based on NetNinja's
2+
[Todo application](https://www.youtube.com/playlist?list=PL4cUxeGkcC9ixPU-QkScoRBVxtPPzVjrQ)
3+
(lessons 9-11)
4+
5+
This truncated version implements the upgrades specified in lab 1 but leaves out
6+
much of the functionality and style implemented in the tutorial.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true,
3+
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
4+
}

homework1/my-project/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+
*.jks
5+
*.p8
6+
*.p12
7+
*.key
8+
*.mobileprovision
9+
*.orig.*
10+
web-build/
11+
web-report/
12+
13+
# macOS
14+
.DS_Store

homework1/my-project/App.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React, { useState } from 'react';
2+
import { StyleSheet, View, FlatList, Alert, TouchableWithoutFeedback, Keyboard } from 'react-native';
3+
import Header from './components/header';
4+
import TodoItem from './components/todoItem';
5+
import AddTodo from './components/addTodo';
6+
7+
export default function App() {
8+
const [todos, setTodos] = useState([]);
9+
10+
const pressHandler = (key) => {
11+
setTodos((prevTodos) => {
12+
return prevTodos.filter(todo => todo.key != key)
13+
});
14+
}
15+
16+
const submitHandler = (text) => {
17+
18+
if(text.length > 3){
19+
setTodos((prevTodos) => {
20+
return [
21+
{ text: text, key: Math.random().toString() },
22+
...prevTodos
23+
];
24+
});
25+
}else{
26+
Alert.alert("Well darn,", "Todos must be over 3 chars long", [
27+
{text: 'Understood', onPress: () => console.log('alert closed')}
28+
]);
29+
}
30+
31+
32+
}
33+
34+
return (
35+
<TouchableWithoutFeedback onPress={() => {
36+
Keyboard.dismiss();
37+
console.log('dismissed keyboard');
38+
}}>
39+
<View style={styles.container}>
40+
<Header />
41+
<View style={styles.content}>
42+
<AddTodo submitHandler={submitHandler}/>
43+
<View style={styles.list}>
44+
<FlatList
45+
data={todos}
46+
renderItem={({item}) => (
47+
<TodoItem item={item} pressHandler={pressHandler}/>
48+
)}
49+
/>
50+
</View>
51+
</View>
52+
</View>
53+
</TouchableWithoutFeedback>
54+
);
55+
}
56+
57+
const styles = StyleSheet.create({
58+
container: {
59+
flex: 1,
60+
backgroundColor: '#fff',
61+
},
62+
content: {
63+
flex: 1,
64+
padding: 40,
65+
},
66+
list: {
67+
marginTop: 20,
68+
flex: 1,
69+
}
70+
})

homework1/my-project/app.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"expo": {
3+
"name": "my-project",
4+
"slug": "my-project",
5+
"privacy": "public",
6+
"platforms": [
7+
"ios",
8+
"android",
9+
"web"
10+
],
11+
"version": "1.0.0",
12+
"orientation": "portrait",
13+
"icon": "./assets/icon.png",
14+
"splash": {
15+
"image": "./assets/splash.png",
16+
"resizeMode": "contain",
17+
"backgroundColor": "#ffffff"
18+
},
19+
"updates": {
20+
"fallbackToCacheTimeout": 0
21+
},
22+
"assetBundlePatterns": [
23+
"**/*"
24+
],
25+
"ios": {
26+
"supportsTablet": true
27+
}
28+
}
29+
}

homework1/my-project/assets/icon.png

1.07 KB
Loading
7.01 KB
Loading

0 commit comments

Comments
 (0)