Skip to content

Commit dd9287e

Browse files
committed
Merge branch 'master' of github.com:wix/react-native-calendars into release
2 parents f357f3c + 5071c3a commit dd9287e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2110
-856
lines changed

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

.editorconfig

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ fastlane/report.xml
6161
fastlane/Preview.html
6262
fastlane/screenshots
6363

64-
# CocoaPods
64+
# Ruby / CocoaPods
6565
ios/Pods
6666
ios/Podfile.lock
67+
/vendor/bundle/
6768

6869
.eslintcache
6970
.reassure

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"bracketSpacing": false,
55
"arrowParens": "avoid",
66
"trailingComma": "none",
7-
"jsxBracketSameLine": false
7+
"bracketSameLine": false
88
}

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.4

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
3+
ruby '2.7.4'
4+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ This project is compatible with Expo/CRNA (without ejecting), and the examples h
2929

3030
## Installation
3131

32+
Using NPM:
3233
```
3334
$ npm install --save react-native-calendars
3435
```
3536

37+
Using Yarn:
38+
```
39+
$ yarn add react-native-calendars
40+
```
41+
3642
The solution is implemented in JavaScript so no native module linking is required.
3743

3844
## Usage

android/app/build.gradle

Lines changed: 225 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,224 @@
11
apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
4+
import org.apache.tools.ant.taskdefs.condition.Os
5+
6+
/**
7+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
8+
* and bundleReleaseJsAndAssets).
9+
* These basically call `react-native bundle` with the correct arguments during the Android build
10+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
11+
* bundle directly from the development server. Below you can see all the possible configurations
12+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
13+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
14+
*
15+
* project.ext.react = [
16+
* // the name of the generated asset file containing your JS bundle
17+
* bundleAssetName: "index.android.bundle",
18+
*
19+
* // the entry file for bundle generation. If none specified and
20+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
21+
* // default. Can be overridden with ENTRY_FILE environment variable.
22+
* entryFile: "index.android.js",
23+
*
24+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
25+
* bundleCommand: "ram-bundle",
26+
*
27+
* // whether to bundle JS and assets in debug mode
28+
* bundleInDebug: false,
29+
*
30+
* // whether to bundle JS and assets in release mode
31+
* bundleInRelease: true,
32+
*
33+
* // whether to bundle JS and assets in another build variant (if configured).
34+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
35+
* // The configuration property can be in the following formats
36+
* // 'bundleIn${productFlavor}${buildType}'
37+
* // 'bundleIn${buildType}'
38+
* // bundleInFreeDebug: true,
39+
* // bundleInPaidRelease: true,
40+
* // bundleInBeta: true,
41+
*
42+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
43+
* // for example: to disable dev mode in the staging build type (if configured)
44+
* devDisabledInStaging: true,
45+
* // The configuration property can be in the following formats
46+
* // 'devDisabledIn${productFlavor}${buildType}'
47+
* // 'devDisabledIn${buildType}'
48+
*
49+
* // the root of your project, i.e. where "package.json" lives
50+
* root: "../../",
51+
*
52+
* // where to put the JS bundle asset in debug mode
53+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
54+
*
55+
* // where to put the JS bundle asset in release mode
56+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
57+
*
58+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
59+
* // require('./image.png')), in debug mode
60+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
61+
*
62+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
63+
* // require('./image.png')), in release mode
64+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
65+
*
66+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
67+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
68+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
69+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
70+
* // for example, you might want to remove it from here.
71+
* inputExcludes: ["android/**", "ios/**"],
72+
*
73+
* // override which node gets called and with what additional arguments
74+
* nodeExecutableAndArgs: ["node"],
75+
*
76+
* // supply additional arguments to the packager
77+
* extraPackagerArgs: []
78+
* ]
79+
*/
480

581
project.ext.react = [
6-
entryFile: "index.js",
7-
enableHermes: true, // clean and rebuild if changing
82+
enableHermes: false, // clean and rebuild if changing
883
]
984

1085
apply from: "../../node_modules/react-native/react.gradle"
1186

87+
/**
88+
* Set this to true to create two separate APKs instead of one:
89+
* - An APK that only works on ARM devices
90+
* - An APK that only works on x86 devices
91+
* The advantage is the size of the APK is reduced by about 4MB.
92+
* Upload all the APKs to the Play Store and people will download
93+
* the correct one based on the CPU architecture of their device.
94+
*/
1295
def enableSeparateBuildPerCPUArchitecture = false
96+
97+
/**
98+
* Run Proguard to shrink the Java bytecode in release builds.
99+
*/
13100
def enableProguardInReleaseBuilds = false
14101

102+
/**
103+
* The preferred build flavor of JavaScriptCore.
104+
*
105+
* For example, to use the international variant, you can use:
106+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
107+
*
108+
* The international variant includes ICU i18n library and necessary data
109+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
110+
* give correct results when using with locales other than en-US. Note that
111+
* this variant is about 6MiB larger per architecture than default.
112+
*/
15113
def jscFlavor = 'org.webkit:android-jsc:+'
16-
def enableHermes = project.ext.react.get("enableHermes", false)
17114

18115
/**
19-
* Architectures to build native code for in debug.
116+
* Whether to enable the Hermes VM.
117+
*
118+
* This should be set on project.ext.react and that value will be read here. If it is not set
119+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120+
* and the benefits of using Hermes will therefore be sharply reduced.
20121
*/
21-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
122+
def enableHermes = project.ext.react.get("enableHermes", false);
123+
124+
/**
125+
* Architectures to build native code for.
126+
*/
127+
def reactNativeArchitectures() {
128+
def value = project.getProperties().get("reactNativeArchitectures")
129+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
130+
}
22131

