-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f0c589
commit fde5d40
Showing
13 changed files
with
121 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = function(api) { | ||
api.cache(true); | ||
module.exports = function (api) { | ||
api.cache(true) | ||
return { | ||
presets: ['babel-preset-expo'], | ||
plugins: ["module:react-native-dotenv"] | ||
}; | ||
}; | ||
plugins: ['module:react-native-dotenv'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { registerRootComponent } from 'expo'; | ||
import { registerRootComponent } from 'expo' | ||
|
||
import App from './App'; | ||
import App from './App' | ||
|
||
// registerRootComponent calls AppRegistry.registerComponent('main', () => App); | ||
// It also ensures that whether you load the app in Expo Go or in a native build, | ||
// the environment is set up appropriately | ||
registerRootComponent(App); | ||
registerRootComponent(App) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Learn more https://docs.expo.io/guides/customizing-metro | ||
const { getDefaultConfig } = require('expo/metro-config'); | ||
const { getDefaultConfig } = require('expo/metro-config') | ||
|
||
module.exports = getDefaultConfig(__dirname); | ||
module.exports = getDefaultConfig(__dirname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,11 @@ | ||
import React, { useState } from 'react' | ||
import Meteor, { Mongo } from '@meteorrn/core' | ||
import { Button, Text, TextInput, View, StyleSheet } from 'react-native' | ||
import { inputStyles } from '../styles/inputStyles' | ||
|
||
const Tasks = new Mongo.Collection('tasks') | ||
|
||
export const MyTasks = (props) => { | ||
const [newTask, setNewTask] = useState('') | ||
const { tasks, isLoading } = Meteor.useTracker(() => { | ||
const sub = Meteor.subscribe('myTasks') | ||
|
||
if (props.signedOut) { | ||
sub.stop() | ||
return { tasks: []} | ||
} | ||
|
||
if (!sub.ready()) { | ||
return { tasks: [], isLoading: true } | ||
} | ||
|
||
const tasks = Tasks.find({}, { sort: { createdAt: -1 } }).fetch(); | ||
return { tasks, isLoading: false } | ||
}); | ||
|
||
// add loading message | ||
if (isLoading) { | ||
return ( | ||
<View style={{ alignItems: 'center' }}> | ||
<Text>Loading tasks...</Text> | ||
</View> | ||
) | ||
} | ||
// add task | ||
const addTask = () => { | ||
Meteor.call('saveTask', { title: newTask, checked: false }, (err, res) => { | ||
if (err) { | ||
return console.error(err) | ||
} | ||
setNewTask('') | ||
}) | ||
} | ||
const checkTask = ({ _id }) => { | ||
Meteor.call('saveTask', { _id, checked: true }, (err, res) => { | ||
if (err) { | ||
return console.error(err) | ||
} | ||
}) | ||
} | ||
|
||
// add task | ||
const renderTaskForm = () => { | ||
return ( | ||
<View style={{ flexDirection: 'row', alignItems: 'center' }}> | ||
<TextInput | ||
style={{ ...inputStyles.text, flex: 1, flewGrow: 1 }} | ||
placeholderTextColor="#8a8a8a" | ||
value={newTask} | ||
onChangeText={setNewTask} | ||
placeholder="What do you need to remember?"/> | ||
<Button disabled={newTask.length === 0} title="add" onPress={addTask}/> | ||
</View> | ||
) | ||
} | ||
|
||
// no tasks yet | ||
if (tasks.length === 0) { | ||
return ( | ||
<View style={{ alignItems: 'center' }}> | ||
<Text>No tasks yet</Text> | ||
{renderTaskForm()} | ||
</View> | ||
) | ||
} | ||
|
||
const renderTasks = () => tasks.map((doc) => { | ||
return ( | ||
<View key={doc._id} style={{ flexDirection: 'row', alignItems: 'center' }}> | ||
<Text style={doc.checked ? styles.checked : styles.unchecked}>{doc.title}</Text> | ||
<Button disabled={doc.checked} title="check" onPress={() => checkTask(doc)}/> | ||
</View> | ||
) | ||
}) | ||
|
||
return ( | ||
<View style={{ alignItems: 'center', padding: 25 }}> | ||
{renderTasks()} | ||
{renderTaskForm()} | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
checked: { | ||
textDecorationLine: 'line-through', | ||
textDecorationStyle: 'solid', | ||
flex: 1, | ||
flexGrow: 1 | ||
}, | ||
unchecked: { | ||
fontWeight: 'bold', | ||
flex: 1, | ||
flexGrow: 1 | ||
} | ||
}) | ||
import React from 'react' | ||
import { Text } from 'react-native' | ||
|
||
/** | ||
* Here you can implement the logic to subscribe to your tasks and CRUD them. | ||
* See: https://github.com/meteorrn/sample | ||
* @param props | ||
* @returns {JSX.Element} | ||
* @constructor | ||
*/ | ||
export const MyTasks = () => (<Text>My Tasks not yet implemented</Text>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { createContext } from 'react' | ||
|
||
/** | ||
* Our authentication context | ||
* Our authentication context provides an API for our components | ||
* that allows them to communicate with the servers in a decoupled way. | ||
* @method signIn | ||
* @method signUp | ||
* @method signOut | ||
* @type {React.Context<unknown>} | ||
* @type {React.Context<object>} | ||
*/ | ||
export const AuthContext = createContext() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.