/*
 * Copyright (c) 2016 droidwolf(droidwolf2006@gmail.com)
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.reactnative.FixedTableView;

import android.view.View;
import android.view.ViewGroup;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;

public class FixedTableViewManager extends ViewGroupManager<FixedTableView> {
    @Override
    public String getName() {
        return FixedTableView.class.getSimpleName();
    }

    @Override
    protected FixedTableView createViewInstance(ThemedReactContext reactContext) {
        FixedTableView view = new FixedTableView(reactContext);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }

    @Override
    public void addView(FixedTableView parent, View child, int index) {
        parent.addNewView(child, index);
    }

    @ReactProp(name = "freezeWidth")
    public void setFreezeWidth(FixedTableView parent, int width) {
        parent.setFreezeWidth(width);
    }

    @ReactProp(name = "freezeHeight")
    public void setFreezeHeight(FixedTableView parent, int height) {
        parent.setFreezeHeight(height);
    }

    @ReactProp(name = "scrollWidth")
    public void setScrollWidth(FixedTableView parent, int width) {
        parent.setScrollWidth(width);
    }

    @Override
    public void removeAllViews(FixedTableView parent) {
        parent.removeAllView();
    }
}
