Rename HMRLoadingView to LoadingView
Summary: This view will be re-used for bundle splitting so I'm changing the name to be more generic as it can be used for informing users of any loading activity. I also cleaned up the files a bit from a class to just an object. Reviewed By: gaearon Differential Revision: D16281367 fbshipit-source-id: 5c2ee7790d29ccba473bd6e90737d2f0581e6291
This commit is contained in:
Родитель
93bebf146f
Коммит
ba8f88d1ab
|
@ -19,7 +19,7 @@
|
|||
.*/node_modules/warning/.*
|
||||
|
||||
; Flow doesn't support platforms
|
||||
.*/Libraries/Utilities/HMRLoadingView.js
|
||||
.*/Libraries/Utilities/LoadingView.js
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/@react-native-community/cli/.*/.*
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
.*/node_modules/warning/.*
|
||||
|
||||
; Flow doesn't support platforms
|
||||
.*/Libraries/Utilities/HMRLoadingView.js
|
||||
.*/Libraries/Utilities/LoadingView.js
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/@react-native-community/cli/.*/.*
|
||||
|
|
|
@ -107,7 +107,7 @@ const HMRClient: HMRClientNativeInterface = {
|
|||
invariant(!hmrClient, 'Cannot initialize hmrClient twice');
|
||||
|
||||
// Moving to top gives errors due to NativeModules not being initialized
|
||||
const HMRLoadingView = require('./HMRLoadingView');
|
||||
const LoadingView = require('./LoadingView');
|
||||
|
||||
const wsHost = port !== null && port !== '' ? `${host}:${port}` : host;
|
||||
const client = new MetroHMRClient(`ws://${wsHost}/hot`);
|
||||
|
@ -172,7 +172,7 @@ Error: ${e.message}`;
|
|||
|
||||
client.on('update-start', () => {
|
||||
if (isFastRefreshActive()) {
|
||||
HMRLoadingView.showMessage('Refreshing...');
|
||||
LoadingView.showMessage('Refreshing...');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -183,11 +183,11 @@ Error: ${e.message}`;
|
|||
});
|
||||
|
||||
client.on('update-done', () => {
|
||||
HMRLoadingView.hide();
|
||||
LoadingView.hide();
|
||||
});
|
||||
|
||||
client.on('error', data => {
|
||||
HMRLoadingView.hide();
|
||||
LoadingView.hide();
|
||||
|
||||
if (data.type === 'GraphNotFoundError') {
|
||||
client.disable();
|
||||
|
@ -212,7 +212,7 @@ Error: ${e.message}`;
|
|||
});
|
||||
|
||||
client.on('close', data => {
|
||||
HMRLoadingView.hide();
|
||||
LoadingView.hide();
|
||||
setHMRUnavailableReason(
|
||||
'Disconnected from the Metro server. Fast Refresh will be disabled until you reload the application.',
|
||||
);
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const ToastAndroid = require('../Components/ToastAndroid/ToastAndroid');
|
||||
|
||||
const TOAST_SHORT_DELAY = 2000;
|
||||
|
||||
class HMRLoadingView {
|
||||
static _showing: boolean;
|
||||
|
||||
static showMessage(message: string) {
|
||||
if (HMRLoadingView._showing) {
|
||||
return;
|
||||
}
|
||||
ToastAndroid.show(message, ToastAndroid.SHORT);
|
||||
HMRLoadingView._showing = true;
|
||||
setTimeout(() => {
|
||||
HMRLoadingView._showing = false;
|
||||
}, TOAST_SHORT_DELAY);
|
||||
}
|
||||
|
||||
static hide() {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HMRLoadingView;
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import ToastAndroid from '../Components/ToastAndroid/ToastAndroid';
|
||||
|
||||
const TOAST_SHORT_DELAY = 2000;
|
||||
let isVisible = false;
|
||||
|
||||
module.exports = {
|
||||
showMessage(message: string) {
|
||||
if (!isVisible) {
|
||||
ToastAndroid.show(message, ToastAndroid.SHORT);
|
||||
isVisible = true;
|
||||
setTimeout(() => {
|
||||
isVisible = false;
|
||||
}, TOAST_SHORT_DELAY);
|
||||
}
|
||||
},
|
||||
hide() {},
|
||||
};
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const processColor = require('../StyleSheet/processColor');
|
||||
import processColor from '../StyleSheet/processColor';
|
||||
import NativeDevLoadingView from './NativeDevLoadingView';
|
||||
|
||||
class HMRLoadingView {
|
||||
static showMessage(message: string) {
|
||||
if (NativeDevLoadingView != null) {
|
||||
module.exports = {
|
||||
showMessage(message: string) {
|
||||
if (NativeDevLoadingView) {
|
||||
NativeDevLoadingView.showMessage(
|
||||
message,
|
||||
// Use same colors as iOS "Personal Hotspot" bar.
|
||||
|
@ -23,13 +23,8 @@ class HMRLoadingView {
|
|||
processColor('#2584e8'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static hide() {
|
||||
if (NativeDevLoadingView != null) {
|
||||
NativeDevLoadingView.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HMRLoadingView;
|
||||
},
|
||||
hide() {
|
||||
NativeDevLoadingView && NativeDevLoadingView.hide();
|
||||
},
|
||||
};
|
|
@ -10,14 +10,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
class HMRLoadingView {
|
||||
static showMessage(message: string) {
|
||||
// noop
|
||||
}
|
||||
|
||||
static hide() {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HMRLoadingView;
|
||||
module.exports = {
|
||||
showMessage(message: string) {},
|
||||
hide() {},
|
||||
};
|
|
@ -13,7 +13,7 @@ node_modules/react-native/Libraries/polyfills/.*
|
|||
node_modules/warning/.*
|
||||
|
||||
; Flow doesn't support platforms
|
||||
.*/Libraries/Utilities/HMRLoadingView.js
|
||||
.*/Libraries/Utilities/LoadingView.js
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/@react-native-community/cli/.*/.*
|
||||
|
|
Загрузка…
Ссылка в новой задаче