Skip to content

Commit

Permalink
feat(MQTT): 新增属性和后台配置字段hideSignalPop控制弱网提醒
Browse files Browse the repository at this point in the history
  • Loading branch information
曾照 committed Aug 4, 2020
1 parent 72ba25f commit bda7d3a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 13 deletions.
41 changes: 31 additions & 10 deletions lib/components/layout/navigator-layout/index.js
Expand Up @@ -155,21 +155,41 @@ var NavigatorLayout = function (_Component) {
_createClass(NavigatorLayout, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _props$devInfo = this.props.devInfo,
devInfo = _props$devInfo === undefined ? {} : _props$devInfo;
var _opts$hideSignalPop = this.opts.hideSignalPop,
hideSignalPopProps = _opts$hideSignalPop === undefined ? false : _opts$hideSignalPop;


var hideSignalPop = devInfo && devInfo.panelConfig && devInfo.panelConfig.fun && devInfo.panelConfig.fun.hideSignalPop;

if (_reactNative.Platform.OS === 'android') {
_reactNative.BackHandler.addEventListener('hardwareBackPress', this._onBack);
}

if (hideSignalPop || hideSignalPopProps) return;

_api2.default.receiverMqttData(23);
_api2.default.sendMqttData(22);

_TYNativeApi2.default.DeviceEventEmitter.addListener('receiveMqttData', this._handleMqttSignal);
_reactNative.AppState.addEventListener('change', this._handleAppStateChange);
if (_reactNative.Platform.OS === 'android') {
_reactNative.BackHandler.addEventListener('hardwareBackPress', this._onBack);
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
var _opts$hideSignalPop2 = this.opts.hideSignalPop,
hideSignalPopProps = _opts$hideSignalPop2 === undefined ? false : _opts$hideSignalPop2;


var hideSignalPop = devInfo && devInfo.panelConfig && devInfo.panelConfig.fun && devInfo.panelConfig.fun.hideSignalPop;

if (_reactNative.Platform.OS === 'android') {
_reactNative.BackHandler.removeEventListener('hardwareBackPress', this._onBack);
}

if (hideSignalPop || hideSignalPopProps) return;

_notification2.default.hide();
this.timer && clearTimeout(this.timer);
_TYNativeApi2.default.DeviceEventEmitter.removeListener('receiveMqttData', this._handleMqttSignal);
Expand All @@ -182,7 +202,7 @@ var NavigatorLayout = function (_Component) {
return _react2.default.createElement(Element, _extends({ navigator: navigator }, route, {
__source: {
fileName: _jsxFileName,
lineNumber: 88
lineNumber: 111
}
}));
}
Expand Down Expand Up @@ -230,6 +250,7 @@ var NavigatorLayout = function (_Component) {

var contentLayout = null;
var opts = this.hookRoute(route);
this.opts = opts;
var _opts$enablePopGestur = opts.enablePopGesture,
enablePopGesture = _opts$enablePopGestur === undefined ? true : _opts$enablePopGestur;

Expand Down Expand Up @@ -271,7 +292,7 @@ var NavigatorLayout = function (_Component) {
devInfo: devInfo,
__source: {
fileName: _jsxFileName,
lineNumber: 196
lineNumber: 220
}
},
contentLayout
Expand Down Expand Up @@ -303,7 +324,7 @@ var NavigatorLayout = function (_Component) {
devInfo: devInfo,
__source: {
fileName: _jsxFileName,
lineNumber: 216
lineNumber: 240
}
},
contentLayout
Expand All @@ -325,7 +346,7 @@ var NavigatorLayout = function (_Component) {
_reactNative.View,
{ style: { flex: 1 }, __source: {
fileName: _jsxFileName,
lineNumber: 250
lineNumber: 274
}
},
_react2.default.createElement(_reactNativeDeprecatedCustomComponents.Navigator, {
Expand All @@ -336,20 +357,20 @@ var NavigatorLayout = function (_Component) {
onWillFocus: this._onWillFocus,
__source: {
fileName: _jsxFileName,
lineNumber: 251
lineNumber: 275
}
}),
modalVisible && _react2.default.createElement(_detectNetModal2.default, { onClose: function onClose() {
return _this3.setState({ modalVisible: false });
}, __source: {
fileName: _jsxFileName,
lineNumber: 258
lineNumber: 282
}
}),
_react2.default.createElement(_portalOut2.default, {
__source: {
fileName: _jsxFileName,
lineNumber: 259
lineNumber: 283
}
})
);
Expand Down
30 changes: 27 additions & 3 deletions src/components/layout/navigator-layout/index.js
Expand Up @@ -62,20 +62,43 @@ export default class NavigatorLayout extends Component {
}

componentDidMount() {
const { devInfo = {} } = this.props;
const { hideSignalPop: hideSignalPopProps = false } = this.opts;

const hideSignalPop =
devInfo &&
devInfo.panelConfig &&
devInfo.panelConfig.fun &&
devInfo.panelConfig.fun.hideSignalPop;

if (Platform.OS === 'android') {
BackHandler.addEventListener('hardwareBackPress', this._onBack);
}

if (hideSignalPop || hideSignalPopProps) return;

TYNativeModules.receiverMqttData(23);
TYNativeModules.sendMqttData(22);

TYSdk.DeviceEventEmitter.addListener('receiveMqttData', this._handleMqttSignal);
AppState.addEventListener('change', this._handleAppStateChange);
if (Platform.OS === 'android') {
BackHandler.addEventListener('hardwareBackPress', this._onBack);
}
}

componentWillUnmount() {
const { hideSignalPop: hideSignalPopProps = false } = this.opts;

const hideSignalPop =
devInfo &&
devInfo.panelConfig &&
devInfo.panelConfig.fun &&
devInfo.panelConfig.fun.hideSignalPop;

if (Platform.OS === 'android') {
BackHandler.removeEventListener('hardwareBackPress', this._onBack);
}

if (hideSignalPop || hideSignalPopProps) return;

Notification.hide();
this.timer && clearTimeout(this.timer);
TYSdk.DeviceEventEmitter.removeListener('receiveMqttData', this._handleMqttSignal);
Expand Down Expand Up @@ -168,6 +191,7 @@ export default class NavigatorLayout extends Component {
dispatchRoute(route, navigator) {
let contentLayout = null;
const opts = this.hookRoute(route);
this.opts = opts;
const { enablePopGesture = true } = opts;
if ((!!opts.gesture || opts.id === 'main') && enablePopGesture) {
TYMobile.enablePopGesture();
Expand Down

0 comments on commit bda7d3a

Please sign in to comment.