Skip to content

Commit a143a6e

Browse files
committed
aws mobile sample
0 parents  commit a143a6e

File tree

75 files changed

+19832
-0
lines changed

Some content is hidden

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

75 files changed

+19832
-0
lines changed

.amplifyrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"providers": {
3+
"awscloudformation": {
4+
"AuthRoleName": "step1-20181222211409-authRole",
5+
"UnauthRoleArn": "arn:aws:iam::545757968773:role/step1-20181222211409-unauthRole",
6+
"AuthRoleArn": "arn:aws:iam::545757968773:role/step1-20181222211409-authRole",
7+
"Region": "ap-southeast-2",
8+
"DeploymentBucketName": "step1-20181222211409-deployment",
9+
"UnauthRoleName": "step1-20181222211409-unauthRole",
10+
"StackName": "step1-20181222211409",
11+
"StackId": "arn:aws:cloudformation:ap-southeast-2:545757968773:stack/step1-20181222211409/b479c780-05da-11e9-9879-0249d6f7bf88"
12+
}
13+
}
14+
}

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["module:metro-react-native-babel-preset"]
3+
}

.buckconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

.flowconfig

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
21+
22+
[include]
23+
24+
[libs]
25+
node_modules/react-native/Libraries/react-native/react-native-interface.js
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
28+
29+
[options]
30+
emoji=true
31+
32+
esproposal.optional_chaining=enable
33+
esproposal.nullish_coalescing=enable
34+
35+
module.system=haste
36+
module.system.haste.use_name_reducers=true
37+
# get basename
38+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
39+
# strip .js or .js.flow suffix
40+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
41+
# strip .ios suffix
42+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
43+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
44+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
45+
module.system.haste.paths.blacklist=.*/__tests__/.*
46+
module.system.haste.paths.blacklist=.*/__mocks__/.*
47+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
48+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
49+
50+
munge_underscores=true
51+
52+
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'
53+
54+
module.file_ext=.js
55+
module.file_ext=.jsx
56+
module.file_ext=.json
57+
module.file_ext=.native.js
58+
59+
suppress_type=$FlowIssue
60+
suppress_type=$FlowFixMe
61+
suppress_type=$FlowFixMeProps
62+
suppress_type=$FlowFixMeState
63+
64+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
65+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
66+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
67+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
68+
69+
[version]
70+
^0.78.0

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

