Skip to content

RN-0.80.1-fixes android #8078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import com.facebook.react.bridge.ColorPropConverter
import com.facebook.react.bridge.ReadableMap
import com.reactnativenavigation.NavigationApplication

private fun parsePlatformColor(paths: ReadableMap) =
ColorPropConverter.getColor(paths, NavigationApplication.instance)
private fun parsePlatformColor(paths: ReadableMap): Int {
return ColorPropConverter.getColor(paths, NavigationApplication.instance) ?: 0 // fallback to black
}

class ReactPlatformColor(private val paths: ReadableMap) :
Colour(parsePlatformColor(paths)) {

override fun get(): Int {
return parsePlatformColor(paths)
}

override fun get(defaultValue: Int?): Int? {
override fun get(defaultValue: Int?): Int {
return try {
parsePlatformColor(paths)
}catch (e:Exception){
defaultValue
ColorPropConverter.getColor(paths, NavigationApplication.instance) ?: defaultValue ?: 0
} catch (e: Exception) {
defaultValue ?: 0
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.reactnativenavigation.options.parsers

import android.content.Context
import com.facebook.react.bridge.ColorPropConverter
import com.reactnativenavigation.options.params.Colour
Expand All @@ -18,21 +17,14 @@ object ColorParser {
return ReactPlatformColor(JSONParser.convert(json))
}
return when (val color = json.opt(colorName)) {
null, VAL_NO_COLOR -> {
DontApplyColour()
}
is Int -> {
Colour(json.optInt(colorName))
}
null, VAL_NO_COLOR -> DontApplyColour()
is Int -> Colour(json.optInt(colorName))
is JSONObject -> {
ColorPropConverter.getColor(color, context)?.let {
ColorPropConverter.getColor(color, context ?: throw IllegalArgumentException("Context must not be null"))?.let {
Colour(it)
} ?: NullColor()
}
else -> {
NullColor()
}
else -> NullColor()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,30 @@ import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.views.view.ReactViewGroup


class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
class ModalContentLayout(context: Context) : ReactViewGroup(context), RootView {

private val mJSTouchDispatcher = JSTouchDispatcher(this)

override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent) {
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
mJSTouchDispatcher.onChildStartedNativeGesture(ev, getEventDispatcher())
}
override fun onChildStartedNativeGesture(androidEvent: MotionEvent) {
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
}
override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent) {
mJSTouchDispatcher.onChildEndedNativeGesture(androidEvent, this.getEventDispatcher())

override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) {
mJSTouchDispatcher.onChildEndedNativeGesture(ev, getEventDispatcher())
}

override fun handleException(t: Throwable) {
getReactContext().handleException(
if (t is Exception) t else RuntimeException(t)
)
}

override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
private fun getEventDispatcher(): EventDispatcher {
val reactContext: ReactContext = this.getReactContext()
return UIManagerHelper.getEventDispatcher(reactContext, UIManagerType.FABRIC) ?: throw IllegalStateException("EventDispatcher for Fabric UI Manager is not found")
}

override fun handleException(t: Throwable?) {
getReactContext().handleException(RuntimeException(t))
private fun getEventDispatcher(): EventDispatcher {
val reactContext: ReactContext = getReactContext()
return UIManagerHelper.getEventDispatcher(reactContext, UIManagerType.FABRIC)
?: throw IllegalStateException("EventDispatcher for Fabric UI Manager is not found")
}

private fun getReactContext(): ReactContext {
Expand All @@ -49,5 +52,4 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
super.onTouchEvent(event)
return true
}

}
}
Loading