From 8ccb861231a7cd620ad3cab8fc52088360082f22 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Thu, 29 Dec 2022 17:45:46 -0800 Subject: [PATCH] Reverting LoadingView change of native implementation of DevLoadingView (#35744) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35744 Changelog: [Android][Fixed] - LoadingView of Android to use the Toast till the native implementation is functional Reviewed By: lunaleaps Differential Revision: D42284732 fbshipit-source-id: dc187e4602240f270b2fbfb40e47604e3a14415d --- Libraries/Utilities/LoadingView.android.js | 45 ++++++---------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/Libraries/Utilities/LoadingView.android.js b/Libraries/Utilities/LoadingView.android.js index 0acf7c39bc68d7..03dd42d7907fb7 100644 --- a/Libraries/Utilities/LoadingView.android.js +++ b/Libraries/Utilities/LoadingView.android.js @@ -8,43 +8,20 @@ * @flow strict-local */ -import processColor from '../StyleSheet/processColor'; -import Appearance from './Appearance'; -import NativeDevLoadingView from './NativeDevLoadingView'; +import ToastAndroid from '../Components/ToastAndroid/ToastAndroid'; + +const TOAST_SHORT_DELAY = 2000; +let isVisible = false; module.exports = { showMessage(message: string, type: 'load' | 'refresh') { - if (NativeDevLoadingView) { - if (type === 'refresh') { - const backgroundColor = processColor('#2584e8'); - const textColor = processColor('#ffffff'); - - NativeDevLoadingView.showMessage( - message, - typeof textColor === 'number' ? textColor : null, - typeof backgroundColor === 'number' ? backgroundColor : null, - ); - } else if (type === 'load') { - let backgroundColor; - let textColor; - - if (Appearance.getColorScheme() === 'dark') { - backgroundColor = processColor('#fafafa'); - textColor = processColor('#242526'); - } else { - backgroundColor = processColor('#404040'); - textColor = processColor('#ffffff'); - } - - NativeDevLoadingView.showMessage( - message, - typeof textColor === 'number' ? textColor : null, - typeof backgroundColor === 'number' ? backgroundColor : null, - ); - } + if (!isVisible) { + ToastAndroid.show(message, ToastAndroid.SHORT); + isVisible = true; + setTimeout(() => { + isVisible = false; + }, TOAST_SHORT_DELAY); } }, - hide() { - NativeDevLoadingView && NativeDevLoadingView.hide(); - }, + hide() {}, };