Skip to content

Commit

Permalink
REVIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedelhanafy00 committed Sep 18, 2020
1 parent cedc8c2 commit fc0d256
Show file tree
Hide file tree
Showing 9 changed files with 3,196 additions and 1,410 deletions.
5 changes: 3 additions & 2 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import App from './src/App.js';
import React from 'react';
// import App from './src/App.js';

export default App;
export default () => <h1>Broo</h1>;
3 changes: 1 addition & 2 deletions config/web/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* @flow */

import React from 'react';
import { AppRegistry } from 'react-native';
import { AppRegistry, Text } from 'react-native';
import App from './App';

AppRegistry.registerComponent('App', () => () => <App />);
AppRegistry.runApplication('App', {
initialProps: {},
rootTag: document.getElementById('root'),
});

6 changes: 3 additions & 3 deletions config/web/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const customizer = (objValue, srcValue) => {
module.exports = mergeWith(
sharedConfig,
{
devtool: 'cheap-module-source-map',
devtool: 'source-map',
entry: {
app: [
// 'webpack-dev-server/client?http://localhost:3000',
Expand All @@ -34,7 +34,7 @@ module.exports = mergeWith(
chunkFilename: '[name].chunk.js',
path: path.resolve('public'),
// devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]',
devtoolModuleFilenameTemplate: info =>
devtoolModuleFilenameTemplate: (info) =>
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
// publicPath: '/',
crossOriginLoading: 'anonymous',
Expand Down Expand Up @@ -81,7 +81,7 @@ module.exports = mergeWith(
},
inline: true,
disableHostCheck: true,
compress: true,
// compress: true,
clientLogLevel: 'none',
overlay: false,
historyApiFallback: {
Expand Down
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"main": "node_modules/expo/AppEntry.js",
"schema_version": "1",
"name": "guchub",
"private": true,
"scripts": {
"start": "yarn web:dev",
"native:dev": "exp start",
"native:run-ios": "exp ios",
"native:run-android": "exp android",
Expand All @@ -29,20 +29,20 @@
"lodash.capitalize": "^4.2.1",
"lodash.get": "^4.4.2",
"mixpanel-browser": "^2.20.0",
"react": "^16.6.3",
"react": "^16.13.1",
"react-apollo": "^2.0.1",
"react-content-loader": "^1.7.3",
"react-dom": "^16.6.3",
"react-dom": "^16.13.1",
"react-lines-ellipsis": "^0.10.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-24.0.0.tar.gz",
"react-native-material-textfield": "^0.12.0",
"react-native": "0.63",
"react-native-material-textfield": "^0.16.1",
"react-native-svg-web": "^1.0.1",
"react-native-web": "^0.1.16",
"react-native-web": "0.13.3",
"react-native-web-linear-gradient": "^1.0.2",
"react-router-dom": "^4.2.2",
"react-router-native": "^4.2.0",
"recharts": "^1.0.0-beta.10",
"styled-components": "^2.4.0"
"styled-components": "^5.2.0"
},
"devDependencies": {
"babel-loader": "^7.1.2",
Expand All @@ -65,7 +65,6 @@
"lodash.mergewith": "^4.6.0",
"prettier": "^1.10.2",
"react-dev-utils": "^5.0.0",
"react-error-overlay": "^3.0.0",
"react-hot-loader": "^4.0.0-beta.17",
"react-transform-hmr": "^1.0.4",
"redbox-react": "^1.5.0",
Expand All @@ -75,7 +74,6 @@
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.9.2",
"webpack-bundle-size-analyzer": "^2.7.0",
"webpack-dashboard": "^1.0.2",
"webpack-dev-server": "^2.9.5",
"webpack-hot-middleware": "^2.21.0",
"webpack-jarvis": "^0.1.1",
Expand Down
36 changes: 18 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import gql from 'graphql-tag';
import { NativeRouter as Router, Route } from 'react-router-native';
import bugsnag from 'bugsnag-js';
import createPlugin from 'bugsnag-react';
import mixpanel from 'mixpanel-browser';
// import mixpanel from 'mixpanel-browser';
import {
About,
Attendance,
Expand All @@ -25,15 +25,15 @@ import { themes } from './constants';

// Move these to setup file
if (process.env.NODE_ENV !== 'development') {
mixpanel.init(process.env.MIXPANEL_KEY);
// mixpanel.init(process.env.MIXPANEL_KEY);
}

const bugsnagClient = bugsnag({
apiKey: process.env.BUGSNAG_KEY,
notifyReleaseStages: ['production'],
releaseStage: process.env.NODE_ENV,
});
const ErrorBoundary = bugsnagClient.use(createPlugin(React));
// const bugsnagClient = bugsnag({
// apiKey: process.env.BUGSNAG_KEY,
// notifyReleaseStages: ['production'],
// releaseStage: process.env.NODE_ENV,
// });
// const ErrorBoundary = bugsnagClient.use(createPlugin(React));

const App = graphql(
gql`
Expand Down Expand Up @@ -71,21 +71,21 @@ const App = graphql(
export default class extends React.Component<null, { client: ?Object }> {
state = { client: null };
async componentDidMount() {
mixpanel.track('App was opened');
// mixpanel.track('App was opened');
this.setState({ client: await setupApollo() });
}
render() {
const client = this.state.client;
return (
<ErrorBoundary>
<View style={{ flex: 1 }}>
{client !== null ? (
<ApolloProvider client={client}>
<App />
</ApolloProvider>
) : null}
</View>
</ErrorBoundary>
// <ErrorBoundary>
<View style={{ flex: 1 }}>
{client !== null ? (
<ApolloProvider client={client}>
<App />
</ApolloProvider>
) : null}
</View>
// </ErrorBoundary>
);
}
}
20 changes: 10 additions & 10 deletions src/screens/Login.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* @flow */

import * as React from 'react';
import { View, Platform, Dimensions } from 'react-native';
import { View, Platform, Dimensions, TextInput as TextField } from 'react-native';
import { withApollo, compose, graphql } from 'react-apollo';
import gql from 'graphql-tag';
import get from 'lodash.get';
import { TextField } from 'react-native-material-textfield';
// import { TextField } from 'react-native-material-textfield';
import styled, { withTheme } from 'styled-components/native';
import mixpanel from 'mixpanel-browser';
// import mixpanel from 'mixpanel-browser';
import { Screen, Waves, Button, Toast } from '../components';
import { saveCredentials } from '../utils';

Expand Down Expand Up @@ -59,8 +59,8 @@ class Login extends React.PureComponent<Props, State> {
const token = get(response, 'data.login.token');

if (isAuthorized) {
mixpanel.register({ username });
mixpanel.track('Logged in');
// mixpanel.register({ username });
// mixpanel.track('Logged in');
await Promise.all([
saveCredentials({
token,
Expand Down Expand Up @@ -113,12 +113,12 @@ class Login extends React.PureComponent<Props, State> {
<Toast shown={error !== null} handleHiding={this._hideToast} text={error || ''} />
<Form onSubmit={this._handleSubmit} style={{ minWidth: 300, zIndex: 10 }}>
<TextInput
onChangeText={text => this.setState({ username: text })}
onChangeText={(text) => this.setState({ username: text })}
value={username}
label="Username"
/>
<TextInput
onChangeText={text => this.setState({ password: text })}
onChangeText={(text) => this.setState({ password: text })}
value={password}
label="Password"
containerStyle={{ marginBottom: 20 }}
Expand All @@ -141,21 +141,21 @@ class Login extends React.PureComponent<Props, State> {
</Form>
</Screen.Content>
</Screen>
{windowWidth > 600 || Platform.OS !== 'web' ? <Waves /> : null}
{/* {windowWidth > 600 || Platform.OS !== 'web' ? <Waves /> : null} */}
</View>
);
}
}

const Form = props => (Platform.OS === 'web' ? <form {...props} /> : <View {...props} />);
const Form = (props) => (Platform.OS === 'web' ? <form {...props} /> : <View {...props} />);

const Logo = styled.Image`
width: 120;
height: 120;
margin-bottom: 20;
`;

const TextInput = withTheme(props => (
const TextInput = withTheme((props) => (
<TextField
tintColor="rgba(98, 205, 199, 1)"
textColor={props.theme.primaryTextColor}
Expand Down
20 changes: 10 additions & 10 deletions src/utils/cache.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* @flow */

import { AsyncStorage } from 'react-native';
// import { localStorage } from 'react-native';

const TOKEN_KEY = 'guc-token';
const DEMOUSER_KEY = 'guc-is-demo-user';
const SCHEMA_VERSION_KEY = 'apollo-schema-version';
const SETTINGS_KEY = 'guc-settings';

/* Apollo Schema */
const saveToken = (token: string) => AsyncStorage.setItem(TOKEN_KEY, token);
const getToken = () => AsyncStorage.getItem(TOKEN_KEY);
const saveToken = (token: string) => localStorage.setItem(TOKEN_KEY, token);
const getToken = () => localStorage.getItem(TOKEN_KEY);

const saveDemoUser = (isDemoUser: boolean) => AsyncStorage.setItem(DEMOUSER_KEY, isDemoUser);
const saveDemoUser = (isDemoUser: boolean) => localStorage.setItem(DEMOUSER_KEY, isDemoUser);
const getDemoUser = async (): Promise<boolean> =>
(await AsyncStorage.getItem(DEMOUSER_KEY)) === 'true';
(await localStorage.getItem(DEMOUSER_KEY)) === 'true';

// AsyncStorage multiset doesn't work for some reason
// localStorage multiset doesn't work for some reason
export const saveCredentials = ({
token,
isDemoUser = false,
Expand All @@ -33,9 +33,9 @@ export const getCredentials = async (): Promise<{
};

/* Apollo Schema */
export const getSchemaVersion = () => AsyncStorage.getItem(SCHEMA_VERSION_KEY);
export const getSchemaVersion = () => localStorage.getItem(SCHEMA_VERSION_KEY);
export const saveSchemaVersion = (schemaVersion: string) =>
AsyncStorage.setItem(SCHEMA_VERSION_KEY, schemaVersion);
localStorage.setItem(SCHEMA_VERSION_KEY, schemaVersion);

/* Settings */
type Settings = {
Expand All @@ -50,11 +50,11 @@ const defaultSettings = {
export const updateSettings = async (settings: Settings = defaultSettings) => {
const oldSettings = await getSettings();
const stringifiedSettings = JSON.stringify({ ...oldSettings, ...settings });
AsyncStorage.setItem(SETTINGS_KEY, stringifiedSettings);
localStorage.setItem(SETTINGS_KEY, stringifiedSettings);
};

export const getSettings = async (): Promise<Settings> => {
const settings = await AsyncStorage.getItem(SETTINGS_KEY);
const settings = await localStorage.getItem(SETTINGS_KEY);

if (settings) return JSON.parse(settings);
return defaultSettings;
Expand Down
5 changes: 2 additions & 3 deletions src/utils/setupApollo.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/* @flow */

import { AsyncStorage, Platform } from 'react-native';
import { Platform } from 'react-native';
import { ApolloClient } from 'apollo-client';
import { HttpLink, InMemoryCache, ApolloLink } from 'apollo-client-preset';
import { CachePersistor } from 'apollo-cache-persist';
import { generateClientStateLink, getSchemaVersion, saveSchemaVersion } from './';
import packageJson from '../../package.json';

const currentSchemaVersion = packageJson.schema_version;

const cache = new InMemoryCache();

const persistor = new CachePersistor({
cache,
storage: AsyncStorage,
storage: localStorage,
trigger: Platform.OS === 'web' ? 'write' : 'background',
});

Expand Down
Loading

0 comments on commit fc0d256

Please sign in to comment.