Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
manueliglesias committed Nov 28, 2017
0 parents commit f776a2b
Show file tree
Hide file tree
Showing 37 changed files with 2,930 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .babelrc
@@ -0,0 +1,8 @@
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
70 changes: 70 additions & 0 deletions .flowconfig
@@ -0,0 +1,70 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore templates for 'react-native init'
.*/local-cli/templates/.*

; Ignore the website subdir
<PROJECT_ROOT>/node_modules/react-native/website/.*

; Ignore the Dangerfile
<PROJECT_ROOT>/node_modules/react-native/danger/dangerfile.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/node_modules/react-native/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
.*/node_modules/fbemitter/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*

; Ignore misbehaving dev-dependencies
.*/node_modules/reqwest/.*
.*/node_modules/xdl/.*

; Ignore expo dependencies

; Ignore Expo SDK + some of it's dependencies temporarily:
; https://github.com/expo/expo/issues/162
.*/node_modules/expo/src/.*
.*/node_modules/react-native-gesture-handler/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/expo/flow/

[options]
emoji=true

module.system=haste

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-3]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-3]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

unsafe.enable_getters_and_setters=true

[version]
^0.53.0
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,6 @@
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
129 changes: 129 additions & 0 deletions .gitignore
@@ -0,0 +1,129 @@
# Xcode
!**/*.xcodeproj
!**/*.pbxproj
!**/*.xcworkspacedata
!**/*.xcsettings
!**/*.xcscheme
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Gradle
/build/
/RNTester/android/app/build/
/RNTester/android/app/gradle/
/RNTester/android/app/gradlew
/RNTester/android/app/gradlew.bat
/ReactAndroid/build/

# Buck
.buckd
buck-out
/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/
/ReactAndroid/src/main/jni/prebuilt/lib/x86/
/ReactAndroid/src/main/gen

# Android
.idea
.gradle
local.properties
*.iml
/android/

# Node
node_modules
*.log
.nvm
/danger/node_modules/

# OS X
.DS_Store

# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
*.js.meta

/coverage
/third-party

android/app/build/*
android/build/*
ios/build/*
package-lock.json
yarn.lock
aws-exports*
node_modules/
.expo/
npm-debug.*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

1 change: 1 addition & 0 deletions .watchmanconfig
@@ -0,0 +1 @@
{}
140 changes: 140 additions & 0 deletions App.js
@@ -0,0 +1,140 @@
import React from 'react';
import { StyleSheet, Text, View, Button, Platform } from 'react-native';
import AWSAppSyncClient from "aws-appsync";
import { Rehydrated } from 'aws-appsync-react';
import { AUTH_TYPE } from "aws-appsync/dist/link/auth-link";
import { graphql, ApolloProvider, compose } from 'react-apollo';
import * as AWS from 'aws-sdk';
import awsconfig from './aws-exports';
import { StackNavigator } from 'react-navigation';
import AllEvents from './Components/AllEvents'
import AddEvent from "./Components/AddEvent";
import ListEvents from './queries/ListEvents';
import CreateEvent from './queries/CreateEvent';
import DeleteEvent from './queries/DeleteEvent';

console.disableYellowBox = true;

const client = new AWSAppSyncClient({
url: awsconfig.graphqlEndpoint,
region: awsconfig.region,
auth: {type: AUTH_TYPE.API_KEY, apiKey: awsconfig.apiKey}
});

_button = function(navigation){
if(Platform.OS === 'ios'){
return <Button title='Create' color='#ffffff' onPress={()=> navigation.navigate('AddEvent')} />
}else {
return <Button title='Create' onPress={()=> navigation.navigate('AddEvent')} />
}
}

const App = StackNavigator({
AllEvents : {
screen : (props) => <AllEventWithData {...props}/>,
navigationOptions: ({navigation}) => ({
title: 'Upcoming Events',
headerRight: this._button(navigation),
headerStyle:{
backgroundColor:'#42a1f4',
},
headerTitleStyle:{
color: '#ffffff'
},
headerTintColor:'#ffffff'
})
},
AddEvent: {
screen: (props) => <AddEventData {...props} />,
navigationOptions: ({navigation, screenProps}) => {
return {
title: 'Create Event',
headerStyle:{
backgroundColor:'#42a1f4'
},
headerTitleStyle:{
color: '#ffffff'
},
headerTintColor:'#ffffff'
};
}
}
});

const WithProvider = () => (
<ApolloProvider client={client}>
<Rehydrated>
<App />
</Rehydrated>
</ApolloProvider>
);

export default WithProvider;

const AllEventWithData = compose(
graphql(ListEvents, {
options: {
fetchPolicy: 'cache-and-network'
},
props: (props) => ({
events: props.data.listEvents.items,
})
}),
graphql(DeleteEvent, {
options:{
fetchPolicy: 'cache-and-network'
},
props: (props) => ({
onDelete: (event) => {
props.mutate({
variables: { id: event.id },
optimisticResponse: () => ({ deleteEvent: { ...event, __typename: 'Event', comments: {__typename:"CommentConnection",items:[], nextToken:null} } }),
})
}
}),
options: {
refetchQueries: [{ query: ListEvents }],
update: (dataProxy, { data: { deleteEvent: { id } } }) => {
const query = ListEvents;
const data = dataProxy.readQuery({ query });
data.listEvents.items = data.listEvents.items.filter(event => event.id !== id);
dataProxy.writeQuery({ query, data });
}
}
}),
)(AllEvents);

const AddEventData = compose(
graphql(CreateEvent, {
options:{
fetchPolicy: 'cache-and-network'
},
props: (props) => ({
onAdd: event => {
props.mutate({
variables: event,
optimisticResponse: () => ({ createEvent: { ...event, __typename: 'Event', comments: {__typename:"CommentConnection",items:[], nextToken:null} }}),
});
}
}),
options: {
refetchQueries: [{ query: ListEvents }],
update: (dataProxy, { data: { createEvent } }) => {
const query = ListEvents;
const data = dataProxy.readQuery({ query });
data.listEvents.items.push(createEvent);
dataProxy.writeQuery({ query, data });
}
}
})
)(AddEvent);

const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
backgroundColor: '#fff',
alignItems: 'stretch',
justifyContent: 'center',
},
});

0 comments on commit f776a2b

Please sign in to comment.