Commit 9c6f7442 by Tonk

Merge branch 'injectedFirebase' into ejectedExpo

parents 7bf59c85 a3e7d977
...@@ -13,23 +13,160 @@ import rootStore from './reduxStore'; ...@@ -13,23 +13,160 @@ import rootStore from './reduxStore';
import { Root } from 'native-base'; import { Root } from 'native-base';
import { fixTimerWarning } from './utils/fixTimerWarning'; import { fixTimerWarning } from './utils/fixTimerWarning';
// import { default as customMapping } from './custom-mapping.json'; // import { default as customMapping } from './custom-mapping.json';
import { fireStore } from './firebase';
console.disableYellowBox = true; console.disableYellowBox = true;
const Application = () => { const Application = () => {
useEffect(() => { useEffect(() => {
fixTimerWarning(); fixTimerWarning();
}, []); }, []);
return ( return (
<ApplicationProvider mapping={mapping} theme={myTheme}> <Root>
<Provider store={rootStore}> <ApplicationProvider mapping={mapping} theme={myTheme}>
<Root> <Provider store={rootStore}>
<AppContainer /> <AppContainer />
</Root> </Provider>
</Provider> </ApplicationProvider>
</ApplicationProvider> </Root>
); );
}; };
export default Application; export default Application;
const createMockData = () => {
// const deviceId = 'iYs6Th9Pkg1vTEDIyPa5';
const deviceId = '8998c7d5-4476-41d9-81c6-9ef2dbac2505';
const batch = fireStore.batch();
/*------------------------------*/
const mainRef = fireStore.doc(`device/${deviceId}`);
batch.set(mainRef, main);
for (let i = 1; i <= 5; i++) {
let mainTimerRef = fireStore
.collection('device')
.doc(deviceId)
.collection('Timers')
.doc();
batch.set(mainTimerRef, timer);
}
/*------------------------------*/
for (let i = 1; i <= 4; i++) {
const mcbLinks = {
type: 'mcbLink',
name: `MCB Link ${i}`,
description: `description ${i}`,
};
let mcbLinksRef = fireStore
.collection('device')
.doc(deviceId)
.collection('mcbLinks')
.doc(i.toString());
for (let z = 1; z <= 5; z++) {
let mcbLinkTimerRef = fireStore
.collection('device')
.doc(deviceId)
.collection('mcbLinks')
.doc(i.toString())
.collection('Timers')
.doc();
batch.set(mcbLinkTimerRef, timer);
}
batch.set(mcbLinksRef, mcbLinks);
}
/*------------------------------*/
for (let i = 1; i <= 4; i++) {
for (let j = 1; j <= 8; j++) {
let subBreakers = {
type: 'subBreaker',
name: `Sub Breaker ${j}`,
description: `description ${j}`,
};
let subBreakersRef = fireStore
.collection('device')
.doc(deviceId)
.collection('mcbLinks')
.doc(i.toString())
.collection('subBreakers')
.doc(j.toString());
for (let z = 1; z <= 5; z++) {
let subBreakerTimerRef = fireStore
.collection('device')
.doc(deviceId)
.collection('mcbLinks')
.doc(i.toString())
.collection('subBreakers')
.doc(j.toString())
.collection('Timers')
.doc();
batch.set(subBreakerTimerRef, timer);
}
batch.set(subBreakersRef, subBreakers);
}
}
batch.commit();
};
// const mcbLinkId = 1;
// const subBreakerId = 2;
const main = {
type: 'main',
name: 'Main',
description: 'description',
notification: true,
rcbo: 10,
};
const timer = {
isActive: false,
isPowerOn: false,
timer: 0,
repeatOn: [
{ id: 0, isRepeat: false, day: 'Sunday' },
{ id: 1, isRepeat: false, day: 'Monday' },
{ id: 2, isRepeat: false, day: 'Tuesday' },
{ id: 3, isRepeat: false, day: 'Wednesday' },
{ id: 4, isRepeat: false, day: 'Thursday' },
{ id: 5, isRepeat: false, day: 'Friday' },
{ id: 6, isRepeat: false, day: 'Saturday' },
],
};
// const mcbLinks = {
// // id: mcbLinkId,
// type: 'mcbLink',
// name: `MCB Link ${mcbLinkId}`,
// description: `description ${mcbLinkId}`,
// };
// const subBreakers = {
// // id: subBreakerId,
// type: 'subBreaker',
// name: `Sub Breaker ${subBreakerId}`,
// description: `description ${subBreakerId}`,
// };
// const timer = {
// isActive: false,
// isPowerOn: false,
// timer: 1566378008,
// repeatOn: [
// { id: 0, isRepeat: false, day: 'Sunday' },
// { id: 1, isRepeat: false, day: 'Monday' },
// { id: 2, isRepeat: false, day: 'Tuesday' },
// { id: 3, isRepeat: false, day: 'Wednesday' },
// { id: 4, isRepeat: false, day: 'Thursday' },
// { id: 5, isRepeat: false, day: 'Friday' },
// { id: 6, isRepeat: false, day: 'Saturday' },
// ],
// };
import React from 'react'; import React from 'react';
import { Platform } from 'react-native';
import { Icon, View } from 'native-base'; import { Icon, View } from 'native-base';
import { color } from './constants/Styles'; import { color } from './constants/Styles';
import { import {
...@@ -16,8 +17,8 @@ import SmartMeterDetailScreen from './screens/Private/SmartMeterScreen/SmartMete ...@@ -16,8 +17,8 @@ import SmartMeterDetailScreen from './screens/Private/SmartMeterScreen/SmartMete
import CameraScreen from './screens/Private/CameraScreen'; import CameraScreen from './screens/Private/CameraScreen';
// Timer // Timer
import TimerScreen from './screens/Private/TimerScreen/TimerScreen'; import TimerScreenAndriod from './screens/Private/TimerScreen/TimerScreen.andriod';
import TimerScreenIos from './screens/Private/TimerScreen/TimerScreen.ios';
// Setting // Setting
import SettingScreen from './screens/Private/SettingScreen/SettingScreen'; import SettingScreen from './screens/Private/SettingScreen/SettingScreen';
import Setting from './screens/Private/SettingScreen/Setting'; import Setting from './screens/Private/SettingScreen/Setting';
...@@ -48,11 +49,24 @@ const defaultNavigationOptions = { ...@@ -48,11 +49,24 @@ const defaultNavigationOptions = {
fontSize: 18, fontSize: 18,
fontFamily: 'Avenir-Roman', fontFamily: 'Avenir-Roman',
}, },
tabBarOptions: {
keyboardHidesTabBar: true,
},
}; };
const SmartMeterStack = createStackNavigator( const HomeStack = createStackNavigator(
{ {
SmartMeter: SmartMeterScreen, SmartMeter: SmartMeterScreen,
},
{
headerLayoutPreset: 'center',
defaultNavigationOptions,
}
);
const SmartMeterStack = createStackNavigator(
{
// SmartMeter: SmartMeterScreen,
SmartMeterDetail: SmartMeterDetailScreen, SmartMeterDetail: SmartMeterDetailScreen,
}, },
{ {
...@@ -77,7 +91,7 @@ const CameraStack = createStackNavigator( ...@@ -77,7 +91,7 @@ const CameraStack = createStackNavigator(
const TimerStack = createStackNavigator( const TimerStack = createStackNavigator(
{ {
Timer: TimerScreen, Timer: Platform.OS === 'android' ? TimerScreenAndriod : TimerScreenIos,
}, },
{ {
headerLayoutPreset: 'center', headerLayoutPreset: 'center',
...@@ -220,6 +234,7 @@ const WithBottomTabStack = createBottomTabNavigator( ...@@ -220,6 +234,7 @@ const WithBottomTabStack = createBottomTabNavigator(
const MainStack = createStackNavigator( const MainStack = createStackNavigator(
{ {
Home: HomeStack,
WithBottomTab: WithBottomTabStack, WithBottomTab: WithBottomTabStack,
Camera: CameraStack, Camera: CameraStack,
}, },
......
...@@ -16,47 +16,64 @@ const Row = ({ data }) => { ...@@ -16,47 +16,64 @@ const Row = ({ data }) => {
<RectButton style={styles.rectButton} onPress={() => alert('hello ' + data.name)}> <RectButton style={styles.rectButton} onPress={() => alert('hello ' + data.name)}>
<View style={{ flexDirection: 'row', paddingVertical: 5 }}> <View style={{ flexDirection: 'row', paddingVertical: 5 }}>
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<Text style={[theme.title, { color: data.active ? color.black : color.grey }]}> <View style={{ flexDirection: 'row', alignItems: 'flex-end', justifyContent: 'space-between' }}>
{format(data.time, 'h:mm')}{' '} <Text style={[theme.title, { color: data.isActive ? color.black : color.grey, fontSize: 18 }]}>
{format(data.timer, 'hh:mm')}
</Text>
<Text <Text
style={[ style={[
theme.description, theme.description,
theme.textDark, theme.textDark,
{ color: data.active ? color.black : color.grey }, {
color: data.isActive ? color.black : color.grey,
fontSize: 12,
fontWeight: 'normal',
},
]} ]}
> >
{format(data.time, 'A')} {format(data.timer, 'A')}
</Text> </Text>
</Text> </View>
<View style={theme.rowContainer}> <View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
{data.repeatDays.map((item, index) => ( {data.repeatOn.map((el, index) => (
<Text <Text
key={index} key={index}
style={[ style={[
theme.description, theme.description,
{ {
color: data.active color: data.isActive
? item.isRepeat ? el.isRepeat
? color.primary ? color.primary
: color.grey : color.grey
: item.isRepeat : el.isRepeat
? color.darkGrey ? color.darkGrey
: color.grey, : color.grey,
fontSize: 12,
}, },
]} ]}
> >
{item.day}{' '} {el.day.substr(0, 1)}
</Text> </Text>
))} ))}
</View> </View>
</View> </View>
<View style={{ flex: 1 }}> <View style={{ flex: 2, paddingHorizontal: 35 }}>
<Text <Text
style={[theme.title, { fontWeight: 'normal', color: data.active ? color.black : color.grey }]} style={[
theme.title,
{ fontWeight: 'normal', color: data.isActive ? color.black : color.grey, fontSize: 18 },
]}
> >
{data.name} {data.name}
</Text> </Text>
<Text style={theme.description}>{data.active ? 'Active' : 'Inactive'} </Text> <Text style={[theme.description, { fontSize: 12 }]}>
{data.type === 'main'
? 'Main'
: data.type === 'mcbLink'
? `MCB LINK${data.id}`
: `MCB Link${data.mcbLinkId} | Sub Breaker${data.id}`}
</Text>
</View> </View>
<View style={{ flex: 1, alignItems: 'flex-end' }}> <View style={{ flex: 1, alignItems: 'flex-end' }}>
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
...@@ -64,14 +81,19 @@ const Row = ({ data }) => { ...@@ -64,14 +81,19 @@ const Row = ({ data }) => {
style={[ style={[
theme.title, theme.title,
{ {
color: data.active ? (data.power ? color.success : color.primary) : color.grey, color: data.isActive
? data.isPowerOn
? color.success
: color.primary
: color.grey,
fontWeight: 'normal', fontWeight: 'normal',
fontSize: 16,
}, },
]} ]}
> >
{data.power ? 'ON' : 'OFF'} {data.isPowerOn ? 'ON' : 'OFF'}
</Text> </Text>
<Text style={theme.description}>Power</Text> <Text style={[theme.description, { fontSize: 12 }]}>Power</Text>
</View> </View>
</View> </View>
</View> </View>
...@@ -84,6 +106,7 @@ class SwipeableRow extends Component { ...@@ -84,6 +106,7 @@ class SwipeableRow extends Component {
state = { state = {
isVisible: false, isVisible: false,
}; };
renderRightActions = (progress, dragX) => { renderRightActions = (progress, dragX) => {
const scale = dragX.interpolate({ const scale = dragX.interpolate({
inputRange: [-80, 0], inputRange: [-80, 0],
...@@ -126,7 +149,6 @@ class SwipeableRow extends Component { ...@@ -126,7 +149,6 @@ class SwipeableRow extends Component {
); );
}; };
updateRef = instance => { updateRef = instance => {
// this._swipeableRow = instance;
this.swipeInstance = instance; this.swipeInstance = instance;
}; };
cfDelete = () => { cfDelete = () => {
...@@ -154,7 +176,7 @@ class SwipeableRow extends Component { ...@@ -154,7 +176,7 @@ class SwipeableRow extends Component {
containerStyle={{ backgroundColor: color.primary }} containerStyle={{ backgroundColor: color.primary }}
onSwipeableWillOpen={this._onSwipeOpen} onSwipeableWillOpen={this._onSwipeOpen}
> >
<Row data={this.props.item} /> <Row data={this.props.item} index={this.props.index} />
</Swipeable> </Swipeable>
); );
} }
......
...@@ -60,7 +60,7 @@ export const theme = StyleSheet.create({ ...@@ -60,7 +60,7 @@ export const theme = StyleSheet.create({
color: color.grey, color: color.grey,
}, },
description: { description: {
fontSize: 14, fontSize: 12,
fontFamily: 'Avenir-Roman', fontFamily: 'Avenir-Roman',
color: color.grey, color: color.grey,
}, },
......
...@@ -14,15 +14,16 @@ ...@@ -14,15 +14,16 @@
"@react-native-community/async-storage": "^1.6.1", "@react-native-community/async-storage": "^1.6.1",
"date-fns": "^1.30.1", "date-fns": "^1.30.1",
"firebase": "^6.3.5", "firebase": "^6.3.5",
"lodash.set": "^4.3.2", "lodash": "^4.17.15",
"lodash.defaults": "^4.2.0",
"lodash.flatten": "^4.4.0",
"native-base": "^2.12.2", "native-base": "^2.12.2",
"react": "^16.9.0", "react": "^16.9.0",
"react-addons-update": "^15.6.2",
"react-native": "^0.60.4", "react-native": "^0.60.4",
"react-native-barcode-mask": "^1.0.5", "react-native-barcode-mask": "^1.0.5",
"react-native-calendar-picker": "^6.0.1", "react-native-calendar-picker": "^6.0.1",
"react-native-camera": "^2.11.1", "react-native-camera": "^2.11.1",
"react-native-date-picker": "^2.5.1", "react-native-date-picker": "^2.7.0",
"react-native-elements": "^1.1.0", "react-native-elements": "^1.1.0",
"react-native-gesture-handler": "^1.3.0", "react-native-gesture-handler": "^1.3.0",
"react-native-linear-gradient": "^2.5.4", "react-native-linear-gradient": "^2.5.4",
......
import { fireStore } from '../../firebase';
// export const GET_ALL_DEVICE_ID = 'GET_ALL_DEVICE_ID';
export const GET_ALL_DEVICE_INFO = 'GET_ALL_DEVICE_INFO';
// export const getAllDeviceIdAction = allDeviceId => ({
// type: GET_ALL_DEVICE_ID,
// allDeviceId,
// });
export const getAllDeviceInfoAction = allDeviceInfo => ({
type: GET_ALL_DEVICE_INFO,
allDeviceInfo,
});
// export const getAllDeviceId = () => async (dispatch, getState) => {
// const { currentUserReducer } = getState();
// const currentUserId = currentUserReducer.uid;
// const allOwnerDeviceId = await fireStore
// .collection('owner')
// .doc(currentUserId)
// .get();
// const allSharingDeviceId = await fireStore
// .collection('sharing')
// .doc(currentUserId)
// .get();
// const allDeviceId = Object.keys({ ...allOwnerDeviceId.data(), ...allSharingDeviceId.data() });
// return dispatch(getAllDeviceIdAction(allDeviceId));
// };
export const getAllDeviceInfo = () => async (dispatch, getState) => {
const { currentUserReducer } = getState();
const currentUserId = currentUserReducer.uid;
try {
const allOwnerDevice = await fireStore
.collection('owner')
.doc(currentUserId)
.get();
const allSharingDevice = await fireStore
.collection('sharing')
.doc(currentUserId)
.get();
const allOwnerDeviceId = Object.keys({ ...allOwnerDevice.data() });
const allSharingDeviceId = Object.keys({ ...allSharingDevice.data() });
let alldeviceInfo = [];
await allOwnerDeviceId.map((deviceId, index) => {
fireStore
.collection('device')
.doc(deviceId)
.get()
.then(deviceInfo =>
alldeviceInfo.push(Object.assign(deviceInfo.data(), { deviceId, isSharing: false }))
);
});
await allSharingDeviceId.map((deviceId, index) => {
fireStore
.collection('device')
.doc(deviceId)
.get()
.then(deviceInfo =>
alldeviceInfo.push(Object.assign(deviceInfo.data(), { deviceId, isSharing: true }))
);
});
const allDataInfo = await alldeviceInfo;
console.log(allDataInfo);
return dispatch(getAllDeviceInfoAction(allDataInfo));
} catch (error) {
alert(error);
}
};
import { fireStore } from '../../firebase';
export const GET_ALL_MAIN_DEVICE_INFO = 'GET_ALL_MAIN_DEVICE_INFO';
export const GET_ALL_MAIN_DEVICE_INFO_LOADING = 'GET_ALL_MAIN_DEVICE_INFO_LOADING';
export const GET_ALL_MAIN_DEVICE_INFO_ERROR = 'GET_ALL_MAIN_DEVICE_INFO_ERROR';
export const getAllMainDeviceInfoAction = allMainDeviceInfo => ({
type: GET_ALL_MAIN_DEVICE_INFO,
allMainDeviceInfo,
});
export const loadingAction = bool => ({
type: GET_ALL_MAIN_DEVICE_INFO_LOADING,
isLoading: bool,
});
export const errorAction = error => ({
type: GET_ALL_MAIN_DEVICE_INFO_ERROR,
error,
});
export const getAllMainDeviceInfo = () => async (dispatch, getState) => {
const { currentUserReducer } = getState();
const currentUserId = currentUserReducer.uid;
try {
dispatch(loadingAction(true));
const allOwnerDevice = await fireStore
.collection('owner')
.doc(currentUserId)
.get();
const allSharingDevice = await fireStore
.collection('sharing')
.doc(currentUserId)
.get();
const allOwnerDeviceId = Object.keys({ ...allOwnerDevice.data() });
const allSharingDeviceId = Object.keys({ ...allSharingDevice.data() });
let allMainDeviceInfoData = [];
allOwnerDeviceId.map(async (deviceId, index) => {
let ownerDeviceInfo = await fireStore
.collection('device')
.doc(deviceId)
.get();
let ownerDeviceInfoData = await ownerDeviceInfo.data();
// let { timers, ...rest } = ownerDeviceInfoData;
allMainDeviceInfoData.push(Object.assign(ownerDeviceInfoData, { deviceId, isSharing: false }));
});
allSharingDeviceId.map(async (deviceId, index) => {
let sharingDeviceInfo = await fireStore
.collection('device')
.doc(deviceId)
.get();
let sharingDeviceInfoData = await sharingDeviceInfo.data();
// let { timers, ...rest } = sharingDeviceInfoData;
allMainDeviceInfoData.push(Object.assign(sharingDeviceInfoData, { deviceId, isSharing: true }));
});
// console.log('allMainDeviceInfoData', allMainDeviceInfoData);
dispatch(getAllMainDeviceInfoAction(allMainDeviceInfoData));
} catch (error) {
dispatch(errorAction(error.message || error || 'Error'));
}
dispatch(loadingAction(false));
};
import app from '../../firebase';
export const GET_CURRENT_USER = 'GET_CURRENT_USER'; export const GET_CURRENT_USER = 'GET_CURRENT_USER';
export const getCurrentUserAction = (displayName, email, emailVerified, phoneNumber, uid) => ({ export const getCurrentUserAction = (displayName, email, emailVerified, phoneNumber, uid) => ({
...@@ -11,7 +9,7 @@ export const getCurrentUserAction = (displayName, email, emailVerified, phoneNum ...@@ -11,7 +9,7 @@ export const getCurrentUserAction = (displayName, email, emailVerified, phoneNum
uid, uid,
}); });
export const getCurrentUser = () => async dispatch => { export const getCurrentUser = user => dispatch => {
const { displayName, email, emailVerified, phoneNumber, uid } = await app.auth().currentUser; const { displayName, email, emailVerified, phoneNumber, uid } = user;
return dispatch(getCurrentUserAction(displayName, email, emailVerified, phoneNumber, uid)); dispatch(getCurrentUserAction(displayName, email, emailVerified, phoneNumber, uid));
}; };
export const SET_CURRENT_SELECTED = 'SET_CURRENT_SELECTED'; export const SET_CURRENT_SELECTED = 'SET_CURRENT_SELECTED';
export const setCurrentSelectedAction = selectedDeviceId => ({ export const setCurrentSelectedAction = selectedDeviceId => ({
type: GET_CURRENT_SELECTED, type: SET_CURRENT_SELECTED,
selectedDeviceId, selectedDeviceId,
}); });
export const setCurrentSelected = DeviceId => async dispatch => { export const setCurrentSelected = deviceId => dispatch => {
return dispatch(setCurrentSelectedAction(DeviceId)); dispatch(setCurrentSelectedAction(deviceId));
}; };
import AsyncStorage from '@react-native-community/async-storage';
export const getToken = token => ({
type: 'GET_TOKEN',
token,
});
export const saveToken = token => ({
type: 'SAVE_TOKEN',
token,
});
export const removeToken = () => ({
type: 'REMOVE_TOKEN',
});
export const loading = bool => ({
type: 'LOADING',
isLoading: bool,
});
export const error = error => ({
type: 'ERROR',
error,
});
export const getUserToken = () => async dispatch => {
try {
await AsyncStorage.getItem('userToken');
dispatch(loading(false));
dispatch(getToken(data));
} catch (err) {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
}
};
export const saveUserToken = data => async dispatch => {
try {
await AsyncStorage.setItem('userToken', '');
dispatch(loading(false));
dispatch(saveToken(data));
} catch (err) {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
}
};
export const removeUserToken = () => async dispatch => {
try {
await AsyncStorage.removeItem('userToken');
dispatch(loading(false));
dispatch(removeToken(data));
} catch (err) {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
}
};
import { fireStore } from '../../firebase';
import _ from 'lodash';
export const GET_TIMERS = 'GET_TIMERS';
export const GET_TIMERS_LOADING = 'GET_TIMERS_LOADING';
export const GET_TIMERS_ERROR = 'GET_TIMERS_ERROR';
export const GET_EXISTED_DATA = 'GET_EXISTED_DATA';
export const GET_MAIN_DEVICE_TIMERS = 'GET_MAIN_DEVICE_TIMERS';
export const GET_MCBLINKS_TIMERS = 'GET_MCBLINKS_TIMERS';
export const GET_SUBBREAKERS_TIMERS = 'GET_SUBBREAKERS_TIMERS';
export const getTimersAction = timers => ({
type: GET_TIMERS,
timers,
});
export const getMainDeviceTImersAction = mainDeviceTimers => ({
type: GET_MAIN_DEVICE_TIMERS,
mainDeviceTimers,
});
export const getMcbLinksTimersAction = mcbLinksTimers => ({
type: GET_MCBLINKS_TIMERS,
mcbLinksTimers,
});
export const getSubBreakersTimersAction = subBreakersTimers => ({
type: GET_SUBBREAKERS_TIMERS,
subBreakersTimers,
});
export const getExistedDataAction = existedData => ({
type: GET_EXISTED_DATA,
existedData,
});
export const loadingAction = bool => ({
type: GET_TIMERS_LOADING,
isLoading: bool,
});
export const errorAction = error => ({
type: GET_TIMERS_ERROR,
error,
});
export const getTimers = () => async (dispatch, getState) => {
const { currentSelectedDeviceReducer } = getState();
const { selectedDeviceId } = currentSelectedDeviceReducer;
try {
dispatch(loadingAction(true));
let allTimersData = [];
let mainDeviceTimers = [];
let mcbLinksTimers = [];
let subBreakersTimers = [];
//main device section
/*-------------------------------------*/
const selectedDeviceDetails = await fireStore
.collection('device')
.doc(selectedDeviceId)
.get();
const selectedDeviceTimers = await fireStore
.collection('device')
.doc(selectedDeviceId)
.collection('Timers')
.orderBy('timer', 'asc')
.where('timer', '>', 0)
.get();
const selectedDeviceDetailsData = selectedDeviceDetails.data();
// const selectedDeviceTimersData = selectedDeviceTimers.data();
selectedDeviceTimers.docs.map(timer => {
mainDeviceTimers.push(timer.data());
});
// //mcblink section
// /*-------------------------------------*/
// const selectedDeviceMcbLinks = await fireStore
// .collection('device')
// .doc(selectedDeviceId)
// .collection('mcbLinks')
// .get();
// let existedMcbLinks = [];
// let selectedDeviceMcbLinksData = [];
// selectedDeviceMcbLinks.docs.map(mcbLink => {
// existedMcbLinks.push(mcbLink.data().id);
// selectedDeviceMcbLinksData.push(mcbLink.data());
// let mcbLinkData = mcbLink.data();
// mcbLinksTimers.push(mcbLinkData.timers);
// mcbLinkData.timers.map(timer => {
// allTimersData.push(
// Object.assign(timer, {
// id: mcbLink.data().id,
// type: mcbLink.data().type,
// name: mcbLink.data().name,
// })
// );
// });
// });
// //subbreaker section
// /*-------------------------------------*/
// let existedSubBreakers = [];
// let selectedDeviceSubBreakersData = [];
// selectedDeviceMcbLinksData.map(async mcbLink => {
// let selectedDeviceSubBreakers = await fireStore
// .collection('device')
// .doc(selectedDeviceId)
// .collection('mcbLinks')
// .doc(mcbLink.id.toString())
// .collection('subBreakers')
// .get();
// return selectedDeviceSubBreakers.docs.map(subBreaker => {
// existedSubBreakers.push([mcbLink.id, subBreaker.data().id]);
// selectedDeviceSubBreakersData.push(subBreaker.data());
// let subBreakerData = subBreaker.data();
// subBreakersTimers.push(subBreakerData.timers);
// subBreakerData.timers.map(timer => {
// allTimersData.push(
// Object.assign(timer, {
// mcbLinkId: mcbLink.id,
// id: subBreaker.data().id,
// type: subBreaker.data().type,
// name: subBreaker.data().name,
// })
// );
// });
// });
// });
// console.log('selectedDeviceMcbLinksData', selectedDeviceMcbLinksData);
// const existedData = { existedMcbLinks, existedSubBreakers };
// // console.log(mainDeviceTimers, mcbLinksTimers, subBreakersTimers);
// dispatch(getExistedDataAction(existedData));
dispatch(getMainDeviceTImersAction(mainDeviceTimers));
// dispatch(getMcbLinksTimersAction(mcbLinksTimers));
// dispatch(getSubBreakersTimersAction(subBreakersTimers));
// dispatch(getTimersAction(allTimersData));
} catch (error) {
dispatch(errorAction(error.message || error || 'Error'));
}
dispatch(loadingAction(false));
};
// export const getTimers = () => async (dispatch, getState) => {
// const { currentSelectedDeviceReducer } = getState();
// const { selectedDeviceId } = currentSelectedDeviceReducer;
// try {
// dispatch(loadingAction(true));
// let allTimersData = [];
// let mainDeviceTimers = [];
// let mcbLinksTimers = [];
// let subBreakersTimers = [];
// //main device section
// /*-------------------------------------*/
// const selectedDevice = await fireStore
// .collection('device')
// .doc(selectedDeviceId)
// .get();
// const selectedDeviceData = await selectedDevice.data();
// mainDeviceTimers.push(selectedDeviceData.timers);
// selectedDeviceData.timers.map(timer =>
// allTimersData.push(Object.assign(timer, { type: selectedDeviceData.type, name: selectedDeviceData.name }))
// );
// //mcblink section
// /*-------------------------------------*/
// const selectedDeviceMcbLinks = await fireStore
// .collection('device')
// .doc(selectedDeviceId)
// .collection('mcbLinks')
// .get();
// let existedMcbLinks = [];
// let selectedDeviceMcbLinksData = [];
// selectedDeviceMcbLinks.docs.map(mcbLink => {
// existedMcbLinks.push(mcbLink.data().id);
// selectedDeviceMcbLinksData.push(mcbLink.data());
// let mcbLinkData = mcbLink.data();
// mcbLinksTimers.push(mcbLinkData.timers);
// mcbLinkData.timers.map(timer => {
// allTimersData.push(
// Object.assign(timer, {
// id: mcbLink.data().id,
// type: mcbLink.data().type,
// name: mcbLink.data().name,
// })
// );
// });
// });
// //subbreaker section
// /*-------------------------------------*/
// let existedSubBreakers = [];
// let selectedDeviceSubBreakersData = [];
// selectedDeviceMcbLinksData.map(async mcbLink => {
// let selectedDeviceSubBreakers = await fireStore
// .collection('device')
// .doc(selectedDeviceId)
// .collection('mcbLinks')
// .doc(mcbLink.id.toString())
// .collection('subBreakers')
// .get();
// return selectedDeviceSubBreakers.docs.map(subBreaker => {
// existedSubBreakers.push([mcbLink.id, subBreaker.data().id]);
// selectedDeviceSubBreakersData.push(subBreaker.data());
// let subBreakerData = subBreaker.data();
// subBreakersTimers.push(subBreakerData.timers);
// subBreakerData.timers.map(timer => {
// allTimersData.push(
// Object.assign(timer, {
// mcbLinkId: mcbLink.id,
// id: subBreaker.data().id,
// type: subBreaker.data().type,
// name: subBreaker.data().name,
// })
// );
// });
// });
// });
// console.log('selectedDeviceMcbLinksData', selectedDeviceMcbLinksData);
// const existedData = { existedMcbLinks, existedSubBreakers };
// // console.log(mainDeviceTimers, mcbLinksTimers, subBreakersTimers);
// dispatch(getExistedDataAction(existedData));
// dispatch(getMainDeviceTImersAction(mainDeviceTimers));
// dispatch(getMcbLinksTimersAction(mcbLinksTimers));
// dispatch(getSubBreakersTimersAction(subBreakersTimers));
// dispatch(getTimersAction(allTimersData));
// } catch (error) {
// dispatch(errorAction(error.message || error || 'Error'));
// }
// dispatch(loadingAction(false));
// };
// export const getTimers = () => async (dispatch, getState) => {
// dispatch(loadingAction(true));
// const { currentSelectedDeviceReducer } = getState();
// const { selectedDeviceId } = currentSelectedDeviceReducer;
// try {
// const allSelectedDevice = await fireStore
// .collection('device')
// .doc(selectedDeviceId)
// .get();
// let allSelectedDeviceData = await allSelectedDevice.data();
// let allTimersData = [];
// allSelectedDeviceData.timers.map(timer =>
// allTimersData.push(
// Object.assign(timer, { type: allSelectedDeviceData.type, name: allSelectedDeviceData.name })
// )
// );
// allSelectedDeviceData.mcbLinks.map(mcbLink =>
// mcbLink.timers.map(timer =>
// allTimersData.push(
// Object.assign(timer, {
// id: mcbLink.id,
// type: mcbLink.type,
// name: mcbLink.name,
// })
// )
// )
// );
// allSelectedDeviceData.mcbLinks.map(mcbLink =>
// mcbLink.subBreakers.map(subBreaker =>
// subBreaker.timers.map(timer =>
// allTimersData.push(
// Object.assign(timer, {
// mcbId: mcbLink.id,
// id: subBreaker.id,
// type: subBreaker.type,
// name: subBreaker.name,
// })
// )
// )
// )
// );
// // console.log('allTimersData', allTimersData);
// dispatch(getTimersAction(allTimersData));
// dispatch(loadingAction(false));
// } catch (error) {
// dispatch(errorAction(error.message || error || 'Error'));
// dispatch(loadingAction(false));
// }
// };
...@@ -3,6 +3,6 @@ import { createStore, applyMiddleware } from 'redux'; ...@@ -3,6 +3,6 @@ import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
import logger from 'redux-logger'; import logger from 'redux-logger';
const middleware = __DEV__ === true ? applyMiddleware(thunk, logger) : applyMiddleware(thunk); const middleware = __DEV__ ? [thunk, logger] : [thunk];
export default (store = createStore(allReducers, middleware)); export default (store = createStore(allReducers, applyMiddleware(...middleware)));
import {
// GET_ALL_DEVICE_ID,
GET_ALL_DEVICE_INFO,
} from '../actions/allDataAction';
const initState = {
// allDeviceId: null,
allDeviceInfo: null,
};
const allDataReducer = (state = initState, action) => {
switch (action.type) {
// case GET_ALL_DEVICE_ID:
// return { ...state, allDeviceId: action.allDeviceId };
case GET_ALL_DEVICE_INFO:
return { ...state, allDeviceInfo: action.allDeviceInfo };
default:
return state;
}
};
export default allDataReducer;
import {
GET_ALL_MAIN_DEVICE_INFO,
GET_ALL_MAIN_DEVICE_INFO_LOADING,
GET_ALL_MAIN_DEVICE_INFO_ERROR,
} from '../actions/allMainDeviceAction';
const initState = {
allMainDeviceInfo: [],
isLoading: true,
error: null,
};
const allMainDeviceReducer = (state = initState, action) => {
switch (action.type) {
case GET_ALL_MAIN_DEVICE_INFO:
return { ...state, allMainDeviceInfo: action.allMainDeviceInfo };
case GET_ALL_MAIN_DEVICE_INFO_LOADING:
return { ...state, isLoading: action.isLoading };
case GET_ALL_MAIN_DEVICE_INFO_ERROR:
return { ...state, error: action.error };
default:
return state;
}
};
export default allMainDeviceReducer;
const initialState = {
token: {},
loading: true,
error: null,
};
const authReducer = (state = initialState, action) => {
switch (action.type) {
case 'GET_TOKEN':
return { ...state, token: action.token };
case 'SAVE_TOKEN':
return { ...state, token: action.token };
case 'REMOVE_TOKEN':
return { ...state, token: action.token };
case 'LOADING':
return { ...state, loading: action.isLoading };
case 'ERROR':
return { ...state, error: action.error };
default:
return state;
}
};
export default authReducer;
import { GET_CURRENT_USER } from '../actions/cerrentUserAction'; import { GET_CURRENT_USER } from '../actions/cerrentUserAction';
const initState = { const initState = {
displayName: null, displayName: '',
email: null, email: '',
emailVerified: null, emailVerified: '',
phoneNumber: null, phoneNumber: '',
uid: null, uid: '',
}; };
const currentUserReducer = (state = initState, action) => { const currentUserReducer = (state = initState, action) => {
......
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
// import authReducer from './authReducer';
import { reducer as form } from 'redux-form'; import { reducer as form } from 'redux-form';
import allDataReducer from './allDataReducer'; import allMainDeviceReducer from './allMainDeviceReducer';
import currentUserReducer from './currentUserReducer'; import currentUserReducer from './currentUserReducer';
import currentSelectedDeviceReducer from './currentSelectedReducer'; import currentSelectedDeviceReducer from './currentSelectedReducer';
import timersReducer from './timersReducer';
export default combineReducers({ export default combineReducers({
// token: authReducer,
currentSelectedDeviceReducer, currentSelectedDeviceReducer,
currentUserReducer, currentUserReducer,
allDataReducer, allMainDeviceReducer,
timersReducer,
form, form,
}); });
import {
GET_TIMERS,
GET_TIMERS_LOADING,
GET_TIMERS_ERROR,
GET_EXISTED_DATA,
GET_MAIN_DEVICE_TIMERS,
GET_MCBLINKS_TIMERS,
GET_SUBBREAKERS_TIMERS,
} from '../actions/timersAction';
const initState = {
timers: [],
mainDeviceTimers: [],
mcbLinksTimers: [],
subBreakersTimers: [],
existedData: {},
isLoading: true,
error: null,
};
const timersReducer = (state = initState, action) => {
switch (action.type) {
case GET_EXISTED_DATA:
return { ...state, existedData: action.existedData };
case GET_TIMERS:
return { ...state, timers: action.timers };
case GET_MAIN_DEVICE_TIMERS:
return { ...state, mainDeviceTimers: action.mainDeviceTimers };
case GET_MCBLINKS_TIMERS:
return { ...state, mcbLinksTimers: action.mcbLinksTimers };
case GET_SUBBREAKERS_TIMERS:
return { ...state, subBreakersTimers: action.subBreakersTimers };
case GET_TIMERS_LOADING:
return { ...state, isLoading: action.isLoading };
case GET_TIMERS_ERROR:
return { ...state, error: action.error };
default:
return state;
}
};
export default timersReducer;
...@@ -24,7 +24,7 @@ class SettingScreen extends React.Component { ...@@ -24,7 +24,7 @@ class SettingScreen extends React.Component {
}); });
} }
state = { state = {
data: this.props.allDeviceInfo[0], data: [],
isVisible: false, isVisible: false,
pressQr: false, pressQr: false,
pressMail: false, pressMail: false,
...@@ -191,7 +191,7 @@ class SettingScreen extends React.Component { ...@@ -191,7 +191,7 @@ class SettingScreen extends React.Component {
} }
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo, allMainDeviceInfo: state.allMainDeviceReducer.allMainDeviceInfo,
}); });
export default connect(mapStateToProps)(SettingScreen); export default connect(mapStateToProps)(SettingScreen);
......
...@@ -86,13 +86,13 @@ const LimitCurrent = [ ...@@ -86,13 +86,13 @@ const LimitCurrent = [
class SmartMeterDetailScreen extends Component { class SmartMeterDetailScreen extends Component {
static navigationOptions = ({ navigation }) => { static navigationOptions = ({ navigation }) => {
const deviceName = navigation.getParam('deviceName', ''); const deviceName = navigation.getParam('name', '');
return { return {
title: deviceName, title: deviceName,
headerLeft: ( headerLeft: (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}> <HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<Item title="back" iconName="ios-arrow-back" onPress={() => navigation.goBack()} /> <Item title="back" iconName="ios-arrow-back" onPress={() => navigation.popToTop()} />
</HeaderButtons> </HeaderButtons>
), ),
headerRight: ( headerRight: (
...@@ -119,7 +119,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -119,7 +119,7 @@ class SmartMeterDetailScreen extends Component {
state = { state = {
mbOn: false, mbOn: false,
sb: this.expandState(), sb: this.expandState(),
data: this.props.allDeviceInfo[0], data: [],
}; };
renderCurrent(item, index) { renderCurrent(item, index) {
return ( return (
...@@ -279,7 +279,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -279,7 +279,7 @@ class SmartMeterDetailScreen extends Component {
} }
}} }}
numColumns={3} numColumns={3}
keyExtractor={(item, index) => index} keyExtractor={(item, index) => index.toString()}
style={{ paddingTop: 20 }} style={{ paddingTop: 20 }}
/> />
{/* MCB Link */} {/* MCB Link */}
...@@ -293,7 +293,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -293,7 +293,7 @@ class SmartMeterDetailScreen extends Component {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo, allDeviceInfo: state.allMainDeviceReducer.allDeviceInfo,
}); });
export default connect(mapStateToProps)(SmartMeterDetailScreen); export default connect(mapStateToProps)(SmartMeterDetailScreen);
......
import React, { Component } from 'react'; import React, { PureComponent } from 'react';
import { Text } from 'native-base'; import { Text } from 'native-base';
import { FlatList, View } from 'react-native'; import { FlatList, View } from 'react-native';
import { theme } from '../../../constants/Styles'; import { theme } from '../../../constants/Styles';
...@@ -6,130 +6,102 @@ import MeterCard from '../../../components/MeterCard'; ...@@ -6,130 +6,102 @@ import MeterCard from '../../../components/MeterCard';
import { HeaderButtons, Item } from 'react-navigation-header-buttons'; import { HeaderButtons, Item } from 'react-navigation-header-buttons';
import IoniconsHeaderButton from '../../../components/IoniconsHeaderButton'; import IoniconsHeaderButton from '../../../components/IoniconsHeaderButton';
import { isIphoneX } from '../../../utils/isPhoneX'; import { isIphoneX } from '../../../utils/isPhoneX';
import { getAllDeviceInfo } from '../../../reduxStore/actions/allDataAction'; import { getAllMainDeviceInfo } from '../../../reduxStore/actions/allMainDeviceAction';
import { setCurrentSelected } from '../../../reduxStore/actions/currentSelectedAction'; import { setCurrentSelected } from '../../../reduxStore/actions/currentSelectedAction';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { getTimers } from '../../../reduxStore/actions/timersAction';
let Data = [ class SmartMeterScreen extends PureComponent {
// {
// deviceName: 'Device 1',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: true,
// isOn: true,
// },
// {
// deviceName: 'Device 2',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: false,
// isOn: true,
// },
// {
// deviceName: 'Device 3',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: true,
// isOn: false,
// },
// {
// deviceName: 'Device 4',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: false,
// isOn: false,
// },
];
class SmartMeterScreen extends Component {
static navigationOptions = ({ navigation }) => ({ static navigationOptions = ({ navigation }) => ({
title: 'Home', title: 'Home',
headerLeft: ( // headerLeft: (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}> // <HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<Item title="menu" iconName="ios-menu" onPress={() => console.log('menu')} /> // <Item title="menu" iconName="ios-menu" onPress={() => console.log('menu')} />
</HeaderButtons> // </HeaderButtons>
), // ),
headerRight: ( headerRight: (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}> <HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<Item title="add" iconName="ios-add" onPress={() => navigation.navigate('Camera')} /> <Item title="menu" iconName="ios-add" onPress={() => navigation.navigate('Camera')} />
</HeaderButtons> </HeaderButtons>
), ),
}); });
state = { state = {
initData: this.props.allDeviceInfo, data: [],
data: this.props.allDeviceInfo,
isLoading: true,
}; };
static getDerivedStateFromProps = (nextProps, prevState) => { _isMounted = false;
if (prevState.data !== nextProps.allDeviceInfo) {
return { componentDidMount = () => {
data: nextProps.allDeviceInfo, this._isMounted = true;
}; // this.getData();
} else null;
}; };
componentDidMount = async () => { renderItem = ({ item, index }) => {
await this.props.getAllDeviceInfo(); return (
<MeterCard
name={item.name || 'Untitled'}
description={item.description || ''}
img={item.img || null}
isOnline={item.isOnline || false}
isOn={item.isOn || false}
onPressEachCard={async () => {
await this.props.setCurrentSelected(item.deviceId);
await this.props.getTimers();
this.props.navigation.navigate('SmartMeterDetail', { name: item.name || '' });
}}
/>
);
}; };
componentDidUpdate = (prevProps, prevState) => { getData = async () => {
if (prevState.data !== this.state.data) { this._isMounted = false;
this.setState({ isLoading: false }); await this.props.getAllMainDeviceInfo();
}
}; };
render() { render() {
console.log(this.state); const { allMainDeviceInfo, isLoading, error } = this.props;
let { allDeviceInfo, getAllDeviceInfo, setCurrentSelected } = this.props;
const { isLoading } = this.state;
return ( return !error ? (
<FlatList <FlatList
removeClippedSubviews={true}
refreshing={isLoading} refreshing={isLoading}
onRefresh={getAllDeviceInfo} onRefresh={this.getData}
style={[theme.container, theme.containerWithPadding]} style={[theme.container, theme.containerWithPadding]}
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }} //iPhoneX BottomSpace = 34 contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }} //iPhoneX BottomSpace = 34
data={this.state.initData} data={allMainDeviceInfo}
extraData={this.state.data} extraData={allMainDeviceInfo}
keyExtractor={(item, index) => `Card${index}`} keyExtractor={(item, index) => `Card${item.deviceId}`}
ListEmptyComponent={() => ( ListEmptyComponent={() => (
<View> <View>
<Text style={[theme.normalText, { marginTop: 20 }]}> <Text style={[theme.normalText, { marginTop: 20 }]}>
{isLoading ? '' : 'No Device Connected'} {isLoading ? '' : this._isMounted ? 'No Device Connected' : ''}
</Text> </Text>
</View> </View>
)} )}
ListHeaderComponent={() => ( ListHeaderComponent={() => (
<Text style={[theme.smallTitle, theme.textDark, { marginBottom: 10 }]}>Smart meter</Text> <Text style={[theme.smallTitle, theme.textDark, { marginBottom: 10 }]}>Smart meter</Text>
)} )}
renderItem={({ item, index }) => ( renderItem={this.renderItem}
<MeterCard
// key={`mastercard${index}`}
name={item.name || 'Untitled'}
description={item.description || ''}
img={item.img || null}
isOnline={item.isOnline || false}
isOn={item.isOn || false}
onPressEachCard={() => {
setCurrentSelected(item.deviceId);
this.props.navigation.navigate('SmartMeterDetail', { name: item.name });
}}
/>
)}
/> />
) : (
<View>
<Text>{error}</Text>
</View>
); );
} }
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo, allMainDeviceInfo: state.allMainDeviceReducer.allMainDeviceInfo,
isLoading: state.allMainDeviceReducer.isLoading,
error: state.allMainDeviceReducer.error,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getAllDeviceInfo, getAllMainDeviceInfo,
setCurrentSelected, setCurrentSelected,
getTimers,
}; };
export default connect( export default connect(
......
import React, { PureComponent } from 'react';
import { Icon, Text } from 'native-base';
import {
View,
StyleSheet,
FlatList,
ScrollView,
Modal,
TouchableOpacity,
Platform,
TouchableNativeFeedback,
} from 'react-native';
import { Switch, Button, Col, Row } from 'native-base';
import { HeaderButtons, Item as HeaderItem } from 'react-navigation-header-buttons';
import IoniconsHeaderButton from '../../../components/IoniconsHeaderButton';
import { color, theme } from '../../../constants/Styles';
import RNPickerSelect from 'react-native-picker-select';
import { Badge, CheckBox, SearchBar } from 'react-native-elements';
import SwipeableRow from '../../../components/SwipeableRow';
import DatePicker from 'react-native-date-picker';
import { width, height } from '../../../constants/Layout';
import InputField from '../../../components/InputField';
import { isIphoneX } from '../../../utils/isPhoneX';
import { connect } from 'react-redux';
import { getTimers } from '../../../reduxStore/actions/timersAction';
import { fireStore } from '../../../firebase';
import firebase from 'firebase/app';
import 'firebase/firestore';
const initState = {
isActive: false,
isPowerOn: false,
timer: new Date(),
repeatOn: [
{ id: 0, isRepeat: false, day: 'Sunday' },
{ id: 1, isRepeat: false, day: 'Monday' },
{ id: 2, isRepeat: false, day: 'Tuesday' },
{ id: 3, isRepeat: false, day: 'Wednesday' },
{ id: 4, isRepeat: false, day: 'Thursday' },
{ id: 5, isRepeat: false, day: 'Friday' },
{ id: 6, isRepeat: false, day: 'Saturday' },
],
checked: [],
isAddVisible: false,
isfilterVisible: false,
search: '',
selectedBreaker: null,
selectedSubBreaker: null,
};
class TimerScreen extends PureComponent {
static navigationOptions = ({ navigation }) => ({
title: 'Timer',
headerLeft: (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<HeaderItem title="menu" iconName="md-home" onPress={() => navigation.popToTop()} />
</HeaderButtons>
),
headerRight: navigation.state.params ? navigation.state.params.headerRight : null,
});
// constructor(props) {
// super(props);
// this.props.navigation.setParams({
// headerRight: (
// <TouchableOpacity onPress={() => this.setState({ isAddVisible: true })}>
// <View style={{ marginRight: 17 }}>
// <Icon name="ios-add" style={{ color: color.white }} />
// </View>
// </TouchableOpacity>
// ),
// });
// }
state = {
isActive: false,
isPowerOn: false,
timer: new Date(),
repeatOn: [
{ id: 0, isRepeat: false, day: 'Sunday' },
{ id: 1, isRepeat: false, day: 'Monday' },
{ id: 2, isRepeat: false, day: 'Tuesday' },
{ id: 3, isRepeat: false, day: 'Wednesday' },
{ id: 4, isRepeat: false, day: 'Thursday' },
{ id: 5, isRepeat: false, day: 'Friday' },
{ id: 6, isRepeat: false, day: 'Saturday' },
],
checked: [],
isAddVisible: false,
isfilterVisible: false,
search: '',
pickerSelectData: [],
subBreakerList: [],
selectedBreaker: null,
selectedSubBreaker: null,
};
setPickerSelectData = async () => {
let pickerSelectData = [{ label: 'Main Device', value: false }];
await this.props.existedData.existedMcbLinks.map((mcbLinkId, index) => {
pickerSelectData.push({ label: `MCB Link ${mcbLinkId}`, value: index + 1 });
});
this.setState({ pickerSelectData });
};
setExistedSubBreaker = () => {
let existedSubBreaker = [];
this.props.existedData.existedSubBreakers.map(subBreaker => {
if (this.state.selectedBreaker === subBreaker[0]) {
existedSubBreaker.push(subBreaker);
}
});
console.log('existedSubBreaker', existedSubBreaker);
let subBreakerList = new Array(existedSubBreaker.length).fill().map((el, index) => {
return { id: index + 1, selected: false };
});
console.log('subBreakerList', subBreakerList);
this.setState({ subBreakerList });
};
autoCloseSwipeRow = swipeInstance => {
if (this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe.close();
}
this.currentlyOpenSwipe = swipeInstance;
};
toggleActive = () => {
this.setState(prevState => ({ isActive: !prevState.isActive }));
};
togglePower = () => {
this.setState(prevState => ({ isPowerOn: !prevState.isPowerOn }));
};
toggleRepeatDays = index => {
this.setState(prevState => ({
repeatOn: prevState.repeatOn.map((element, elementIndex) =>
elementIndex === index ? { ...element, isRepeat: !prevState.repeatOn[index].isRepeat } : element
),
}));
};
updateSearch = search => {
this.setState({ search });
};
createNewTimer = () => {
const deviceId = this.props.selectedDeviceId;
const { selectedSubBreaker, selectedBreaker } = this.state;
// const data = {
// timers: [
// {
// isActive: this.state.isActive,
// isPowerOn: this.state.isPowerOn,
// timer: Number(this.state.timer),
// repeatOn: this.state.repeatOn,
// },
// ],
// };
let docRef = null;
if (selectedSubBreaker) {
docRef = fireStore.doc(
`device/${deviceId}/mcbLinks/${selectedBreaker}/subBreakers/${selectedSubBreaker.id}`
);
} else if (selectedBreaker) {
docRef = fireStore.doc(`device/${deviceId}/mcbLinks/${selectedBreaker}`);
} else {
docRef = fireStore.doc(`device/${deviceId}`);
}
try {
docRef.update({
timers: firebase.firestore.FieldValue.arrayUnion({
isActive: this.state.isActive,
isPowerOn: this.state.isPowerOn,
timer: Number(this.state.timer),
repeatOn: this.state.repeatOn,
}),
});
} catch (e) {
alert(e);
}
};
componentDidUpdate = (prevProps, prevState) => {
if (prevProps.timers !== this.props.timers) {
console.log('timers =>', this.props.timers || '');
}
if (prevState.selectedBreaker !== this.state.selectedBreaker) {
this.setExistedSubBreaker();
}
if (prevProps.existedData.existedMcbLinks !== this.props.existedData.existedMcbLinks) {
console.log('this.props.existedData.existedMcbLinks', this.props.existedData.existedMcbLinks);
this.setPickerSelectData();
}
if (prevState.subBreakerList !== this.state.subBreakerList && this.state.subBreakerList) {
let selectedSubBreaker = this.state.subBreakerList.find(subBreaker => {
return subBreaker.selected === true;
});
this.setState({ selectedSubBreaker: selectedSubBreaker });
}
console.log('STATE', this.state);
};
componentDidMount = () => {
this.props.navigation.setParams({
headerRight: (
<TouchableOpacity onPress={() => this.setState({ isAddVisible: true })}>
<View style={{ marginRight: 17 }}>
<Icon name="ios-add" style={{ color: color.white }} />
</View>
</TouchableOpacity>
),
});
this.setExistedSubBreaker();
this.props.existedData.existedMcbLinks && this.setPickerSelectData();
};
render() {
return (
<>
{/* Overlay */}
<Modal
transparent
presentationStyle={'overFullScreen'}
animationType="fade"
visible={this.state.isfilterVisible || this.state.isAddVisible}
>
<View style={{ width, height, backgroundColor: 'rgba(0,0,0,0.5)' }} />
</Modal>
{/* Search Bar */}
<View style={{ padding: 15, flexDirection: 'row', alignItems: 'center' }}>
<SearchBar
containerStyle={styles.searchBarContainer}
inputContainerStyle={styles.searchBarInputContainer}
inputStyle={styles.searchBarInput}
round
lightTheme
placeholder="Search..."
onChangeText={this.updateSearch}
value={this.state.search}
/>
<Icon
name="md-funnel"
style={{ color: '#c7cad1', fontSize: 20, marginLeft: 10, marginRight: 5 }}
onPress={() => this.setState({ isfilterVisible: true })}
/>
</View>
{/* List Timer */}
<FlatList
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }}
data={this.props.timers}
extraData={this.props}
ListEmptyComponent={() => (
<View>
<Text style={[theme.normalText, theme.mt2]}>No timers</Text>
</View>
)}
ItemSeparatorComponent={() => <View style={styles.separator} />}
renderItem={({ item, index }) => (
<SwipeableRow item={item} index={index} onSwipeOpen={this.autoCloseSwipeRow} />
)}
keyExtractor={(item, index) => `timer${index}`}
/>
{/* Create & Update Timer Modal */}
<Modal
transparent
presentationStyle={'overFullScreen'}
animationType="slide"
visible={this.state.isAddVisible}
>
<View style={styles.scrollContainer}>
<Text style={[theme.title, { paddingHorizontal: 25 }]}>Create Timer</Text>
<ScrollView contentContainerStyle={{ paddingHorizontal: 25, paddingBottom: 20 }}>
<Text style={[theme.normalText, theme.textDark, theme.mt2]}>Set Time</Text>
<DatePicker
date={this.state.timer}
onDateChange={date => this.setState({ timer: date })}
mode="time"
style={{ height: 100 }}
/>
<Text style={[theme.normalText, theme.textDark, theme.mt2]}>Select Breaker</Text>
<View
style={[
theme.mt2,
{
borderWidth: 1,
borderColor: '#dcdcdc',
borderRadius: 5,
padding: 10,
},
]}
>
<RNPickerSelect
items={this.state.pickerSelectData}
useNativeAndroidPickerStyle={false}
onValueChange={(value, index) => {
this.setState({ selectedBreaker: value });
}}
placeholder={{ label: 'Select...', value: null }}
style={pickerStyle}
Icon={() => (
<Icon name="ios-arrow-down" style={{ fontSize: 14, color: '#c8c8c8' }} />
)}
/>
</View>
<FlatList
style={theme.mt2}
data={this.state.subBreakerList}
extradata={this.state}
ItemSeparatorComponent={() => <View style={theme.mt1} />}
renderItem={({ item, index }) => (
<CheckBox
containerStyle={styles.checkboxContainer}
fontFamily={'Avenir-Roman'}
textStyle={{ fontWeight: 'normal', color: color.darkGrey }}
title={'Sub breaker ' + item.id}
checked={this.state.subBreakerList[index].selected}
checkedIcon={
<Icon
name="md-radio-button-on"
style={{ color: color.primary, fontSize: 22 }}
/>
}
uncheckedIcon={
<Icon
name="md-radio-button-off"
style={{ color: color.grey, fontSize: 22 }}
/>
}
onPress={() => {
this.setState(prevState => ({
subBreakerList: prevState.subBreakerList.map((el, elementIndex) =>
elementIndex === index
? {
...el,
selected: !this.state.subBreakerList[index].selected,
}
: { ...el, selected: false }
),
}));
}}
/>
)}
keyExtractor={(item, index) => `sub${index}`}
/>
<View style={[styles.rowContainer, theme.mt2]}>
<Text style={[theme.normalText, theme.textDark]}>Power</Text>
<Switch value={this.state.isPowerOn} onValueChange={this.togglePower} />
</View>
<View style={[styles.rowContainer, theme.mt2]}>
<Text style={[theme.normalText, theme.textDark]}>Active</Text>
<Switch value={this.state.isActive} onValueChange={this.toggleActive} />
</View>
<View style={theme.mt2}>
<Text style={[theme.normalText, theme.textDark, { marginBottom: 10 }]}>Repeat</Text>
<View style={styles.dayContainer}>
{this.state.repeatOn.map((item, index) => {
let dynamicColor = this.state.repeatOn[index].isRepeat
? color.primary
: color.grey;
return (
<TouchableNativeFeedback
key={`repeatOn${index}`}
onPress={() => this.toggleRepeatDays(index)}
>
<View style={[styles.dayBtn, { borderColor: dynamicColor }]}>
<Text style={[theme.normalText, { color: dynamicColor }]}>
{item.day.substr(0, 1)}
</Text>
</View>
</TouchableNativeFeedback>
);
})}
</View>
</View>
<View style={[{ flexDirection: 'row', justifyContent: 'space-evenly' }, theme.mt2]}>
<Button
transparent
style={{ flex: 1, justifyContent: 'center' }}
onPress={() => this.setState(initState)}
>
<Text style={{ color: color.grey }}>Cancel</Text>
</Button>
<Button
rounded
style={{
flex: 1,
justifyContent: 'center',
backgroundColor: color.primary,
}}
onPress={async () => {
await this.createNewTimer();
await this.props.getTimers();
this.setState(initState);
}}
>
<Text style={{ color: color.white }}>Confirm</Text>
</Button>
</View>
</ScrollView>
</View>
</Modal>
{/* Filter Modal */}
<Modal
transparent
presentationStyle={'overFullScreen'}
animationType="slide"
visible={this.state.isfilterVisible}
>
<View style={styles.filterModal}>
<View
style={[
theme.rowContainer,
{
justifyContent: 'space-between',
paddingBottom: 10,
borderBottomColor: 'rgba(189, 192, 200, 0.3)',
borderBottomWidth: 1,
},
]}
>
<Text style={[theme.smallTitle, theme.textDark]}>Reset</Text>
<Text style={[theme.smallTitle, theme.textDark]}>Filters</Text>
<Text
style={[theme.smallTitle, theme.textDanger]}
onPress={() => this.setState({ isfilterVisible: false })}
>
Done
</Text>
</View>
<Text style={[theme.smallTitle, theme.textDanger, theme.mt2]}>Select Breaker</Text>
<View
style={[
theme.mt2,
{
borderWidth: 1,
borderColor: '#dcdcdc',
borderRadius: 5,
padding: 10,
},
]}
>
<RNPickerSelect
items={this.state.pickerSelectData}
onValueChange={(value, index) => {
// this.setState({ selectedBreaker: breaker[index - 1].sub });
}}
useNativeAndroidPickerStyle={false}
placeholder={{ label: 'Select...', value: null }}
style={pickerStyle}
Icon={() => <Icon name="ios-arrow-down" style={{ fontSize: 14, color: '#c8c8c8' }} />}
/>
</View>
<FlatList
style={theme.mt2}
data={this.state.selectedBreaker}
// extradata={this.state.selectedBreaker}
ListEmptyComponent={() => (
<View>
<Text style={[theme.normalText, theme.mt2]}>No Sub breaker</Text>
</View>
)}
ItemSeparatorComponent={() => <View style={theme.mt1} />}
renderItem={({ item, index }) => (
<CheckBox
containerStyle={styles.checkboxContainer}
fontFamily={'Avenir-Roman'}
textStyle={{ fontWeight: 'normal', color: color.darkGrey }}
title={'Sub breaker ' + item.id}
checked={this.state.selectedBreaker[index].active}
checkedIcon={
<Icon name="md-checkbox" style={{ color: color.primary, fontSize: 26 }} />
}
uncheckedIcon={
<Icon name="md-square-outline" style={{ color: color.grey, fontSize: 26 }} />
}
onPress={() =>
this.setState(prevState => ({
// selectedBreaker: prevState.selectedBreaker.map(el =>
// el.id === index + 1
// ? { ...el, active: !this.state.selectedBreaker[index].active }
// : el
// ),
}))
}
/>
)}
keyExtractor={(item, index) => `sub${index}`}
/>
</View>
</Modal>
</>
);
}
}
const mapStateToProps = state => ({
existedData: state.timersReducer.existedData,
timers: state.timersReducer.timers,
isLoading: state.timersReducer.isLoading,
selectedDeviceId: state.currentSelectedDeviceReducer.selectedDeviceId,
});
const mapDispatchToProps = {
getTimers,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TimerScreen);
const pickerStyle = {
inputIOS: {
color: color.darkGrey,
fontFamily: 'Avenir-Roman',
},
iconContainer: {
top: Platform.OS === 'android' ? 5 : undefined,
right: 0,
},
inputAndroid: {
height: 20,
fontFamily: 'Avenir-Roman',
fontSize: 14,
paddingVertical: 0,
},
};
const styles = StyleSheet.create({
searchBarContainer: {
flex: 1,
display: 'flex',
backgroundColor: 'transparent',
height: 33,
paddingVertical: 0,
borderTopWidth: 0,
borderBottomWidth: 0,
},
searchBarInputContainer: {
borderWidth: 1,
borderBottomWidth: 1,
backgroundColor: 'transparent',
minHeight: 10,
height: 33,
borderColor: '#c7cad1',
},
searchBarInput: { fontFamily: 'Avenir-Roman', fontSize: 14, color: color.grey, marginTop: 3 },
separator: {
marginHorizontal: 10,
height: StyleSheet.hairlineWidth,
backgroundColor: 'rgb(200, 199, 204)',
},
rowContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
},
dayContainer: {
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-evenly',
},
dayBtn: {
width: 35,
height: 35,
borderWidth: 1,
borderRadius: 18,
alignItems: 'center',
justifyContent: 'center',
},
scrollContainer: {
flex: 0.9,
top: height * 0.1,
paddingTop: 20,
// paddingBottom: 30,
// paddingHorizontal: 25,
backgroundColor: '#fff',
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
alignContent: 'space-between',
justifyContent: 'space-evenly',
},
timerInputContainer: {
flex: 1,
minHeight: 450,
maxHeight: 500,
paddingVertical: 10,
justifyContent: 'space-between',
},
filterModal: {
flex: 0.7,
top: height * 0.3,
paddingTop: 20,
paddingBottom: 18,
paddingHorizontal: 25,
backgroundColor: color.white,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
},
checkboxContainer: {
borderColor: 'transparent',
backgroundColor: color.white,
padding: 0,
margin: 0,
},
});
...@@ -25,6 +25,7 @@ import { isIphoneX } from '../../../utils/isPhoneX'; ...@@ -25,6 +25,7 @@ import { isIphoneX } from '../../../utils/isPhoneX';
import FadeDimBG from '../../../components/FadeDimBG'; import FadeDimBG from '../../../components/FadeDimBG';
import SlideUpModal from '../../../components/SlideUpModal'; import SlideUpModal from '../../../components/SlideUpModal';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { getTimers } from '../../../reduxStore/actions/timersAction';
// mock data // mock data
const MultipleMockData = [ const MultipleMockData = [
...@@ -203,23 +204,6 @@ class TimerScreen extends Component { ...@@ -203,23 +204,6 @@ class TimerScreen extends Component {
search: '', search: '',
}; };
// renderTimerFab = () => {
// return (
// <Fab
// containerStyle={{
// bottom: '15%',
// // right: '50%', // centerFAB
// // marginRight: -28,
// }}
// style={{ backgroundColor: color.primary }}
// position="bottomRight"
// onPress={() => this.setState({ isVisible: true })}
// >
// <Icon name="add" />
// </Fab>
// );
// };
autoCloseSwipeRow = swipeInstance => { autoCloseSwipeRow = swipeInstance => {
if (this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) { if (this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe.close(); this.currentlyOpenSwipe.close();
...@@ -258,8 +242,9 @@ class TimerScreen extends Component { ...@@ -258,8 +242,9 @@ class TimerScreen extends Component {
}; };
componentDidUpdate = (prevProps, prevState) => { componentDidUpdate = (prevProps, prevState) => {
prevState !== this.state && console.log(this.state); if (prevProps.timers !== this.props.timers) {
prevProps !== this.props && console.log(this.props); console.log('timers =>', this.props.timers || '');
}
}; };
render() { render() {
...@@ -279,7 +264,7 @@ class TimerScreen extends Component { ...@@ -279,7 +264,7 @@ class TimerScreen extends Component {
/> />
<Icon <Icon
name="md-funnel" name="md-funnel"
style={{ color: '#c7cad1', fontSize: 14, marginLeft: 10 }} style={{ color: '#c7cad1', fontSize: 20, marginLeft: 10, marginRight: 5 }}
onPress={() => this.setState({ isfilterVisible: true })} onPress={() => this.setState({ isfilterVisible: true })}
/> />
</View> </View>
...@@ -287,10 +272,11 @@ class TimerScreen extends Component { ...@@ -287,10 +272,11 @@ class TimerScreen extends Component {
{/* List Timer */} {/* List Timer */}
<FlatList <FlatList
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }} contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }}
data={MultipleMockData[0].timer} data={this.props.timers}
extraData={this.props.timers}
ListEmptyComponent={() => ( ListEmptyComponent={() => (
<View> <View>
<Text style={[theme.normalText, theme.mt2]}>No Subbreaker</Text> <Text style={[theme.normalText, theme.mt2]}>No timers</Text>
</View> </View>
)} )}
ItemSeparatorComponent={() => <View style={styles.separator} />} ItemSeparatorComponent={() => <View style={styles.separator} />}
...@@ -542,10 +528,20 @@ class TimerScreen extends Component { ...@@ -542,10 +528,20 @@ class TimerScreen extends Component {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo, allMainDeviceInfo: state.allMainDeviceReducer.allMainDeviceInfo,
timers: state.timersReducer.timers,
isLoading: state.timersReducer.isLoading,
selectedDeviceId: state.currentSelectedDeviceReducer.selectedDeviceId,
}); });
export default connect(mapStateToProps)(TimerScreen); const mapDispatchToProps = {
getTimers,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TimerScreen);
const pickerStyle = { const pickerStyle = {
inputIOS: { inputIOS: {
...@@ -569,7 +565,7 @@ const styles = StyleSheet.create({ ...@@ -569,7 +565,7 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
display: 'flex', display: 'flex',
backgroundColor: 'transparent', backgroundColor: 'transparent',
height: 30, height: 33,
paddingVertical: 0, paddingVertical: 0,
borderTopWidth: 0, borderTopWidth: 0,
borderBottomWidth: 0, borderBottomWidth: 0,
...@@ -579,10 +575,10 @@ const styles = StyleSheet.create({ ...@@ -579,10 +575,10 @@ const styles = StyleSheet.create({
borderBottomWidth: 1, borderBottomWidth: 1,
backgroundColor: 'transparent', backgroundColor: 'transparent',
minHeight: 10, minHeight: 10,
height: 30, height: 33,
borderColor: '#c7cad1', borderColor: '#c7cad1',
}, },
searchBarInput: { fontFamily: 'Avenir-Roman', fontSize: 12, color: color.grey }, searchBarInput: { fontFamily: 'Avenir-Roman', fontSize: 14, color: color.grey, marginTop: 3 },
separator: { separator: {
marginHorizontal: 10, marginHorizontal: 10,
height: StyleSheet.hairlineWidth, height: StyleSheet.hairlineWidth,
......
...@@ -5,28 +5,25 @@ import logo from '../../assets/images/logo2.png'; ...@@ -5,28 +5,25 @@ import logo from '../../assets/images/logo2.png';
import { width } from '../../constants/Layout'; import { width } from '../../constants/Layout';
import app from '../../firebase'; import app from '../../firebase';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { getAllDeviceInfo } from '../../reduxStore/actions/allDataAction';
import { getCurrentUser } from '../../reduxStore/actions/cerrentUserAction'; import { getCurrentUser } from '../../reduxStore/actions/cerrentUserAction';
import { getAllMainDeviceInfo } from '../../reduxStore/actions/allMainDeviceAction';
class AuthLoadingScreen extends Component { class AuthLoadingScreen extends Component {
static navigationOptions = { static navigationOptions = {
header: null, header: null,
}; };
constructor(props) {
super(props);
this._bootstrapAsync();
}
state = { state = {
isShowImg: true, isShowImg: true,
authentication: null, authentication: null,
alreadyLaunched: null,
RememberedLogin: null,
}; };
showLogoThenIndicator = () => { showLogoThenIndicator = () => {
setTimeout(() => { setTimeout(() => {
this.setState({ isShowImg: false }); this.setState({ isShowImg: false });
}, 1200); }, 1200); // 1200
}; };
_bootstrapAsync = async () => { _bootstrapAsync = async () => {
...@@ -38,46 +35,18 @@ class AuthLoadingScreen extends Component { ...@@ -38,46 +35,18 @@ class AuthLoadingScreen extends Component {
app.auth().onAuthStateChanged(async user => { app.auth().onAuthStateChanged(async user => {
if (user) { if (user) {
await this.props.getCurrentUser(); await this.props.getCurrentUser(user);
await this.props.getAllDeviceInfo(); await this.props.getAllMainDeviceInfo();
this.props.navigation.navigate(RememberedLogin ? 'Main' : 'Login'); this.props.navigation.navigate(RememberedLogin === 'true' ? 'Main' : 'Login');
} else { } else {
this.props.navigation.navigate(alreadyLaunched ? 'Login' : 'Onboarding'); this.props.navigation.navigate(alreadyLaunched === 'true' ? 'Login' : 'Onboarding');
} }
}); });
}; };
// componentDidMount = async () => { componentDidMount = async () => {
// this.showLogoThenIndicator(); await this._bootstrapAsync();
// // Preload data from an external API };
// // Preload data using AsyncStorage
// const alreadyLaunched = await AsyncStorage.getItem('alreadyLaunched');
// const RememberedLogin = await AsyncStorage.getItem('RememberedLogin');
// app.auth().onAuthStateChanged(async user => {
// if (user) {
// this.props.getCurrentUser && (await this.props.getCurrentUser());
// this.setState({ authentication: true });
// this.props.navigation.navigate(RememberedLogin ? 'Main' : 'Login');
// } else {
// this.setState({ authentication: false });
// this.props.navigation.navigate(alreadyLaunched ? 'Login' : 'Onboarding');
// }
// });
// };
// componentDidUpdate = async (prevProps, prevState) => {
// if (prevState.authentication !== this.state.authentication) {
// this.props.getCurrentUser && (await this.props.getCurrentUser());
// this.props.navigation.navigate(
// this.state.RememberedLogin
// ? 'Main'
// : this.state.authentication || this.state.alreadyLaunched
// ? 'Login'
// : 'Onboarding'
// );
// }
// };
render() { render() {
return ( return (
...@@ -98,12 +67,16 @@ class AuthLoadingScreen extends Component { ...@@ -98,12 +67,16 @@ class AuthLoadingScreen extends Component {
} }
} }
mapStateToProps = state => ({
uid: state.currentUserReducer.uid,
});
const mapDispatchToProps = { const mapDispatchToProps = {
getCurrentUser, getCurrentUser,
getAllDeviceInfo, getAllMainDeviceInfo,
}; };
export default connect( export default connect(
null, mapStateToProps,
mapDispatchToProps mapDispatchToProps
)(AuthLoadingScreen); )(AuthLoadingScreen);
...@@ -4491,6 +4491,16 @@ lodash.clone@^4.5.0: ...@@ -4491,6 +4491,16 @@ lodash.clone@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6" resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6"
integrity sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y= integrity sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=
lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=
lodash.flatten@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=
lodash.isequal@^4.5.0: lodash.isequal@^4.5.0:
version "4.5.0" version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
...@@ -4501,11 +4511,6 @@ lodash.merge@^4.6.1: ...@@ -4501,11 +4511,6 @@ lodash.merge@^4.6.1:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
lodash.sortby@^4.7.0: lodash.sortby@^4.7.0:
version "4.7.0" version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
...@@ -4526,7 +4531,7 @@ lodash@4.17.11: ...@@ -4526,7 +4531,7 @@ lodash@4.17.11:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1: lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
version "4.17.15" version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
...@@ -5873,14 +5878,6 @@ rc@^1.2.7: ...@@ -5873,14 +5878,6 @@ rc@^1.2.7:
minimist "^1.2.0" minimist "^1.2.0"
strip-json-comments "~2.0.1" strip-json-comments "~2.0.1"
react-addons-update@^15.6.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/react-addons-update/-/react-addons-update-15.6.2.tgz#e53753c5b34887974510c882d7fb075851d5e504"
integrity sha1-5TdTxbNIh5dFEMiC1/sHWFHV5QQ=
dependencies:
fbjs "^0.8.9"
object-assign "^4.1.0"
react-deep-force-update@^1.0.0: react-deep-force-update@^1.0.0:
version "1.1.2" version "1.1.2"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.2.tgz#3d2ae45c2c9040cbb1772be52f8ea1ade6ca2ee1" resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.2.tgz#3d2ae45c2c9040cbb1772be52f8ea1ade6ca2ee1"
...@@ -5931,10 +5928,10 @@ react-native-camera@^2.11.1: ...@@ -5931,10 +5928,10 @@ react-native-camera@^2.11.1:
dependencies: dependencies:
prop-types "^15.6.2" prop-types "^15.6.2"
react-native-date-picker@^2.5.1: react-native-date-picker@^2.7.0:
version "2.6.1" version "2.7.0"
resolved "https://registry.yarnpkg.com/react-native-date-picker/-/react-native-date-picker-2.6.1.tgz#ad322cc12a760ad7a2cabce18928652dd4f8b8f0" resolved "https://registry.yarnpkg.com/react-native-date-picker/-/react-native-date-picker-2.7.0.tgz#91c6cd85c45309763e58982c46fcf3dba2d1da55"
integrity sha512-9FVOMulMs5mWfjWcoEuHotIh5LiJPHvrSUEsHfiYW48kME3GF/nE0DyNg4qDuJFRsZr8mIdiNyLQHQbnhGKZ/Q== integrity sha512-pevfIzZ2jnYZe3jrDsUN2EM0fGcal3lL2aqExDux7d01C4QWOJJdHbut2URjL/EzS1v2ByLQJNT0ErjniheRiw==
dependencies: dependencies:
moment "^2.22.1" moment "^2.22.1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment