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:
Christoph Nakazawa 2019-07-18 02:59:15 -07:00 коммит произвёл Facebook Github Bot
Родитель 93bebf146f
Коммит ba8f88d1ab
8 изменённых файлов: 50 добавлений и 69 удалений

Просмотреть файл

@ -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/.*/.*