Skip to content

Commit

Permalink
V1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
c19354837 committed May 7, 2018
1 parent a4fd179 commit 98d9b33
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions examples/SystemSettingExample/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Alert, Text, View, Slider, TouchableOpacity, PixelRatio, Switch, ActivityIndicator, ScrollView, Platform } from 'react-native';
import React, { Component } from 'react'
import { AppRegistry, StyleSheet, Alert, Text, View, Slider, TouchableOpacity, PixelRatio, Switch, ActivityIndicator, ScrollView, Platform } from 'react-native'

import SystemSetting from 'react-native-system-setting'

export default class SystemSettingExample extends Component {

isAndroid = Platform.OS === 'android'

volumeListener = null;
wifiListener = null;
bluetoothListener = null;
volumeListener = null
wifiListener = null
bluetoothListener = null
locationListener = null
airplaneListener = null

volTypes = ['music', 'system', 'call', 'ring', 'alarm', 'notification']
volIndex = 0
Expand Down Expand Up @@ -54,15 +56,19 @@ export default class SystemSettingExample extends Component {
})

this.wifiListener = await SystemSetting.addWifiListener((enable) => {
this.setState({
wifiEnable: enable,
})
this.setState({ wifiEnable: enable })
})

this.bluetoothListener = await SystemSetting.addBluetoothListener((enable) => {
this.setState({
bluetoothEnable: enable,
})
this.setState({ bluetoothEnable: enable })
})

this.locationListener = await SystemSetting.addLocationListener((enable) => {
this.setState({ locationEnable: enable })
})

this.airplaneListener = await SystemSetting.addAirplaneListener((enable) => {
this.setState({ airplaneEnable: enable })
})
}

Expand All @@ -76,6 +82,8 @@ export default class SystemSettingExample extends Component {
SystemSetting.removeListener(this.volumeListener)
SystemSetting.removeListener(this.wifiListener)
SystemSetting.removeListener(this.bluetoothListener)
SystemSetting.removeListener(this.locationListener)
SystemSetting.removeListener(this.airplaneListener)
}

_changeVol(value) {
Expand Down Expand Up @@ -237,7 +245,7 @@ export default class SystemSettingExample extends Component {
loading={airplaneStateLoading}
switchFunc={(value) => this._switchAirplane()} />
</ScrollView>
);
)
}
}

Expand Down Expand Up @@ -332,6 +340,6 @@ const styles = StyleSheet.create({
paddingVertical: 8,
color: '#405EFF'
}
});
})

AppRegistry.registerComponent('SystemSettingExample', () => SystemSettingExample);
AppRegistry.registerComponent('SystemSettingExample', () => SystemSettingExample)

0 comments on commit 98d9b33

Please sign in to comment.