buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
    }
}

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

apply plugin: 'com.android.library'
apply plugin: 'com.facebook.react'

android {
    compileSdkVersion 33
    buildToolsVersion "33.0.0"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 33
        versionCode 1
        versionName "1.0"
        buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
    }
    lintOptions {
        abortOnError false
    }
    sourceSets {
        main {
            if (isNewArchitectureEnabled()) {
                java.srcDirs += ['src/newarch/java']
            } else {
                java.srcDirs += ['src/oldarch/java']
            }
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.facebook.react:react-native:+'
    implementation 'androidx.cardview:cardview:1.0.0'

    // Glide v4.16.0
    implementation 'com.github.bumptech.glide:glide:4.16.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'

    // AVIF support
    implementation 'com.github.bumptech.glide:avif-integration:4.16.0'

    // SVG support
    api 'com.caverock:androidsvg-aar:1.4'

    if (isNewArchitectureEnabled()) {
        implementation project(':ReactAndroid')
        implementation project(':ReactAndroid:hermes-engine')
        implementation project(':ReactAndroid:react-native-gradle-plugin')
    }
}
