Commit 7cb8077e by HaOuiha

update

parent cd1feaf6
...@@ -8,8 +8,8 @@ import { width } from '../../../constants/Layout'; ...@@ -8,8 +8,8 @@ import { width } from '../../../constants/Layout';
import { Overlay } from 'react-native-elements'; import { Overlay } from 'react-native-elements';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { updateDetail } from '../../../reduxStore/actions/currentSelectedAction'; import { updateDetail } from '../../../reduxStore/actions/currentSelectedAction';
import Slider from 'react-native-slider'; import Slider from 'react-native-slider';
import Modal from 'react-native-modalbox';
class updateDetailScreen extends Component { class updateDetailScreen extends Component {
static navigationOptions = ({ navigation }) => { static navigationOptions = ({ navigation }) => {
...@@ -116,7 +116,7 @@ class updateDetailScreen extends Component { ...@@ -116,7 +116,7 @@ class updateDetailScreen extends Component {
) : ( ) : (
<View style={styles.textInputContainer}> <View style={styles.textInputContainer}>
<TextInput <TextInput
multiline={true} multiline={this.state.field === 'Description' ? true : false}
style={[theme.description, { fontSize: 14 }]} style={[theme.description, { fontSize: 14 }]}
onChangeText={data => this.setState({ data })} onChangeText={data => this.setState({ data })}
value={data} value={data}
...@@ -127,7 +127,31 @@ class updateDetailScreen extends Component { ...@@ -127,7 +127,31 @@ class updateDetailScreen extends Component {
<Button full style={styles.saveButton} onPress={() => this.toggleModal(true)}> <Button full style={styles.saveButton} onPress={() => this.toggleModal(true)}>
<Text style={[theme.normalText, theme.textWhite]}>SAVE</Text> <Text style={[theme.normalText, theme.textWhite]}>SAVE</Text>
</Button> </Button>
<Overlay <Modal
coverScreen
swipeToClose={false}
animationDuration={250}
style={{ height: '25%', width: '90%', borderRadius: 20 }}
position={'center'}
isOpen={isVisible}
onClosed={() => this.toggleModal(false)}
>
<View style={styles.overlayStyle}>
<Text style={[theme.normalText, theme.textDark, theme.centerText, { marginHorizontal: 30 }]}>
Are you sure you want to save this item?
</Text>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Button transparent style={{ width: '40%' }} onPress={() => this.toggleModal(false)}>
<Text style={{ color: color.grey }}>CANCEL</Text>
</Button>
<Button style={styles.saveButtonModal} rounded onPress={() => this.handleConfirm()}>
<Text>SAVE</Text>
</Button>
</View>
</View>
</Modal>
{/* <Overlay
borderRadius={20} borderRadius={20}
height={'25%'} height={'25%'}
width={'90%'} width={'90%'}
...@@ -148,7 +172,7 @@ class updateDetailScreen extends Component { ...@@ -148,7 +172,7 @@ class updateDetailScreen extends Component {
</Button> </Button>
</View> </View>
</> </>
</Overlay> </Overlay> */}
</View> </View>
); );
} }
...@@ -166,6 +190,7 @@ export default connect( ...@@ -166,6 +190,7 @@ export default connect(
const styles = StyleSheet.create({ const styles = StyleSheet.create({
overlayStyle: { overlayStyle: {
padding: 20, padding: 20,
flex: 1,
alignItems: 'center', alignItems: 'center',
justifyContent: 'space-around', justifyContent: 'space-around',
}, },
......
...@@ -23,7 +23,7 @@ export default class WifiSelectScreen extends React.Component { ...@@ -23,7 +23,7 @@ export default class WifiSelectScreen extends React.Component {
), ),
}; };
}; };
renderWifiList() { renderWifiList = () => {
return ( return (
<FlatList <FlatList
data={mock.filter(x => x.connected === false)} data={mock.filter(x => x.connected === false)}
...@@ -34,15 +34,13 @@ export default class WifiSelectScreen extends React.Component { ...@@ -34,15 +34,13 @@ export default class WifiSelectScreen extends React.Component {
style={{ marginBottom: isIphoneX() ? 100 : 65 }} style={{ marginBottom: isIphoneX() ? 100 : 65 }}
/> />
); );
} };
renderWifiCard(item) { renderWifiCard = item => {
return ( return (
<TouchableOpacity <TouchableOpacity
style={[ style={[
styles.cardContainer, styles.cardContainer,
{ { backgroundColor: item.connected ? 'rgba(238,84,84,0.2)' : color.white },
backgroundColor: item.connected ? 'rgba(238,84,84,0.2)' : color.white,
},
]} ]}
> >
<View style={[theme.rowContainer, { justifyContent: 'space-between' }]}> <View style={[theme.rowContainer, { justifyContent: 'space-between' }]}>
...@@ -61,7 +59,7 @@ export default class WifiSelectScreen extends React.Component { ...@@ -61,7 +59,7 @@ export default class WifiSelectScreen extends React.Component {
</View> </View>
</TouchableOpacity> </TouchableOpacity>
); );
} };
render() { render() {
return ( return (
<ScrollView style={[theme.container, {}]}> <ScrollView style={[theme.container, {}]}>
......
...@@ -228,9 +228,7 @@ class McbLinkScreen extends React.Component { ...@@ -228,9 +228,7 @@ class McbLinkScreen extends React.Component {
} }
}} }}
ItemSeparatorComponent={() => <View style={{ margin: 5 }} />} ItemSeparatorComponent={() => <View style={{ margin: 5 }} />}
keyExtractor={(item, index) => { keyExtractor={(item, index) => `elec${index}`}
`elec${index}`;
}}
key={`scrollPage${index}`} key={`scrollPage${index}`}
/> />
); );
...@@ -296,11 +294,7 @@ class McbLinkScreen extends React.Component { ...@@ -296,11 +294,7 @@ class McbLinkScreen extends React.Component {
<TextInput <TextInput
placeholder="Device name" placeholder="Device name"
style={[theme.normalText, { width: '100%' }]} style={[theme.normalText, { width: '100%' }]}
onChangeText={text => onChangeText={text => this.setState({ deviceName: text })}
this.setState({
deviceName: text,
})
}
value={deviceName} value={deviceName}
/> />
</View> </View>
...@@ -333,10 +327,7 @@ class McbLinkScreen extends React.Component { ...@@ -333,10 +327,7 @@ class McbLinkScreen extends React.Component {
<Image <Image
style={[ style={[
styles.electronicIcon, styles.electronicIcon,
{ { tintColor: dynamicColor, resizeMode: 'contain' },
tintColor: dynamicColor,
resizeMode: 'contain',
},
]} ]}
source={getDeviceIcon(item.type)} source={getDeviceIcon(item.type)}
/> />
...@@ -412,7 +403,7 @@ class McbLinkScreen extends React.Component { ...@@ -412,7 +403,7 @@ class McbLinkScreen extends React.Component {
animationDuration={360} animationDuration={360}
style={[styles.addModal]} style={[styles.addModal]}
position={'bottom'} position={'bottom'}
isOpen={this.state.isAddElectronicVisible} visible={this.state.isAddElectronicVisible}
onClosed={() => this.setState({ isAddElectronicVisible: false })} onClosed={() => this.setState({ isAddElectronicVisible: false })}
> >
{this.renderAddModal()} {this.renderAddModal()}
......
...@@ -179,7 +179,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -179,7 +179,7 @@ class SmartMeterDetailScreen extends Component {
<Card style={{ padding: 15, marginBottom: 20, borderRadius: 10, borderColor: color.white }}> <Card style={{ padding: 15, marginBottom: 20, borderRadius: 10, borderColor: color.white }}>
<Row style={{ justifyContent: 'center', alignItems: 'center' }}> <Row style={{ justifyContent: 'center', alignItems: 'center' }}>
<Left> <Left>
<Text style={[theme.smallTitle, { color: color.darkGrey }]}>{name || 'Untitled'}</Text> <Text style={[theme.smallTitle, { color: color.darkGrey }]}>{name}</Text>
</Left> </Left>
<Right> <Right>
<Switch <Switch
...@@ -361,12 +361,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -361,12 +361,7 @@ class SmartMeterDetailScreen extends Component {
}; };
return ( return (
<Card <Card style={{ borderColor: color.white, borderRadius: 8 }}>
style={{
borderColor: color.white,
borderRadius: 8,
}}
>
<Row <Row
style={{ paddingVertical: 7, paddingLeft: 7, paddingRight: Platform.OS === 'android' ? 12 : 7 }} style={{ paddingVertical: 7, paddingLeft: 7, paddingRight: Platform.OS === 'android' ? 12 : 7 }}
onPress={handleOnPressMcbLink} onPress={handleOnPressMcbLink}
...@@ -451,7 +446,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -451,7 +446,7 @@ class SmartMeterDetailScreen extends Component {
/> />
) : ( ) : (
<View style={{ marginTop: 20 }}> <View style={{ marginTop: 20 }}>
<Text>{this.props.error}</Text> <Text>{'Something went wrong ' + this.props.error}</Text>
</View> </View>
) )
// </Card> // </Card>
......
...@@ -129,7 +129,7 @@ class SmartMeterScreen extends PureComponent { ...@@ -129,7 +129,7 @@ class SmartMeterScreen extends PureComponent {
</> </>
) : ( ) : (
<View> <View>
<Text>{error}</Text> <Text>{'Something went wrong ' + error}</Text>
</View> </View>
); );
} }
...@@ -165,9 +165,7 @@ const mapStateToProps = state => ({ ...@@ -165,9 +165,7 @@ const mapStateToProps = state => ({
error: state.allMainDeviceReducer.error, error: state.allMainDeviceReducer.error,
}); });
const mapDispatchToProps = { const mapDispatchToProps = { getAllMainDeviceInfo };
getAllMainDeviceInfo,
};
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -29,19 +29,16 @@ class AuthLoadingScreen extends Component { ...@@ -29,19 +29,16 @@ class AuthLoadingScreen extends Component {
}, 900); // 1200 }, 900); // 1200
}; };
_bootstrapAsync = async () => { bootstrapAsync = async () => {
this.showLogoThenIndicator(); this.showLogoThenIndicator();
try { try {
// Preload data from an external API // Preload data from an external API && Preload data using AsyncStorage
// Preload data using AsyncStorage
const alreadyLaunched = await AsyncStorage.getItem('alreadyLaunched'); const alreadyLaunched = await AsyncStorage.getItem('alreadyLaunched');
const RememberedLogin = await AsyncStorage.getItem('RememberedLogin'); const RememberedLogin = await AsyncStorage.getItem('RememberedLogin');
app.auth().onAuthStateChanged(async user => { app.auth().onAuthStateChanged(async user => {
if (user) { if (user) {
console.log(user); console.log(user);
// const idToken = await app.auth().currentUser.getIdToken(/* forceRefresh */ true);
// console.log(idToken);
await this.props.getCurrentUser(user); await this.props.getCurrentUser(user);
this.props.navigation.navigate(RememberedLogin === 'true' ? 'Main' : 'Login'); this.props.navigation.navigate(RememberedLogin === 'true' ? 'Main' : 'Login');
// createMockData(); // createMockData();
...@@ -56,7 +53,7 @@ class AuthLoadingScreen extends Component { ...@@ -56,7 +53,7 @@ class AuthLoadingScreen extends Component {
componentDidMount = () => { componentDidMount = () => {
this._isMounted = true; this._isMounted = true;
this._bootstrapAsync(); this.bootstrapAsync();
}; };
componentWillUnmount = () => { componentWillUnmount = () => {
...@@ -67,13 +64,7 @@ class AuthLoadingScreen extends Component { ...@@ -67,13 +64,7 @@ class AuthLoadingScreen extends Component {
return ( return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
{this.state.isShowImg ? ( {this.state.isShowImg ? (
<Image <Image style={{ width: width * 0.9, resizeMode: 'contain' }} source={logo} />
style={{
width: width * 0.9,
resizeMode: 'contain',
}}
source={logo}
/>
) : ( ) : (
<ActivityIndicator size="large" color="#f44c4c" /> <ActivityIndicator size="large" color="#f44c4c" />
)} )}
......
...@@ -21,7 +21,7 @@ export default class LoginScreen extends Component { ...@@ -21,7 +21,7 @@ export default class LoginScreen extends Component {
const { username, password } = values; const { username, password } = values;
try { try {
await app.auth().signInWithEmailAndPassword(username, password); await app.auth().signInWithEmailAndPassword(username, password);
this.success(); await this.success();
} catch (error) { } catch (error) {
alert(error); alert(error);
} }
......
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