Skip to content

Commit 0383531

Browse files
committed
first commit
0 parents  commit 0383531

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+35119
-0
lines changed

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
ios/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
36+
37+
# node.js
38+
#
39+
node_modules/
40+
npm-debug.log
41+
yarn-error.log
42+
43+
# fastlane
44+
#
45+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46+
# screenshots whenever they are needed.
47+
# For more information about the recommended setup visit:
48+
# https://docs.fastlane.tools/best-practices/source-control/
49+
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
54+
55+
# Bundle artifact
56+
*.jsbundle
57+
58+
# Ruby / CocoaPods
59+
/ios/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*

.node-version

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

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

.ruby-version

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

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.tsx

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import React, {useState, useLayoutEffect, useEffect} from 'react';
2+
import {
3+
SafeAreaView,
4+
StyleSheet,
5+
Text,
6+
View,
7+
TextInput,
8+
Button,
9+
FlatList,
10+
Image,
11+
} from 'react-native';
12+
13+
import AsyncStorage from '@react-native-async-storage/async-storage';
14+
15+
function App(): JSX.Element {
16+
const [todos, setTodos] = useState([
17+
'Try adding some tasks for your awesome day! 💫',
18+
]);
19+
20+
useLayoutEffect(() => {
21+
AsyncStorage.getItem('todos').then(todos => {
22+
if (todos) {
23+
setTodos(JSON.parse(todos));
24+
console.log(todos);
25+
}
26+
});
27+
}, []);
28+
29+
useEffect(() => {
30+
AsyncStorage.setItem('todos', JSON.stringify(todos));
31+
}, [todos]);
32+
33+
const [task, setTask] = useState('');
34+
35+
const addTask = () => {
36+
task && setTodos(prevTasks => [task, ...prevTasks]);
37+
};
38+
39+
const removeTask = (index: number) => {
40+
const newTodos = todos.filter((todo, i) => i !== index);
41+
setTodos(newTodos);
42+
};
43+
44+
return (
45+
<SafeAreaView style={styles.container}>
46+
<View style={styles.header}>
47+
<Text style={styles.text}>Todos 📝</Text>
48+
</View>
49+
<View style={styles.todoEntry}>
50+
<TextInput
51+
style={styles.input}
52+
placeholder="Enter Task!"
53+
onChangeText={text => setTask(text)}
54+
/>
55+
<Button color="black" title="Add Task" onPress={addTask} />
56+
</View>
57+
<View style={styles.taskHeader}>
58+
<Text style={styles.taskText}>Tasks ✏</Text>
59+
</View>
60+
61+
{!(todos.length === 0) ? (
62+
<FlatList
63+
style={styles.taskContainer}
64+
data={todos}
65+
renderItem={todoData => {
66+
return (
67+
<View key={todoData.index} style={styles.todoContainer}>
68+
<Text>{todoData.item}</Text>
69+
<Button
70+
color="gray"
71+
title="Delete"
72+
onPress={() => removeTask(todoData.index)}
73+
/>
74+
</View>
75+
);
76+
}}
77+
/>
78+
) : (
79+
<View style={styles.emptyDiv}>
80+
<Image source={require('./empty.jpg')} style={{}} />
81+
<Text style={styles.emptyText}>Add Some Tasks UwU</Text>
82+
</View>
83+
)}
84+
{/* </View> */}
85+
</SafeAreaView>
86+
);
87+
}
88+
89+
const styles = StyleSheet.create({
90+
container: {
91+
display: 'flex',
92+
justifyContent: 'flex-start',
93+
alignItems: 'center',
94+
flex: 1,
95+
backgroundColor: 'black',
96+
},
97+
header: {
98+
display: 'flex',
99+
justifyContent: 'center',
100+
alignItems: 'center',
101+
width: '100%',
102+
height: 50,
103+
borderBottomColor: 'gray',
104+
borderBottomWidth: 1,
105+
},
106+
text: {
107+
color: 'white',
108+
fontSize: 15,
109+
fontWeight: 'normal',
110+
},
111+
todoEntry: {
112+
width: '100%',
113+
paddingVertical: 15,
114+
paddingHorizontal: 5,
115+
flexDirection: 'row',
116+
justifyContent: 'space-between',
117+
},
118+
input: {
119+
backgroundColor: 'gray',
120+
flex: 3,
121+
height: 40,
122+
padding: 10,
123+
borderRadius: 5,
124+
},
125+
taskBtn: {
126+
flex: 1,
127+
margin: 10,
128+
backgroundColor: 'white',
129+
color: 'black',
130+
},
131+
taskHeader: {
132+
display: 'flex',
133+
alignItems: 'flex-start',
134+
width: '100%',
135+
padding: 20,
136+
},
137+
taskText: {
138+
color: 'white',
139+
fontSize: 30,
140+
fontWeight: 'bold',
141+
},
142+
taskContainer: {
143+
display: 'flex',
144+
width: '100%',
145+
paddingHorizontal: 5,
146+
marginBottom: 20,
147+
},
148+
todoContainer: {
149+
display: 'flex',
150+
borderWidth: 1,
151+
borderColor: 'white',
152+
borderRadius: 5,
153+
padding: 15,
154+
gap: 10,
155+
width: '100%',
156+
marginBottom: 10,
157+
},
158+
emptyDiv: {
159+
width: '100%',
160+
display: 'flex',
161+
justifyContent: 'center',
162+
alignItems: 'center',
163+
},
164+
emptyText: {
165+
color: 'white',
166+
fontSize: 20,
167+
textAlign: 'center',
168+
marginTop: 10,
169+
},
170+
taskParent: {
171+
width: '100%',
172+
display: 'flex',
173+
justifyContent: 'flex-start',
174+
alignItems: 'center',
175+
},
176+
});
177+
178+
export default App;

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby File.read(File.join(__dir__, '.ruby-version')).strip
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.3'

__tests__/App-test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
12+
it('renders correctly', () => {
13+
renderer.create(<App />);
14+
});

0 commit comments

Comments
 (0)