package com.trust.ywx.specs.navigation

import android.content.Intent
import com.facebook.react.bridge.ReactApplicationContext
import com.trust.ywx.BuzActivity
import com.trust.ywx.specs.NativeNavigationManagerSpec
import com.trust.ywx.utils.AppManager

class NavigationManager(reactContext: ReactApplicationContext) :
    NativeNavigationManagerSpec(reactContext) {
    override fun navigate(name: String) {
        NavigationHelper.routerName = name
        AppManager.lastActivity()
            ?.apply {
                startActivity(Intent(this, BuzActivity::class.java))
                overridePendingTransition(0, 0)
            }
    }

    override fun pop() {
        AppManager.finishActivity(null)?.overridePendingTransition(0, 0)
    }

    override fun getName() = NAME

    companion object {
        const val NAME = "NavigationManager"
    }
}