Skip to content

Commit

Permalink
Reverting LoadingView change of native implementation of DevLoadingVi…
Browse files Browse the repository at this point in the history
…ew (#35744)

Summary:
Pull Request resolved: #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
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Dec 30, 2022
1 parent 068a208 commit 8ccb861
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions Libraries/Utilities/LoadingView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {},
};

0 comments on commit 8ccb861

Please sign in to comment.