package xyz.dynamic.client

import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import xyz.dynamic.client.keychain.KeychainModule
import xyz.dynamic.client.manifest.ReactNativeManifestModule

class DynamicClientPackage : BaseReactPackage() {
    override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
        return when (name) {
            KeychainModule.NAME -> KeychainModule(reactContext)
            ReactNativeManifestModule.NAME -> ReactNativeManifestModule(reactContext)
            else -> null
        }
    }

    override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
        return ReactModuleInfoProvider {
            mapOf(
                KeychainModule.NAME to ReactModuleInfo(
                    KeychainModule.NAME,
                    KeychainModule.NAME,
                    false,
                    false,
                    false,
                    true
                ),
                ReactNativeManifestModule.NAME to ReactModuleInfo(
                    ReactNativeManifestModule.NAME,
                    ReactNativeManifestModule.NAME,
                    false,
                    false,
                    false,
                    true
                )
            )
        }
    }
}
