package com.anythink.reactnative.banner;

import android.widget.FrameLayout;


import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;

/**
* Banner ViewManager (old architecture shell): @ReactProp ×5 forward shared Impl (no command).
* Equivalent to the newarch shell prop by prop, only the way props are exposed is different (@ReactProp vs codegen Interface @Override).
 */
@ReactModule(name = ATBannerViewManager.NAME)
public class ATBannerViewManager extends SimpleViewManager<FrameLayout> {

    public static final String NAME = "ATBannerView";

    @Override
    public String getName() {
        return NAME;
    }

    @Override
    protected FrameLayout createViewInstance(ThemedReactContext ctx) {
        return ATBannerViewManagerImpl.createView(ctx);
    }

    @Override
    protected void onAfterUpdateTransaction(FrameLayout view) {
        super.onAfterUpdateTransaction(view);
        ATBannerViewManagerImpl.onAfterUpdateTransaction(view);
    }

    @Override
    public void onDropViewInstance(FrameLayout view) {
        ATBannerViewManagerImpl.onDrop(view);
        super.onDropViewInstance(view);
    }

    @ReactProp(name = "placementID")
    public void setPlacementID(FrameLayout view, String value) {
        ATBannerViewManagerImpl.stateOf(view).placementId = value;
        ATBannerViewManagerImpl.maybeAttach(view);
    }

    @ReactProp(name = "isAdaptiveHeight")
    public void setIsAdaptiveHeight(FrameLayout view, boolean value) {
        ATBannerViewManagerImpl.stateOf(view).adaptive = value;
    }

    @ReactProp(name = "adWidth")
    public void setAdWidth(FrameLayout view, int value) {
        ATBannerViewManagerImpl.stateOf(view).adWidth = value;
        ATBannerViewManagerImpl.maybeAttach(view);
    }

    @ReactProp(name = "adHeight")
    public void setAdHeight(FrameLayout view, int value) {
        ATBannerViewManagerImpl.stateOf(view).adHeight = value;
        ATBannerViewManagerImpl.maybeAttach(view);
    }
}