.graphqlconfig.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
projects:
2+
rnreinvent:
3+
schemaPath: src\graphql\schema.json
4+
includes:
5+
- src\graphql\**\*.js
6+
excludes:
7+
- ./amplify/**
8+
extensions:
9+
amplify:
10+
codeGenTarget: javascript
11+
generatedFileName: ''
12+
docsFilePath: src\graphql
13+
graphQLApiId: p44zpzsx3bft3ogebkmzacpuki
14+
endpoints:
15+
prod: >-
16+
https://x72bi7t4ovdlterojrnechagqi.appsync-api.ap-southeast-2.amazonaws.com/graphql

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

AmplifyInit.jpg

376 KB
Loading

App.js

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import React, {Component} from 'react';
2+
import {Platform, StyleSheet, Text, View} from 'react-native';
3+
import { withAuthenticator } from 'aws-amplify-react-native';
4+
5+
import { API, graphqlOperation } from 'aws-amplify'
6+
import { listCitys as ListCities} from './src/graphql/queries'
7+
import { createCity as CreateCity } from './src/graphql/mutations'
8+
import { ListItem, Button, FormInput } from 'react-native-elements'
9+
10+
class App extends Component<Props> {
11+
state = { cities: [], name: '', country: ''}
12+
13+
async componentDidMount(){
14+
try {
15+
const {data: {listCitys: {items }}} = await API.graphql(graphqlOperation(ListCities))
16+
this.setState({ cities:items })
17+
console.log('cities: ', items)
18+
} catch (err) {
19+
console.log('error fetching data: ', err)
20+
}
21+
}
22+
23+
onChange = (key,value) => {
24+
this.setState({ [key]: value})
25+
}
26+
27+
createCity = async () => {
28+
const city = {
29+
name: this.state.name,
30+
country: this.state.country,
31+
}
32+
const cities = [...this.state.cities, city] //takes the old array and put the new city
33+
this.setState({cities, name:'', country:''})
34+
try {
35+
await API.graphql(graphqlOperation(CreateCity, {input: city}))
36+
console.log('city successfully created!!')
37+
38+
}catch (err){
39+
console.log('error: ', err)
40+
}
41+
}
42+
43+
render() {
44+
return (
45+
<View style={styles.container}>
46+
<FormInput
47+
onChangeText={v => this.onChange('name', v)}
48+
placeholder = 'City Name'
49+
value={this.state.name}
50+
/>
51+
<FormInput
52+
onChangeText={v => this.onChange('country', v)}
53+
placeholder = 'Country'
54+
value={this.state.country}
55+
/>
56+
<Button
57+
style={{margin:20}}
58+
onPress={this.createCity}
59+
title= 'Add City'
60+
backgroundColor='#ffa100'
61+
/>
62+
{
63+
this.state.cities.map((item, i) => (
64+
<ListItem
65+
key={i}
66+
title={item.name}
67+
subtitle={item.description}
68+
/>
69+
))
70+
}
71+
</View>
72+
);
73+
}
74+
}
75+
76+
export default withAuthenticator(App, { includeGreetings: true}) //greetings add logout button sign out button
77+
78+
const styles = StyleSheet.create({
79+
container: {
80+
flex: 1,
81+
backgroundColor: '#F5FCFF',
82+
},
83+
welcome: {
84+
fontSize: 20,
85+
textAlign: 'center',
86+
margin: 10,
87+
},
88+
instructions: {
89+
textAlign: 'center',
90+
color: '#333333',
91+
marginBottom: 5,
92+
},
93+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"providers": {
3+
"awscloudformation": {
4+
"AuthRoleName": "step1-20181222211409-authRole",
5+
"UnauthRoleArn": "arn:aws:iam::545757968773:role/step1-20181222211409-unauthRole",
6+
"AuthRoleArn": "arn:aws:iam::545757968773:role/step1-20181222211409-authRole",
7+
"Region": "ap-southeast-2",
8+
"DeploymentBucketName": "step1-20181222211409-deployment",
9+
"UnauthRoleName": "step1-20181222211409-unauthRole",
10+
"StackName": "step1-20181222211409",
11+
"StackId": "arn:aws:cloudformation:ap-southeast-2:545757968773:stack/step1-20181222211409/b479c780-05da-11e9-9879-0249d6f7bf88"
12+
}
13+
},
14+
"api": {
15+
"rnreinvent": {
16+
"service": "AppSync",
17+
"providerPlugin": "awscloudformation",
18+
"output": {
19+
"securityType": "AMAZON_COGNITO_USER_POOLS",
20+
"GraphQLAPIIdOutput": "p44zpzsx3bft3ogebkmzacpuki",
21+
"GraphQLAPIEndpointOutput": "https://x72bi7t4ovdlterojrnechagqi.appsync-api.ap-southeast-2.amazonaws.com/graphql",
22+
"GraphQLAPIKeyOutput": "da2-foe7rxtlabhfvcrfmfpcat6ebu",
23+
"AuthCognitoUserPoolIdOutput": "ap-southeast-2_eJxm0SUxn",
24+
"AuthCognitoUserPoolNativeClientId": "See UserPool: ap-southeast-2_eJxm0SUxn",
25+
"AuthCognitoUserPoolJSClientId": "See UserPool: ap-southeast-2_eJxm0SUxn"
26+
},
27+
"providerMetadata": {
28+
"s3TemplateURL": "https://s3.amazonaws.com/step1-20181222211409-deployment/amplify-cfn-templates/api/cloudformation-template.json",
29+
"logicalId": "apirnreinvent"
30+
},
31+
"lastPushTimeStamp": "2018-12-23T00:05:21.599Z",
32+
"lastPushDirHash": "k5Pc7Koe4f9GI5k6Za73RuY9QFc="
33+
}
34+
},
35+
"auth": {
36+
"cognitoa8a43d01": {
37+
"service": "Cognito",
38+
"providerPlugin": "awscloudformation",
39+
"providerMetadata": {
40+
"s3TemplateURL": "https://s3.amazonaws.com/step1-20181222211409-deployment/amplify-cfn-templates/auth/cognitoa8a43d01-cloudformation-template.yml",
41+
"logicalId": "authcognitoa8a43d01"
42+
},
43+
"lastPushTimeStamp": "2018-12-23T00:05:21.599Z",
44+
"output": {
45+
"AppClientSecret": "vag2n2n2svfs8q9pmr3r1tde3tefqj98giq02n76h76noj7ol01",
46+
"UserPoolId": "ap-southeast-2_eJxm0SUxn",
47+
"AppClientIDWeb": "1eabgqgi85o27tnr1faptr4ph7",
48+
"AppClientID": "3hcd5eieb70ob2ugi0dd6n1mje",
49+
"IdentityPoolId": "ap-southeast-2:f35586fb-bd38-4a59-b036-185be38d3ab7",
50+
"IdentityPoolName": "cognitoa8a43d01_identitypool_a8a43d01",
51+
"UserPoolName": "cognitoa8a43d01_userpool_a8a43d01"
52+
},
53+
"lastPushDirHash": "lxlr012jI7+amKeY14SJLLWg7I4="
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)