Skip to content

Commit

Permalink
chore: ugprade example to rn 0.75.1 (#3565)
Browse files Browse the repository at this point in the history
* chore: ugprade example to rn 7.5.0-rc3

* rn-0.75.1
  • Loading branch information
mfazekas authored Aug 20, 2024
1 parent bc01a0b commit e5b1ca5
Show file tree
Hide file tree
Showing 27 changed files with 1,172 additions and 495 deletions.
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ android {
} else {
java.srcDirs += 'src/main/mapbox-v11-compat/v10'
}
java.srcDirs += 'src/main/rn-compat/rn75'
if (safeExtGet("RNMapboxMapsUseV11", false)) {
logger.warn("RNMapboxMapsUseV11 is deprecated, just set RNMapboxMapsVersion to 11.*")
}
Expand Down Expand Up @@ -164,9 +165,9 @@ dependencies {

// Dependencies
customizableDependencies('RNMapboxMapsSupportLibs') {
implementation "com.android.support:support-vector-drawable:28.0.0"
//implementation "com.android.support:support-vector-drawable:28.0.0"
implementation "com.android.support:support-annotations:28.0.0"
implementation "com.android.support:appcompat-v7:28.0.0"
//implementation "com.android.support:appcompat-v7:28.0.0"
}
customizableDependencies('RNMapboxMapsOkHTTPLibs') {
implementation "com.squareup.okhttp3:okhttp:4.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.rnmapbox.rnmbx.utils.ViewTagResolver
import com.rnmapbox.rnmbx.utils.extensions.asBooleanOrNull
import com.rnmapbox.rnmbx.utils.extensions.asDoubleOrNull
import com.rnmapbox.rnmbx.utils.extensions.asStringOrNull
import com.rnmapbox.rnmbx.rncompat.dynamic.*

class RNMBXCameraManager(private val mContext: ReactApplicationContext, val viewTagResolver: ViewTagResolver) :
AbstractEventEmitter<RNMBXCamera?>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.mapbox.maps.ImageStretches
import com.rnmapbox.rnmbx.components.AbstractEventEmitter
import com.rnmapbox.rnmbx.events.constants.EventKeys
import com.rnmapbox.rnmbx.events.constants.eventMapOf
import com.rnmapbox.rnmbx.rncompat.dynamic.*
import com.rnmapbox.rnmbx.utils.ImageEntry
import com.rnmapbox.rnmbx.utils.Logger
import com.rnmapbox.rnmbx.utils.ResourceUtils
Expand Down Expand Up @@ -202,15 +203,13 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) :
images.setNativeImages(nativeImages)
}

override fun customEvents(): Map<String, String>? {
return eventMapOf(
override fun customEvents(): Map<String, String>? { return eventMapOf(
EventKeys.IMAGES_MISSING to "onImageMissing"
)
}

// region RNMBXImage children

override fun addView(parent: RNMBXImages?, childView: View?, childPosition: Int) {
override fun addView(parent: RNMBXImages, childView: View, childPosition: Int) {
if (parent == null || childView == null) {
Logger.e("RNMBXImages", "addView: parent or childView is null")
return
Expand All @@ -225,7 +224,7 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) :
childView.nativeImageUpdater = parent
}

override fun removeView(parent: RNMBXImages?, view: View?) {
override fun removeView(parent: RNMBXImages, view: View) {
if (parent == null || view == null) {
Logger.e("RNMBXImages", "removeView: parent or view is null")
return
Expand All @@ -234,7 +233,7 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) :
parent.mImageViews.remove(view)
}

override fun removeAllViews(parent: RNMBXImages?) {
override fun removeAllViews(parent: RNMBXImages) {
if (parent == null) {
Logger.e("RNMBXImages", "removeAllViews parent is null")
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewGroupManager
import com.facebook.react.uimanager.annotations.ReactProp
import com.facebook.react.viewmanagers.RNMBXCustomLocationProviderManagerInterface
import com.rnmapbox.rnmbx.rncompat.dynamic.*
import com.rnmapbox.rnmbx.utils.Logger


class RNMBXCustomLocationProviderManager : ViewGroupManager<RNMBXCustomLocationProvider>(),
RNMBXCustomLocationProviderManagerInterface<RNMBXCustomLocationProvider> {
override fun getName(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.google.gson.Gson
import com.google.gson.stream.JsonWriter
import com.mapbox.bindgen.Value
import com.mapbox.maps.extension.style.expressions.generated.Expression
import com.rnmapbox.rnmbx.rncompat.dynamic.*
import com.rnmapbox.rnmbx.utils.Logger
import com.rnmapbox.rnmbx.utils.extensions.toJsonArray
import java.io.StringWriter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ class NativeMapViewModule(context: ReactApplicationContext, val viewTagResolver:

override fun setHandledMapChangedEvents(
viewRef: ViewRefTag?,
events: ReadableArray,
promise: Promise
events: ReadableArray?,
promise: Promise?
) {
withMapViewOnUIThread(viewRef, promise) {
it.setHandledMapChangedEvents(events.asArrayString())
withMapViewOnUIThread(viewRef, promise!!) {
it.setHandledMapChangedEvents(events!!.asArrayString())
promise.resolve(null)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso
}
}

override fun addView(mapView: RNMBXMapView?, childView: View?, childPosition: Int) {
override fun addView(mapView: RNMBXMapView, childView: View, childPosition: Int) {
mapView!!.addFeature(childView, childPosition)
}

override fun getChildCount(mapView: RNMBXMapView?): Int {
override fun getChildCount(mapView: RNMBXMapView): Int {
return mapView!!.featureCount
}

override fun getChildAt(mapView: RNMBXMapView?, index: Int): View? {
override fun getChildAt(mapView: RNMBXMapView, index: Int): View? {
return mapView!!.getFeatureAt(index)
}

override fun removeViewAt(mapView: RNMBXMapView?, index: Int) {
override fun removeViewAt(mapView: RNMBXMapView, index: Int) {
mapView!!.removeFeatureAt(index)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.facebook.react.viewmanagers.RNMBXStyleImportManagerInterface
import com.rnmapbox.rnmbx.components.AbstractEventEmitter
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
import com.mapbox.bindgen.Value
import com.rnmapbox.rnmbx.rncompat.dynamic.*
import com.rnmapbox.rnmbx.utils.Logger
import com.rnmapbox.rnmbx.utils.extensions.toValueHashMap
import org.json.JSONObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.mapbox.maps.extension.style.types.StyleTransition
import com.rnmapbox.rnmbx.components.styles.RNMBXStyleFactory
import com.mapbox.maps.extension.style.expressions.generated.Expression
import com.mapbox.maps.extension.style.light.LightPosition
import com.rnmapbox.rnmbx.rncompat.dynamic.*
import com.rnmapbox.rnmbx.utils.ExpressionParser
import com.rnmapbox.rnmbx.utils.Logger
import java.util.ArrayList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.net.Uri
import android.util.Log
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper
import com.mapbox.maps.extension.style.sources.generated.ImageSource
import com.rnmapbox.rnmbx.rncompat.resourcedrawableidhelper.*
import com.rnmapbox.rnmbx.utils.LatLngQuad
import java.net.URL

Expand Down Expand Up @@ -66,4 +67,5 @@ class RNMBXImageSource(context: Context?) : RNMBXSource<ImageSource?>(context) {
companion object {
const val LOG_TAG = "RNMBXImageSource"
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import com.rnmapbox.rnmbx.components.AbstractEventEmitter
abstract class RNMBXTileSourceManager<T : RNMBXTileSource<*>?> internal constructor(
reactApplicationContext: ReactApplicationContext
) : AbstractEventEmitter<T>(reactApplicationContext) {
override fun getChildAt(source: T, childPosition: Int): View {
override fun getChildAt(source: T & Any, childPosition: Int): View {
return source!!.getChildAt(childPosition)
}

override fun getChildCount(source: T): Int {
override fun getChildCount(source: T & Any): Int {
return source!!.childCount
}

override fun addView(source: T, childView: View, childPosition: Int) {
override fun addView(source: T & Any, childView: View, childPosition: Int) {
source!!.addLayer(childView, childPosition)
}

override fun removeViewAt(source: T, childPosition: Int) {
override fun removeViewAt(source: T & Any, childPosition: Int) {
source!!.removeLayer(childPosition)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.ReadableType
import com.mapbox.bindgen.Value
import com.rnmapbox.rnmbx.rncompat.dynamic.*

fun ReadableMap.toValueHashMap(): HashMap<String, Value> {
var result = hashMapOf<String, Value>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.mapbox.geojson.MultiPolygon
import com.mapbox.geojson.Point
import com.mapbox.geojson.Polygon
import com.mapbox.maps.EdgeInsets
import com.rnmapbox.rnmbx.rncompat.readable_map.*
import com.rnmapbox.rnmbx.utils.ConvertUtils
import com.rnmapbox.rnmbx.utils.Logger

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.rnmapbox.rnmbx.rncompat.dynamic

import com.facebook.react.bridge.Dynamic
import com.facebook.react.bridge.ReadableType


fun Dynamic.getType(): ReadableType {
return type
}

/*
val Dynamic.type: ReadableType
get() { return this.getType() }
*/
/*
val Dynamic.isNull: Boolean
get() { return this.isNull() }
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.rnmapbox.rnmbx.rncompat.readable_map
import com.facebook.react.bridge.ReadableMap

fun ReadableMap.getEntryIterator(): Iterator<Map. Entry<String, Any>>
{
return this.entryIterator
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.rnmapbox.rnmbx.rncompat.resourcedrawableidhelper;

import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper

public fun ResourceDrawableIdHelper.Companion.getInstance(): ResourceDrawableIdHelper {
return this.instance
}
5 changes: 3 additions & 2 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.4'

gem 'cocoapods', '~> 1.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '=> 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.3', '!= 7.1.0'
21 changes: 11 additions & 10 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ apply plugin: "com.facebook.react"
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down Expand Up @@ -49,6 +49,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -121,5 +124,3 @@ dependencies {
implementation jscFlavor
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ buildscript {
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = '1.9.22'
kotlinVersion = "1.9.24"
}
repositories {
google()
Expand Down
2 changes: 0 additions & 2 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ org.gradle.jvmargs=-Xmx2560m -XX:MaxMetaspaceSize=1024m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

RNMBX11=false

Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
4 changes: 3 additions & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'RNMapboxGLExample'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (api) {
api.cache(true);

return {
presets: ['babel-preset-expo'],
presets: ['@react-native/babel-preset'], //'babel-preset-expo'],
plugins: [
[
'module-resolver',
Expand Down
Loading

0 comments on commit e5b1ca5

Please sign in to comment.