Skip to content

Instantly share code, notes, and snippets.

@Minishlink
Created August 12, 2020 03:43
Show Gist options
  • Save Minishlink/fc60bce597cf3564d442c367418a89bf to your computer and use it in GitHub Desktop.
Save Minishlink/fc60bce597cf3564d442c367418a89bf to your computer and use it in GitHub Desktop.
react-native-snackbar for showing snackbar even when modal will disappear (eg loading overlay)
diff --git a/node_modules/react-native-snackbar/android/src/main/java/com/azendoo/reactnativesnackbar/SnackbarModule.java b/node_modules/react-native-snackbar/android/src/main/java/com/azendoo/reactnativesnackbar/SnackbarModule.java
index 0a405fb..c21c5b4 100644
--- a/node_modules/react-native-snackbar/android/src/main/java/com/azendoo/reactnativesnackbar/SnackbarModule.java
+++ b/node_modules/react-native-snackbar/android/src/main/java/com/azendoo/reactnativesnackbar/SnackbarModule.java
@@ -62,9 +62,11 @@ public class SnackbarModule extends ReactContextBaseJavaModule {
mActiveSnackbars.clear();
+ boolean shouldForceDisplayOnMainView = getOptionValue(options, "shouldForceDisplayOnMainView", false);
+
// `hasWindowFocus`: Returns true if this activity's *main* window currently has window focus.
// Note that this is not the same as the view itself having focus.
- if (!view.hasWindowFocus()) {
+ if (!view.hasWindowFocus() && !shouldForceDisplayOnMainView) {
// Get all modal views on the screen.
ArrayList<View> modals = recursiveLoopChildren(view, new ArrayList<View>());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment