package cn.dankal.yunlaboratory.ui.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import cn.dankal.basiclib.widget.dialog.BaseDialog;
import cn.dankal.basiclib.widget.dialog.CustomDialog;
import cn.dankal.basiclib.widget.wheelview.WheelView;
import cn.dankal.basiclib.widget.wheelview.adapters.ArrayWheelAdapter;
import cn.dankal.yunlaboratory.R;

public class RenderDialog extends BaseDialog {
    private WheelView wheelView;

    public RenderDialog(Context context) {
        super(context);
    }

    @Override
    public void initDialog() {
        dialog = new CustomDialog.Builder(context).widthpx(-1).heightdp(185).gravity(Gravity.BOTTOM).view(R.layout.dialog_choose_sex).build();


        wheelView = (WheelView) dialog.getView(R.id.wheel_view);

        dialog.addViewOnclick(R.id.tv_negative, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        dialog.addViewOnclick(R.id.tv_positive, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();

            }
        });

        List<String> strings = new ArrayList<>();
        strings.add("女");
        strings.add("男");

        String[] data = new String[strings.size()];

        strings.toArray(data);
        wheelView.setVisibleItems(2);
        wheelView.setViewAdapter(new ArrayWheelAdapter<String>(context, data));
    }


    /**
     * 性别 1男2女
     *
     * @return
     */
    public int getCurrentSex() {
        return wheelView.getCurrentItem() == 0 ? 2 : 1;
    }
}
