package com.myfatoorahreactnative.googlepay;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.myfatoorahreactnative.utils.MFGPayConstants;

public class MFGooglePayManager extends SimpleViewManager<MFGooglePayButton> implements IMFGooglePayManager {
  public static MFGooglePayButton googlePayButton;

  //#region ReactNative Module Required
  public static ReactApplicationContext reactContext;

  public MFGooglePayManager(ReactApplicationContext reactContext) {
    MFGooglePayManager.reactContext = reactContext;
  }

  @NonNull
  @Override
  public String getName() {
    return MFGPayConstants.MFGooglePayButtonModuleNAME;
  }

  @Override
  protected void onAfterUpdateTransaction(@NonNull MFGooglePayButton view) {
    super.onAfterUpdateTransaction(view);
    googlePayButton.addButton();
  }

  @NonNull
  @Override
  public MFGooglePayButton createViewInstance(@NonNull ThemedReactContext context) {
    googlePayButton = new MFGooglePayButton(context);
    return googlePayButton;
  }
  //#endregion

  //#region GooglePay Props
  @ReactProp(name = "type")
  public void SetType(MFGooglePayButton view, int type) {
    view.setType(type);
  }

  @ReactProp(name = "theme")
  public void SetTheme(MFGooglePayButton view, int theme) {
    view.setTheme(theme);
  }

  @ReactProp(name = "radius")
  public void SetCornerRadius(MFGooglePayButton view, int radius) {
    view.setCornerRadius(radius);
  }
  //#endregion
}