23132
android {
24133
ndkVersion rootProject.ext.ndkVersion
25134

26135
compileSdkVersion rootProject.ext.compileSdkVersion
27-
buildToolsVersion rootProject.ext.buildToolsVersion
28136

29137
defaultConfig {
30138
applicationId "com.calendarsexample"
31139
minSdkVersion rootProject.ext.minSdkVersion
32140
targetSdkVersion rootProject.ext.targetSdkVersion
33141
versionCode 1
34142
versionName "1.0"
143+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144+
145+
if (isNewArchitectureEnabled()) {
146+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
147+
externalNativeBuild {
148+
ndkBuild {
149+
arguments "APP_PLATFORM=android-21",
150+
"APP_STL=c++_shared",
151+
"NDK_TOOLCHAIN_VERSION=clang",
152+
"GENERATED_SRC_DIR=$buildDir/generated/source",
153+
"PROJECT_BUILD_DIR=$buildDir",
154+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
155+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
156+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157+
cppFlags "-std=c++17"
158+
// Make sure this target name is the same you specify inside the
159+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160+
targets "calendarsexample_appmodules"
161+
// Fix for windows limit on number of character in file paths and in command lines
162+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
163+
arguments "NDK_APP_SHORT_COMMANDS=true"
164+
}
165+
}
166+
}
167+
if (!enableSeparateBuildPerCPUArchitecture) {
168+
ndk {
169+
abiFilters (*reactNativeArchitectures())
170+
}
171+
}
172+
}
35173
}
174+
175+
if (isNewArchitectureEnabled()) {
176+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
177+
externalNativeBuild {
178+
ndkBuild {
179+
path "$projectDir/src/main/jni/Android.mk"
180+
}
181+
}
182+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
183+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
184+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
185+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
186+
into("$buildDir/react-ndk/exported")
187+
}
188+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
189+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
190+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
191+
into("$buildDir/react-ndk/exported")
192+
}
193+
afterEvaluate {
194+
// If you wish to add a custom TurboModule or component locally,
195+
// you should uncomment this line.
196+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
197+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
198+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
199+
200+
// Due to a bug inside AGP, we have to explicitly set a dependency
201+
// between configureNdkBuild* tasks and the preBuild tasks.
202+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
203+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
204+
configureNdkBuildDebug.dependsOn(preDebugBuild)
205+
reactNativeArchitectures().each { architecture ->
206+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
207+
dependsOn("preDebugBuild")
208+
}
209+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
210+
dependsOn("preReleaseBuild")
211+
}
212+
}
213+
}
214+
}
215+
36216
splits {
37217
abi {
38218
reset()
39219
enable enableSeparateBuildPerCPUArchitecture
40220
universalApk false // If true, also generate a universal APK
41-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
221+
include (*reactNativeArchitectures())
42222
}
43223
}
44224
signingConfigs {
@@ -52,21 +232,16 @@ android {
52232
buildTypes {
53233
debug {
54234
signingConfig signingConfigs.debug
55-
if (nativeArchitectures) {
56-
ndk {
57-
abiFilters nativeArchitectures.split(',')
58-
}
59-
}
60235
}
61236
release {
62237
// Caution! In production, you need to generate your own keystore file.
63238
// see https://reactnative.dev/docs/signed-apk-android.
64239
signingConfig signingConfigs.debug
65-
66240
minifyEnabled enableProguardInReleaseBuilds
67241
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
68242
}
69243
}
244+
70245
// applicationVariants are e.g. debug, release
71246
applicationVariants.all { variant ->
72247
variant.outputs.each { output ->
@@ -79,24 +254,31 @@ android {
79254
output.versionCodeOverride =
80255
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
81256
}
82-
}
83-
}
84-
}
85257

86-
configurations.all {
87-
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
88-
def requested = details.requested
89-
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
90-
details.useVersion "${rootProject.ext.supportLibVersion}"
91258
}
92259
}
93260
}
94261

95262
dependencies {
96263
implementation fileTree(dir: "libs", include: ["*.jar"])
97-
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
264+
265+
//noinspection GradleDynamicVersion
98266
implementation "com.facebook.react:react-native:+" // From node_modules
99-
implementation project(':react-native-navigation')
267+
268+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
269+
270+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
271+
exclude group:'com.facebook.fbjni'
272+
}
273+
274+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
275+
exclude group:'com.facebook.flipper'
276+
exclude group:'com.squareup.okhttp3', module:'okhttp'
277+
}
278+
279+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
280+
exclude group:'com.facebook.flipper'
281+
}
100282

101283
if (enableHermes) {
102284
def hermesPath = "../../node_modules/hermes-engine/android/";
@@ -107,6 +289,18 @@ dependencies {
107289
}
108290
}
109291

292+
if (isNewArchitectureEnabled()) {
293+
// If new architecture is enabled, we let you build RN from source
294+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
295+
// This will be applied to all the imported transtitive dependency.
296+
configurations.all {
297+
resolutionStrategy.dependencySubstitution {
298+
substitute(module("com.facebook.react:react-native"))
299+
.using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
300+
}
301+
}
302+
}
303+
110304
// Run this once to be able to run the application with BUCK
111305
// puts all compile dependencies into folder libs for BUCK to use
112306
task copyDownloadableDepsToLibs(type: Copy) {
@@ -115,3 +309,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
115309
}
116310

117311
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
312+
313+
def isNewArchitectureEnabled() {
314+
// To opt-in for the New Architecture, you can either:
315+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
316+
// - Invoke gradle with `-newArchEnabled=true`
317+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
318+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
319+
}

android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
android:usesCleartextTraffic="true"
99
tools:targetApi="28"
1010
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
11+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
1212
</application>
1313
</manifest>

0 commit comments

Comments
 (0)