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
4 changes: 4 additions & 0 deletions my-project/.expo-shared/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true,
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
}
14 changes: 14 additions & 0 deletions my-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules/**/*
.expo/*
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/
web-report/

# macOS
.DS_Store
48 changes: 48 additions & 0 deletions my-project/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useState } from 'react';
import { StyleSheet, Text, View, FlatList } from 'react-native';
import Header from './components/header';
import TodoItem from './components/todoItem';

export default function App() {
const [todos, setTodos] = useState([
{ text: 'buy coffee', key: '1' },
{ text: 'create an app', key: '2' },
{ text: 'play on the switch', key: '3' }
]);

const pressHandler = (key) => {
setTodos(prevTodos => {
return prevTodos.filter(todo => todo.key != key);
});
};

return (
<View style={styles.container}>
<Header />
<View style={styles.content}>
{/* add todo form */}
<View style={styles.list}>
<FlatList
data={todos}
renderItem={({ item }) => (
<TodoItem item={item} pressHandler={pressHandler} />
)}
/>
</View>
</View>
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
content: {
padding: 40,
},
list: {
marginTop: 20,
},
});
30 changes: 30 additions & 0 deletions my-project/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"expo": {
"name": "my-project",
"slug": "my-project",
"privacy": "public",
"sdkVersion": "35.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
}
}
Binary file added my-project/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my-project/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions my-project/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
24 changes: 24 additions & 0 deletions my-project/components/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

export default function Header() {
return (
<View style={styles.header}>
<Text style={styles.title}>My Todos</Text>
</View>
);
}

const styles = StyleSheet.create({
header: {
height: 80,
paddingTop: 38,
backgroundColor: 'coral',
},
title: {
textAlign: 'center',
color: '#fff',
fontSize: 20,
fontWeight: 'bold',
}
});
22 changes: 22 additions & 0 deletions my-project/components/todoItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import {StyleSheet, TouchableOpacity, Text} from 'react-native';

export default function TodoItem({ pressHandler, item }) {
return (
<TouchableOpacity onPress={() => pressHandler(item.key)}>
<Text style={styles.item}>{item.text}</Text>
</TouchableOpacity>
)
}

const styles = StyleSheet.create({
item: {
padding: 16,
marginTop: 16,
borderColor: '#bbb',
borderWidth: 1,
borderStyle: "dashed",
borderRadius: 1,
borderRadius: 10,
}
});
Loading