Skip to content

Commit

Permalink
feat: add parse to project!
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Jul 12, 2020
1 parent 59d8040 commit 9e4e0de
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ web-build/
# macOS
.DS_Store*
.env*
environment.js
37 changes: 22 additions & 15 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import * as React from 'react';
import React from 'react';
import {
Platform, StatusBar, StyleSheet, View
} from 'react-native';

import useCachedResources from './modules/cached-resources/useCachedResources';
import BottomTabNavigator from './navigation/BottomTabNavigator';
import LinkingConfiguration from './navigation/LinkingConfiguration';
import { initialize } from './services/parse/auth'

const Stack = createStackNavigator();

export default function App() {
const isLoadingComplete = useCachedResources();
export default class App extends React.Component {
constructor(props) {
super(props);
initialize();
}
render() {
// const isLoadingComplete = useCachedResources();

if (!isLoadingComplete) {
return null;
// if (!isLoadingComplete) {
// return null;
// }
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="dark-content" />}
<NavigationContainer linking={LinkingConfiguration}>
<Stack.Navigator>
<Stack.Screen name="Root" component={BottomTabNavigator} />
</Stack.Navigator>
</NavigationContainer>
</View>
);
}
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="dark-content" />}
<NavigationContainer linking={LinkingConfiguration}>
<Stack.Navigator>
<Stack.Screen name="Root" component={BottomTabNavigator} />
</Stack.Navigator>
</NavigationContainer>
</View>
);
}

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion components/TabBarIcon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ionicons } from '@expo/vector-icons';
import * as React from 'react';

import Colors from '../constants/Colors';
import Colors from '../constants/style/Colors';

export default function TabBarIcon(props) {
const { name, focused } = props;
Expand Down
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions environment-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Constants from "expo-constants";

const ENV = {
dev: {
parseAppId: "exampleAppId",
parseJavascriptKey: "exampleJavascriptKey",
parseServerUrl: "https://parseapi.back4app.com/",
parseMasterKey: "exampleMasterKey"
},
staging: {
parseAppId: "exampleAppId",
parseJavascriptKey: "exampleJavascriptKey",
parseServerUrl: "https://parseapi.back4app.com/",
parseMasterKey: "exampleMasterKey"
},
prod: {
parseAppId: "exampleAppId",
parseJavascriptKey: "exampleJavascriptKey",
parseServerUrl: "https://parseapi.back4app.com/",
parseMasterKey: "exampleMasterKey"
}
};

const getEnvVars = (env = Constants.manifest.releaseChannel) => {
// What is __DEV__ ?
// This variable is set to true when react-native is running in Dev mode.
// __DEV__ is true when run locally, but false when published.
if (__DEV__) {
return ENV.dev;
} else if (env === 'staging') {
return ENV.staging;
} else if (env === 'prod') {
return ENV.prod;
}
};

export default getEnvVars;
45 changes: 42 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "env-cmd -f .env.dev expo start",
"start": "expo start",
"reinstall": "rm package-lock.json && rm -rf node_modules/ && npm install",
"android": "expo start --android",
"ios": "expo start --ios",
Expand All @@ -11,7 +11,8 @@
"test-run": "jest --forceExit --detectOpenHandles && codecov",
"lint": "./node_modules/.bin/eslint '**/*.{js,jsx}' --quiet",
"lint-fix": "./node_modules/.bin/eslint '**/*.{js,jsx}' --fix",
"publish": "expo publish && expo build:ios && expo build:android"
"publish-staging": "expo publish --release-channel staging && expo build:ios --release-channel staging && expo build:android --release-channel staging",
"publish-prod": "expo publish --release-channel prod && expo build:ios --release-channel prod && expo build:android --release-channel prod"
},
"jest": {
"preset": "jest-expo",
Expand All @@ -31,6 +32,7 @@
"expo-linking": "1.0.1",
"expo-splash-screen": "0.2.3",
"expo-web-browser": "8.2.1",
"parse": "2.14.0",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
Expand Down
9 changes: 6 additions & 3 deletions screens/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';

import { retrieveHelloFunction } from '../services/parse/crud'


export default function HomeScreen() {
return (
Expand All @@ -19,9 +21,10 @@ export default function HomeScreen() {
}

function handleHelpPress() {
WebBrowser.openBrowserAsync(
'https://docs.expo.io/versions/latest/get-started/create-a-new-app/#making-your-first-change'
);
// WebBrowser.openBrowserAsync(
// 'https://docs.expo.io/versions/latest/get-started/create-a-new-app/#making-your-first-change'
// );
retrieveHelloFunction()
}

HomeScreen.navigationOptions = {
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions services/parse/auth/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Parse } from 'parse/react-native';
import { AsyncStorage } from "react-native";
import getEnvVars from '../../../environment';

function initialize() {
const { parseAppId, parseJavascriptKey, parseServerUrl } = getEnvVars();

Parse.setAsyncStorage(AsyncStorage);
Parse.initialize(parseAppId, parseJavascriptKey);
Parse.serverURL = parseServerUrl;
console.log(`Initialize Parse with App ID:${parseAppId}, Javascript Key: ${parseJavascriptKey}`)

}

export { initialize }
12 changes: 12 additions & 0 deletions services/parse/crud/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Parse } from 'parse/react-native';

function retrieveHelloFunction() {
Parse.Cloud.run(`hello`).then((result) => {
console.log(result);
return result;

})
}


export { retrieveHelloFunction }
Empty file added services/twilio/index.js
Empty file.

0 comments on commit 9e4e0de

Please sign in to comment.