axelra-ag / react-native-animateable-text

🆎 A fork of React Native's <Text/> component that supports Animated Values!
https://www.npmjs.com/package/react-native-animateable-text
MIT License
360 stars 27 forks source link

Not compatible with RN 0.71.7 #40

Closed XantreDev closed 1 year ago

XantreDev commented 1 year ago

Cannot build

Patch:

--- a/node_modules/react-native-animateable-text/android/src/main/java/com/reactnativereanimatedtext/JBTextViewManager.java
+++ b/node_modules/react-native-animateable-text/android/src/main/java/com/reactnativereanimatedtext/JBTextViewManager.java
@@ -8,8 +8,10 @@
 package com.reactnativereanimatedtext;

 import android.content.Context;
+import android.os.Build;
 import android.text.Spannable;
 import androidx.annotation.Nullable;
+import android.view.Gravity;
 import com.facebook.react.bridge.ReadableMap;
 import com.facebook.react.bridge.ReadableNativeMap;
 import com.facebook.react.common.MapBuilder;
@@ -104,14 +106,18 @@ public class JBTextViewManager

     int textBreakStrategy =
       TextAttributeProps.getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy"));
+    int currentJustificationMode =
+        Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();

     return new ReactTextUpdate(
-      spanned,
-      state.hasKey("mostRecentEventCount") ? state.getInt("mostRecentEventCount") : -1,
-      false, // TODO add this into local Data
-      TextAttributeProps.getTextAlignment(props, TextLayoutManager.isRTL(attributedString)),
-      textBreakStrategy,
-      TextAttributeProps.getJustificationMode(props));
+        spanned,
+        state.hasKey("mostRecentEventCount") ? state.getInt("mostRecentEventCount") : -1,
+        false, // TODO add this into local Data
+        TextAttributeProps.getTextAlignment(
+            props, TextLayoutManager.isRTL(attributedString), Gravity.LEFT
+            /*  there should be: `view.getGravityHorizontal()` but its not public method */ ),
+        textBreakStrategy,
+        TextAttributeProps.getJustificationMode(props, currentJustificationMode));
   }

   @Override
XantreDev commented 1 year ago

But there are problem: / there should be: view.getGravityHorizontal() but its not public method /

XantreDev commented 1 year ago

https://github.com/facebook/react-native/commit/31a8e92caddcdbef9fe74de53e7f412a7e998591 This is related with this fixes

XantreDev commented 1 year ago

Should i create issue to they make this issue private?

radko93 commented 1 year ago

@XantreGodlike I think it's a good idea to create an issue on React Native so they make view.getGravityHorizontal accessible.

JonnyBurger commented 1 year ago

Thanks for raising! I'll merge it and make a new release if you manage to provide a working PR.

XantreDev commented 1 year ago

Ok. I will provide PR soon