Skip to content

NightMode in v 7.0.3 #996

Description

@chhamza

In version 6.7.7 patch for nightMode worked but in v7.0.3 its not working. Does anybody tried this?

diff --git a/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java b/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java
index 4186f17..aa8e33d 100644
--- a/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java
+++ b/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java
@@ -47,6 +47,12 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
         mDelegate = new RNPDFPdfViewManagerDelegate<>(this);
     }

+    @Override
+    @ReactProp(name = "nightMode", defaultBoolean = false)
+    public void setNightMode(PdfView view, boolean value) {
+      view.setNightMode(value);
+    }
+
     @Override
     public String getName() {
         return REACT_CLASS;
@@ -174,7 +180,7 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
     @Override
     public void onAfterUpdateTransaction(PdfView pdfView) {
         super.onAfterUpdateTransaction(pdfView);
-        pdfView.drawPdf();
+        //pdfView.drawPdf();
     }

 }
diff --git a/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfView.java b/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfView.java
index 7b7a125..4532b52 100644
--- a/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfView.java
+++ b/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfView.java
@@ -88,6 +88,12 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
         super(context, set);
     }

+    // PdfView.java
+    public void setNightMode(boolean nightMode) {
+      super.setNightMode(nightMode);
+      this.invalidate();
+    }
+
     @Override
     public void onPageChanged(int page, int numberOfPages) {
         // pdf lib page start from 0, convert it to our page (start from 1)
@@ -346,7 +352,8 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl

     // page start from 1
     public void setPage(int page) {
-        this.page = page>1?page:1;
+      this.page = page > 1 ? page : 1;
+      this.jumpTo(this.page - 1);
     }

     public void setScale(float scale) {
diff --git a/node_modules/react-native-pdf/fabric/RNPDFPdfNativeComponent.js b/node_modules/react-native-pdf/fabric/RNPDFPdfNativeComponent.js
index 43fea3b..226cc7c 100644
--- a/node_modules/react-native-pdf/fabric/RNPDFPdfNativeComponent.js
+++ b/node_modules/react-native-pdf/fabric/RNPDFPdfNativeComponent.js
@@ -32,6 +32,7 @@
    password: ?string,
    onChange: ?BubblingEventHandler<ChangeEvent>,
    singlePage: ?boolean,
+   nightMode: ?boolean;
  |}>;

  interface NativeCommands {
diff --git a/node_modules/react-native-pdf/index.d.ts b/node_modules/react-native-pdf/index.d.ts
index c75e1c3..65acbe8 100644
--- a/node_modules/react-native-pdf/index.d.ts
+++ b/node_modules/react-native-pdf/index.d.ts
@@ -47,6 +47,7 @@ export interface PdfProps {
     enableRTL?: boolean,
     enableAnnotationRendering?: boolean,
     enableDoubleTapZoom?: boolean;
+    nightMode?: boolean;
     /**
      * Fit policy.  This will adjust the initial zoom of the PDF based on the initial size of the view and the scale factor.
      * 0 = fit width

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions