Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(upgrade): RN v74+ resolution #7886

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ module.exports = function (api) {
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from',
'react-native-reanimated/plugin',
'@babel/plugin-proposal-class-properties',
],
overrides: [
{
plugins: [['@babel/plugin-transform-private-methods']],
},
],
};
};
2 changes: 1 addition & 1 deletion lib/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def safeExtGetFallbackLowerBound(prop, fallback) {
}

def DEFAULT_COMPILE_SDK_VERSION = 33
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_MIN_SDK_VERSION = 23
def DEFAULT_TARGET_SDK_VERSION = 33
def DEFAULT_KOTLIN_VERSION = "1.5.31"
def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.views.text.ReactFontManager;
import com.facebook.react.views.text.ReactTextShadowNode;
import java.util.ArrayList;
Expand All @@ -27,12 +28,13 @@ public class ReactTypefaceUtils {
public static final int UNSET = -1;

public static int parseFontWeight(@Nullable String fontWeightString) {
int fontWeightNumeric =
fontWeightString != null ? parseNumericFontWeight(fontWeightString) : UNSET;
int fontWeightNumeric = fontWeightString != null ? parseNumericFontWeight(fontWeightString) : UNSET;
int fontWeight = fontWeightNumeric != UNSET ? fontWeightNumeric : Typeface.NORMAL;

if (fontWeight == 700 || "bold".equals(fontWeightString)) fontWeight = Typeface.BOLD;
else if (fontWeight == 400 || "normal".equals(fontWeightString)) fontWeight = Typeface.NORMAL;
if (fontWeight == 700 || "bold".equals(fontWeightString))
fontWeight = Typeface.BOLD;
else if (fontWeight == 400 || "normal".equals(fontWeightString))
fontWeight = Typeface.NORMAL;

return fontWeight;
}
Expand Down Expand Up @@ -96,19 +98,20 @@ public static Typeface applyStyles(

int want = 0;
if ((weight == Typeface.BOLD)
|| ((oldStyle & Typeface.BOLD) != 0 && weight == ReactTextShadowNode.UNSET)) {
|| ((oldStyle & Typeface.BOLD) != 0 && weight == ReactConstants.UNSET)) {
want |= Typeface.BOLD;
}

if ((style == Typeface.ITALIC)
|| ((oldStyle & Typeface.ITALIC) != 0 && style == ReactTextShadowNode.UNSET)) {
|| ((oldStyle & Typeface.ITALIC) != 0 && style == ReactConstants.UNSET)) {
want |= Typeface.ITALIC;
}

if (family != null) {
typeface = ReactFontManager.getInstance().getTypeface(family, want, weight, assetManager);
} else if (typeface != null) {
// TODO(t9055065): Fix custom fonts getting applied to text children with different style
// TODO(t9055065): Fix custom fonts getting applied to text children with
// different style
typeface = Typeface.create(typeface, want);
}

Expand All @@ -120,16 +123,18 @@ public static Typeface applyStyles(
}

/**
* Return -1 if the input string is not a valid numeric fontWeight (100, 200, ..., 900), otherwise
* Return -1 if the input string is not a valid numeric fontWeight (100, 200,
* ..., 900), otherwise
* return the weight.
*/
private static int parseNumericFontWeight(String fontWeightString) {
// This should be much faster than using regex to verify input and Integer.parseInt
// This should be much faster than using regex to verify input and
// Integer.parseInt
return fontWeightString.length() == 3
&& fontWeightString.endsWith("00")
&& fontWeightString.charAt(0) <= '9'
&& fontWeightString.charAt(0) >= '1'
? 100 * (fontWeightString.charAt(0) - '0')
: UNSET;
&& fontWeightString.endsWith("00")
&& fontWeightString.charAt(0) <= '9'
&& fontWeightString.charAt(0) >= '1'
? 100 * (fontWeightString.charAt(0) - '0')
: UNSET;
}
}
3 changes: 1 addition & 2 deletions lib/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Thu Jan 04 11:01:32 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@
"@babel/core": "7.22.9",
"@babel/plugin-proposal-export-default-from": "7.10.1",
"@babel/plugin-proposal-export-namespace-from": "7.10.1",
"@babel/plugin-transform-private-methods": "^7.24.7",
"@babel/preset-env": "^7.22.9",
"@babel/runtime": "7.22.6",
"@babel/types": "7.22.5",
"@babel/preset-env": "^7.22.9",
"@react-native/metro-config": "^0.73.2",
"@react-native/babel-preset": "^0.73.18",
"@react-native/typescript-config": "^0.73.1",
"@react-native-community/blur": "^3.6.0",
"@react-native-community/datetimepicker": "^3.4.7",
"@react-native-community/eslint-config": "2.0.0",
"@react-native-community/netinfo": "^5.9.4",
"@react-native/babel-preset": "^0.74.84",
"@react-native/metro-config": "^0.74.84",
"@react-native/typescript-config": "^0.74.84",
"@testing-library/jest-native": "^5.4.2",
"@testing-library/react-native": "^12.0.1",
"@types/hoist-non-react-statics": "^3.0.1",
Expand Down Expand Up @@ -109,7 +110,7 @@
"pngjs": "^6.0.0",
"prettier": "2.1.2",
"react": "18.2.0",
"react-native": "0.73.3",
"react-native": "0.74.2",
"react-native-fast-image": "^8.6.3",
"react-native-gesture-handler": "^2.10.1",
"react-native-reanimated": "^3.8.1",
Expand Down
2 changes: 1 addition & 1 deletion playground/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {

defaultConfig {
applicationId "com.reactnativenavigation.playground"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion rootProject.ext.get("targetSdkVersion")
versionCode 1
versionName "1.0"
Expand Down
2 changes: 1 addition & 1 deletion playground/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
detoxKotlinVersion = kotlinVersion
compileSdkVersion = 34
buildToolsVersion = "34.0.0"
minSdkVersion = 21
minSdkVersion = 23
targetSdkVersion = 34
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
Expand Down
Loading