package com.unitreactnativecomponents.nativeComponents import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.SimpleViewManager import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.UIManagerHelper import com.unitreactnativecomponents.nativeComponents.visapresentation.UNGooglePayView @ReactModule(name = UnitAddToWalletButtonViewManager.REACT_VIEW_NAME) class UnitAddToWalletButtonViewManager : SimpleViewManager() { override fun getName(): String { return REACT_VIEW_NAME } override fun createViewInstance(reactContext: ThemedReactContext): UNGooglePayView { val unGooglePayView = UNGooglePayView(reactContext) unGooglePayView.onAddToWalletClicked { val surfaceId = UIManagerHelper.getSurfaceId(reactContext) UIManagerHelper.getEventDispatcherForReactTag(reactContext, unGooglePayView.id) ?.dispatchEvent(UnitReactNativeComponentsEvent(surfaceId, unGooglePayView.id)) } unGooglePayView.filterTouchesWhenObscured = true return unGooglePayView } override fun getExportedCustomDirectEventTypeConstants(): MutableMap { return mapOf( "onAddToWalletClicked" to hashMapOf("registrationName" to "onAddToWalletClicked") ).toMutableMap() } companion object { const val REACT_VIEW_NAME = "UnitAddToWalletButtonNativeView" } }