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
import xyz.dynamic.client.screenshot.ScreenshotProtectionModule
import xyz.dynamic.client.webview.DynamicWebViewModule

class DynamicClientPackage : BaseReactPackage() {
    override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
        return when (name) {
            KeychainModule.NAME -> KeychainModule(reactContext)
            ReactNativeManifestModule.NAME -> ReactNativeManifestModule(reactContext)
            DynamicWebViewModule.NAME -> DynamicWebViewModule(reactContext)
            ScreenshotProtectionModule.NAME -> ScreenshotProtectionModule(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
                ),
                DynamicWebViewModule.NAME to ReactModuleInfo(
                    DynamicWebViewModule.NAME,
                    DynamicWebViewModule.NAME,
                    false,
                    false,
                    false,
                    true
                ),
                ScreenshotProtectionModule.NAME to ReactModuleInfo(
                    ScreenshotProtectionModule.NAME,
                    ScreenshotProtectionModule.NAME,
                    false,
                    false,
                    false,
                    true
                )
            )
        }
    }
}
