package com.trust.ywx

import android.os.Bundle
import android.widget.Toast
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import com.trust.ywx.multiple.MultipleReactActivityDelegate
import com.trust.ywx.specs.navigation.NavigationHelper
import com.trust.ywx.utils.AppManager

class BuzActivity : ReactActivity() {

    /**
     * Returns the name of the main component registered from JavaScript. This is used to schedule
     * rendering of the component.
     */
    override fun getMainComponentName(): String = NavigationHelper.routerName

    /**
     * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
     * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
     */
    override fun createReactActivityDelegate(): ReactActivityDelegate =
        if (BuildConfig.DEBUG) DefaultReactActivityDelegate(
            this,
            mainComponentName,
            fabricEnabled
        ) else
            MultipleReactActivityDelegate(this, NavigationHelper.routerName, fabricEnabled)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        AppManager.addActivity(this)
    }

    override fun onResume() {
        super.onResume()
    }

    override fun onDestroy() {
        AppManager.removeActivity(this)
        super.onDestroy()
    }
}
