Skip to content

Commit

Permalink
Support React Native's new architecture (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
henninghall committed Sep 10, 2023
1 parent f0bee76 commit 2127a4d
Show file tree
Hide file tree
Showing 39 changed files with 3,700 additions and 5,478 deletions.
File renamed without changes.
124 changes: 0 additions & 124 deletions .github/workflows/test-rn069.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: 1.8
java-version: 11
distribution: 'temurin'

- name: Install npm dependencies
working-directory: ./examples/detox
working-directory: ./examples/Rn072
run: |
yarn install --frozen-lockfile
- name: Run unit tests
working-directory: ./examples/detox/android
working-directory: ./examples/Rn072/android
run: ./gradlew testDebugUnitTest
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default () => {
| Prop | Description | Screenshots iOS | Screenshot Android |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `date` | The currently selected date. |
| `onDateChange` | Date change handler ( Inline only ) |
| `onDateChange` | Date change handler ( Inline only ) |
| `fadeToColor` | Android picker is fading towards this background color. {color, 'none'} |
| `maximumDate` | Maximum selectable date. <br/> Example: `new Date("2021-12-31")` |
| `minimumDate` | Minimum selectable date. <br/> Example: `new Date("2021-01-01")` |
Expand All @@ -145,7 +145,7 @@ export default () => {
| `title` | Modal only: Title text. Can be set to null to remove text. |
| `confirmText` | Modal only: Confirm button text. |
| `cancelText` | Modal only: Cancel button text. |
| `theme` | Modal only: The theme of the modal. `"light"`, `"dark"`, `"auto"`. Defaults to `"auto"`. |
| `theme` | Modal only: The theme of the modal. `"light"`, `"dark"`, `"auto"`. Defaults to `"auto"`. |

## Additional android styling

Expand Down Expand Up @@ -183,6 +183,10 @@ To change the font size on Android `nativeAndroid` variant. Open `styles.xml` an
</style>
```

## React Native's new architecture

This package supports React Native's new architecture (Fabric + Turbo Modules) from React Native 0.71 and forward. Support was introduced in version `4.3.0` of `react-native-date-picker`.

## Linking

This package supports automatic linking. Usually, the only thing you need to do is to install the package, the cocoapods dependencies (as described above). Then rebuild the project by running `react-native run-ios`, `react-native run-android` or start the build from within Xcode/Android Studio. If you're running a React Native version below 0.60 or your setup is having issues with automatic linking, you can run `npx react-native link react-native-date-picker` and rebuild. In some occations you'll have to manually link the package. Instructions in <a href="https://github.com/henninghall/react-native-date-picker/issues/40">this issue</a>.
Expand Down
46 changes: 45 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
apply plugin: 'com.android.library'

def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

if (isNewArchitectureEnabled()) {
apply plugin: 'com.facebook.react'
}

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
Expand All @@ -11,8 +19,18 @@ android {
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 18)
targetSdkVersion safeExtGet('targetSdkVersion', 25)

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ['src/newarch']
} else {
java.srcDirs += ['src/oldarch']
}
}
}
buildTypes {
release {
Expand All @@ -22,10 +40,36 @@ android {
}
}



if (isNewArchitectureEnabled()) {
buildscript {
repositories {
mavenCentral()
google()
}

dependencies {
classpath("com.android.tools.build:gradle:7.1.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
}
}
}


dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.facebook.react:react-native:+'
implementation 'com.github.henninghall:numberpickerview:v1.1.5'
implementation 'org.apache.commons:commons-lang3:3.8'
implementation group: 'net.time4j', name: 'time4j-android', version: '4.8-2021a'
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "RNDatePicker"
codegenJavaPackageName = "com.henninghall.date_picker"
}
}
Empty file modified android/gradlew
100644 → 100755
Empty file.

This file was deleted.

Loading

0 comments on commit 2127a4d

Please sign in to comment.