Skip to content

Commit

Permalink
Merge pull request #2 from QuangNguyen1412/dev/wifi_manager
Browse files Browse the repository at this point in the history
Dev/wifi manager
  • Loading branch information
QuangNguyen1412 authored Jan 22, 2020
2 parents d931517 + a57fa58 commit ab88848
Show file tree
Hide file tree
Showing 21 changed files with 1,233 additions and 189 deletions.
28 changes: 9 additions & 19 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,13 @@ import HomeScreen from './src/components/screens/Home/HomeScreen';
import firebase from 'react-native-firebase';
// import {createAppContainer} from 'react-navigation';
// import {createStackNavigator} from 'react-navigation-stack';

export const themeColor = {
bright: '#C5FBD0',
dark: '#325C3C',
error: '#ff0000',
};

// const RootStack = createStackNavigator(
// {
// Home: HomeScreen,
// Login: Login,
// },
// {
// initialRouteName: 'Home',
// },
// );

// const AppContainer = createAppContainer(RootStack);
global.email = "";
export default class App extends React.Component {
constructor() {
super();
Expand Down Expand Up @@ -59,13 +48,14 @@ export default class App extends React.Component {
}
render() {
// console.log('User info ', this.state.user);
return <HomeScreen />;
// return <HomeScreen />;

// if (this.state.user == null) {
// return <Login />;
// } else {
// console.log('Logged in with user ' + this.state.user);
// return <HomeScreen />;
// }
if (this.state.user == null) {
return <Login />;
} else {
console.log('Logged in with user ' + this.state.user.email);
global.email = this.state.user.email;
return <HomeScreen />;
}
}
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ${JAVA_HOME} = D:\Program Files\Android\Android Studio\jre\jre
2. npm install && npm run postinstall
3. The top-level build.gradle version value
buildToolsVersion = "28.0.3"
minSdkVersion = 16
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
Expand Down Expand Up @@ -75,3 +75,6 @@ https://github.com/react-native-community/react-native-permissions/issues/348#is

react-native-qr scanner
https://github.com/moaazsidat/react-native-qrcode-scanner#readme

react-native-wifi-reborn
https://github.com/JuanSeBestia/react-native-wifi-reborn
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
googlePlayServicesVersion = "12.0.1"
Expand Down
Binary file added assets/aqLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/label_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wifi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* @format
*/
// global.XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest;
// global.Blob = null;

import {AppRegistry} from 'react-native';
import App from './App';
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ios": "react-native run-ios",
"test": "jest",
"lint": "eslint .",
"postinstall": "jetifier -r"
"postinstall": "npx jetify"
},
"dependencies": {
"eslint-plugin-react": "^7.12.4",
Expand All @@ -22,6 +22,8 @@
"react-native-qrcode-scanner": "^1.3.1",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "1.0.0-alpha.23",
"react-native-spinkit": "^1.5.0",
"react-native-wifi-reborn": "^2.2.0",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3"
},
Expand Down
16 changes: 16 additions & 0 deletions src/components/Constants/fireStoreConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default class FireStoreConstant {
static collections = {
users: 'users',
devices: 'devices',
mac_addresses: 'mac_addresses',
};

static documentField = {
users: {
devices: 'devices',
email: 'email',
first_name: 'first_name',
last_name: 'last_name',
},
};
}
3 changes: 3 additions & 0 deletions src/components/Constants/globalConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class GlobalConstants {
static SERVER_DOMAIN_NAME = 'https://scottgale.appspot.com/';
}
47 changes: 25 additions & 22 deletions src/components/components/InputField.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {StyleSheet, View, Image, TextInput} from 'react-native';
import {w, h} from '../../api/Dimensions';
import {w, h, totalSize} from '../../api/Dimensions';
const themeColor = {
bright: '#C5FBD0',
dark: '#325C3C',
error: '#ff0000',
};
export default class InputField extends Component {
constructor() {
super();
Expand All @@ -21,16 +26,16 @@ export default class InputField extends Component {
focus = () => this.input.focus();
clear = () => this.input.clear();

textStyleChangeOnState = color => {
textStyleChangeOnState = (borderColor, textColor) => {
return {
width: w(80),
height: h(7),
marginHorizontal: 20,
paddingLeft: 45,
borderRadius: 20,
borderBottomWidth: 1,
color: color,
borderBottomColor: color,
height: h(6),
marginHorizontal: w(6),
paddingLeft: w(11),
borderRadius: totalSize(3),
borderBottomWidth: totalSize(0.15),
color: textColor,
borderBottomColor: borderColor,
};
};

Expand All @@ -39,14 +44,17 @@ export default class InputField extends Component {
<View style={styles.inputWrapper}>
<Image source={this.props.source} style={styles.inlineImg} />
<TextInput
style={this.textStyleChangeOnState(this.props.textFieldBoxColor)}
style={this.textStyleChangeOnState(
this.props.textFieldBoxColor,
this.props.textFieldColor,
)}
placeholder={this.props.placeholder}
secureTextEntry={this.props.secureTextEntry}
autoCorrect={this.props.autoCorrect}
autoCapitalize={this.props.autoCapitalize}
returnKeyType={this.props.returnKeyType}
maxLength={this.props.maxLength}
placeholderTextColor="rgba(255,255,255,0.4)"
placeholderTextColor={this.props.placeholderTextColor}
underlineColorAndroid="transparent"
onSubmitEditing={this.props.onSubmitEditingFunc}
onChangeText={this.props.onChangeTextFunc}
Expand All @@ -67,6 +75,8 @@ InputField.propTypes = {
maxLength: PropTypes.number,
onChangeTextFunc: PropTypes.func,
textFieldBoxColor: PropTypes.string,
textFieldColor: PropTypes.string,
placeholderTextColor: PropTypes.string,
onSubmitEditingFunc: PropTypes.func,
};

Expand All @@ -80,20 +90,13 @@ InputField.defaultProps = {
keyboardType: null,
secureTextEntry: false,
textFieldBoxColor: '#ffffff',
textFieldColor: themeColor.bright,
placeholderTextColor: "rgba(255,255,255,0.4)",
autoCapitalize: 'none',
onChangeTextFunc: () => {},
};

const styles = StyleSheet.create({
input: {
width: w(80),
height: h(7),
marginHorizontal: 20,
paddingLeft: 45,
borderRadius: 20,
color: '#ffffff',
borderBottomWidth: 1,
borderBottomColor: '#ffffff',
},
inputWrapper: {
flex: 1,
},
Expand All @@ -103,6 +106,6 @@ const styles = StyleSheet.create({
width: w(5),
height: h(3),
left: w(10),
top: h(1.7),
top: h(1.5),
},
});
13 changes: 7 additions & 6 deletions src/components/components/Loader.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {ActivityIndicator, StyleSheet, Modal, View} from 'react-native';
import {StyleSheet, Modal, View} from 'react-native';
var Spinner = require('react-native-spinkit');

export default class Loader extends Component {
render() {
console.log('is loading ' + this.props.isLoading);
return (
<Modal
style={styles.modalStyle}
transparent={true}
animationType={'none'}
visible={this.props.isLoading}>
<View style={styles.modalStyle}>
<ActivityIndicator
<Spinner
style={styles.loadingIcon}
isVisible={this.props.isLoading}
size={this.props.indicatorSize}
type={'Bounce'}
color={this.props.indicatorColor}
animating={this.props.isLoading}
/>
</View>
</Modal>
Expand All @@ -26,7 +27,7 @@ export default class Loader extends Component {

Loader.propTypes = {
isLoading: PropTypes.bool.isRequired,
indicatorSize: PropTypes.string,
indicatorSize: PropTypes.number,
indicatorColor: PropTypes.string,
backGroundColor: PropTypes.string,
};
Expand All @@ -40,6 +41,6 @@ const styles = StyleSheet.create({
flex: 1,
alignItems: 'center',
flexDirection: 'column',
backgroundColor: 'rgba(32, 32, 32, 0.3)',
backgroundColor: 'rgba(32, 32, 32, 0.6)',
},
});
23 changes: 23 additions & 0 deletions src/components/fireStoreHelpers/fireStoreHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import FireStoreConstants from '../Constants/fireStoreConstants';
import firebase from 'react-native-firebase';

export default class FireStoreHelper {
static async getUserDevices() {
console.log('getUserDevices');
var devicesData;
const user = await firebase
.firestore()
.collection(FireStoreConstants.collections.users)
.doc(global.email);
console.log('firebase.firestore().runTransaction');
await firebase
.firestore()
.runTransaction(async transaction => {
const doc = await transaction.get(user);
devicesData = await doc.data().devices;
console.log(devicesData);
})
.catch(err => {});
return await Promise.resolve(devicesData);
}
}
Loading

0 comments on commit ab88848

Please sign in to comment.