-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
557 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
android/src/main/java/com/urbanairship/reactnative/ReactEmbeddedView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* Copyright Airship and Contributors */ | ||
|
||
package com.urbanairship.reactnative | ||
|
||
import android.content.Context | ||
import android.graphics.Color | ||
import android.view.View | ||
import android.widget.FrameLayout | ||
import androidx.core.view.doOnAttach | ||
import com.facebook.react.bridge.LifecycleEventListener | ||
import com.urbanairship.embedded.AirshipEmbeddedView | ||
|
||
class ReactEmbeddedView(context: Context) : FrameLayout(context) { | ||
|
||
private var embeddedId: String? = null | ||
|
||
fun load(embeddedId: String) { | ||
if (this.embeddedId == embeddedId) { | ||
return | ||
} | ||
|
||
removeAllViews() | ||
this.embeddedId = embeddedId | ||
addView(AirshipEmbeddedView(context, embeddedId)) | ||
} | ||
|
||
override fun requestLayout() { | ||
super.requestLayout() | ||
|
||
// This view relies on a measure + layout pass happening after it calls requestLayout(). | ||
// https://github.com/facebook/react-native/issues/4990#issuecomment-180415510 | ||
// https://stackoverflow.com/questions/39836356/react-native-resize-custom-ui-component | ||
post(measureAndLayout) | ||
} | ||
|
||
private val measureAndLayout = Runnable { | ||
measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), | ||
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)) | ||
layout(left, top, right, bottom) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
android/src/main/java/com/urbanairship/reactnative/ReactEmbeddedViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* Copyright Airship and Contributors */ | ||
|
||
package com.urbanairship.reactnative | ||
|
||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.facebook.react.uimanager.ViewManagerDelegate | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
import com.facebook.react.viewmanagers.RTNAirshipEmbeddedViewManagerDelegate | ||
import com.facebook.react.viewmanagers.RTNAirshipEmbeddedViewManagerInterface | ||
|
||
|
||
class ReactEmbeddedViewManager : SimpleViewManager<ReactEmbeddedView>(), | ||
RTNAirshipEmbeddedViewManagerInterface<ReactEmbeddedView> { | ||
|
||
private val delegate = RTNAirshipEmbeddedViewManagerDelegate(this) | ||
|
||
override fun getName(): String { | ||
return REACT_CLASS | ||
} | ||
|
||
override fun getDelegate(): ViewManagerDelegate<ReactEmbeddedView?> { | ||
return delegate | ||
} | ||
|
||
override fun createViewInstance(reactContext: ThemedReactContext): ReactEmbeddedView { | ||
return ReactEmbeddedView(reactContext) | ||
} | ||
|
||
@ReactProp(name = "embeddedId") | ||
override fun setEmbeddedId(view: ReactEmbeddedView, embeddedId: String?) { | ||
embeddedId?.let { | ||
view.load(it) | ||
} | ||
} | ||
|
||
|
||
companion object { | ||
const val REACT_CLASS = "RTNAirshipEmbeddedView" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#Tue Aug 06 09:31:04 PDT 2024 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.