Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
Browse files Browse the repository at this point in the history
…y-to-kotlin
  • Loading branch information
alduzy committed Jun 5, 2024
2 parents a9b709d + 5cfafbb commit f7bd9ad
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ hermesEnabled=true
# This is necessary, because the code checking for multiple instances
# detects package versions from other example applications in the repository.
disableMultipleInstancesCheck=true

isScreensExampleApp=true
2 changes: 2 additions & 0 deletions FabricExample/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ newArchEnabled=true
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

isScreensExampleApp=true
2 changes: 2 additions & 0 deletions FabricTestExample/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ newArchEnabled=true
hermesEnabled=true

disableMultipleInstancesCheck=true

isScreensExampleApp=true
1 change: 1 addition & 0 deletions RNScreens.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Pod::Spec.new do |s|
s.platforms = { :ios => platform, :tvos => "11.0", :visionos => "1.0" }
s.source = { :git => "https://github.com/software-mansion/react-native-screens.git", :tag => "#{s.version}" }
s.source_files = source_files
s.project_header_files = "cpp/**/*.h" # Don't expose C++ headers publicly to allow importing framework into Swift files
s.requires_arc = true

if defined?(install_modules_dependencies()) != nil
Expand Down
2 changes: 2 additions & 0 deletions TVOSExample/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.75.1

isScreensExampleApp=true
2 changes: 2 additions & 0 deletions TestsExample/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ newArchEnabled=false
hermesEnabled=true

disableMultipleInstancesCheck=true

isScreensExampleApp=true
78 changes: 77 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,80 @@ dependencies {
because("on older React Native versions this dependency conflicts with react-native-screens")
}
}
}
}

def isScreensExampleApp() {
return project.hasProperty('isScreensExampleApp') && project.property('isScreensExampleApp') == "true"
}

def getAbsoluteCodegenArtifactsPaperDestination() {
if (!project.hasProperty('codegenArtifactsPaperDestination')) {
throw new Exception('[RNScreens] Please fill codegenArtifactsPaperDestination variable in android/gradle.properties correct path to paper paper destination')
}

return "${project.rootDir}/../../${project.property('codegenArtifactsPaperDestination')}"
}

def getAbsoluteCodegenArtifactsSource() {
if (!project.hasProperty('codegenArtifactsSource')) {
throw new Exception('[RNScreens] Please fill codegenArtifactsSource variable in android/gradle.properties correct path to codegenerated artifacts')
}

return "${project.rootDir}/../../${project.property('codegenArtifactsSource')}"
}


tasks.register("copyCodegenArtifacts") {
group 'After build tasks'
description 'Tasks which copy codegen artifacts to paper architecture'

if (!isScreensExampleApp() || !isNewArchitectureEnabled()) {
return
}

dependsOn tasks.generateCodegenArtifactsFromSchema

doLast {

def absoluteCodegenArtifactsPaperDestination = getAbsoluteCodegenArtifactsPaperDestination()
def absoluteCodegenArtifactsSource = getAbsoluteCodegenArtifactsSource()

def existingFiles = fileTree(absoluteCodegenArtifactsPaperDestination).matching {
include '**/*.java'
}

def generatedFiles = fileTree(absoluteCodegenArtifactsSource).matching {
include '**/*.java'
}

def existingFilesMap = [:]

existingFiles.forEach { existingFile ->
existingFilesMap[existingFile.name] = 1
}

generatedFiles.forEach { generatedFile ->
if (!existingFilesMap.containsKey(generatedFile.name)) {
logger.warn("[RNScreens] ${generatedFile.name} not found in paper dir, if it's used in Android you need to copy it manually and implement yourself before using auto-copy feature")
}
}

if (existingFiles.size() == 0) {
logger.warn("[RNScreens] Paper destination with codegen interfaces is empty. This might be okay if you don't have any interfaces/delegates used in Android, if that's not the case please check if codegenArtifactsPaperDestination in android/gradle.properties is correct")
}

if (existingFiles.size() > generatedFiles.size()) {
throw new Exception("[RNScreens] Number od generated artifacts should be greather then or equal to paper interfaces. Please check if codegenArtifactsSource in android/gradle.properties is correct")
}

copy {
from absoluteCodegenArtifactsSource
include existingFiles.collect { it.name }
into absoluteCodegenArtifactsPaperDestination
}
}
}

if (isScreensExampleApp() && isNewArchitectureEnabled()) {
tasks.generateCodegenArtifactsFromSchema.finalizedBy('copyCodegenArtifacts')
}
7 changes: 7 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ android.useAndroidX=true
android.enableJetifier=true

kotlin.code.style=official

# Path to codegen output directory with this library view manager's interfaces & delegates. Used by `copyCodegenArtifacts` task that helps to synchronise newly generated files with their Paper conterparts.
codegenArtifactsSource=android/build/generated/source/codegen/java/com/facebook/react/viewmanagers

# Path to directory with view manager's interfaces & delegates used while running on Paper architecture. This property is used as output path for `copyCodegenArtifacts` task.
# Used for task (copyCodegenArtifacts) that automates copying those interfaces/delegates when codegen is run
codegenArtifactsPaperDestination=android/src/paper/java/com/facebook/react/viewmanagers/
2 changes: 1 addition & 1 deletion ios/RNSScreenContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ @implementation RNSScreenContainerView {

- (instancetype)init
{
if (self = [super init]) {
if (self = [super initWithFrame:CGRectZero]) {
#ifdef RCT_NEW_ARCH_ENABLED
static const auto defaultProps = std::make_shared<const react::RNSScreenContainerProps>();
_props = defaultProps;
Expand Down
2 changes: 1 addition & 1 deletion react-navigation
Submodule react-navigation updated 471 files

0 comments on commit f7bd9ad

Please sign in to comment.