I am working on SDK for android and later for ios. And this SDK should be added to the native android project as AAR and probably for ios as a pod.
I was following RN article integration with existing apps and it is working completely fine but my problem is I don't want to run the whole activity up to the native project... I just need to open modal dialog with RN components and some logic
The third part of application write in Kotlin on android implementing my SDK
class MainActivity : AppCompatActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val MySDK = MySdk(this, this, 'some other data')
...
btnOpenWalleePaymentModalReactNative.setOnClickListener {
MySDK.launchDialog()
}
and now my SDK opening RN activity (inside MySDK):
class MySDK(private val context: Context, val activity: Activity) {
fun launchDialog() {
val intent = Intent(context, MyReactActivity::class.java)
context.startActivity(intent)
}
and this part open standard activity where all RN exist but i don't want to have an activity i want to have dialogue
so I created a class with dialogue what I want to use for that (BottomSheetDialogFragment)
class TestDialog(context: Context, var activity: Activity): BottomSheetDialogFragment() {
private lateinit var reactRootView: ReactRootView
private lateinit var reactInstanceManager: ReactInstanceManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
SoLoader.init(context, false)
reactRootView = ReactRootView(context)
val packages: List<ReactPackage> = PackageList(activity.application).packages
reactInstanceManager = ReactInstanceManager.builder()
.setApplication(activity.application)
.setCurrentActivity(activity)
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index")
.addPackages(packages)
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build()
reactRootView?.startReactApplication(reactInstanceManager, "PaymentSDK", null)
activity.setContentView(reactRootView)
}
and when I init this class and open dialogue with react native it will change the activity from third party library and put there my react activity and blurred overlay from dialogue...
TestDialog(context, activity ).show(activity.supportFragmentManager, "tag")
like on the picture
any idea how to squeeze RN view/UI into fragment or dialogue view or any other idea how to do it? Or an article with something similar like writing an RN module for native android?
