package com.bc_chat.bc_base.utils

import android.app.Activity
import android.content.Context
import android.view.Gravity
import com.bc_chat.bc_base.R
import com.zhaohaoting.framework.utils.DensityUtil
import com.zhaohaoting.framework.view.picker.base.util.ConvertUtils
import com.zhaohaoting.framework.view.picker.framework.entity.Province
import com.zhaohaoting.framework.view.picker.framework.picker.AddressPicker

/**
 * author：Created by zhaohaoting on 2018/8/3
 * email：526309416@qq.com
 * desc：
 */
object PickerUtils {
    fun createAddressPickerWindow(mContext: Context, provinces: List<Province>, onAddressPickListener: AddressPicker.OnAddressPickListener? = null): AddressPicker {
        val picker = AddressPicker(mContext as Activity, provinces)
        picker.setTopPadding(ConvertUtils.toPx(mContext, 10f))
        picker.setSelectedItem(provinces[0].areaName, provinces[0].cities[0].areaName, provinces[0].cities[0].counties[0].areaName)
        picker.setOffset(2)
        picker.setCycleDisable(true)
        picker.setCancelTextColor(mContext.resources.getColor(R.color.black_99_color))
        picker.setSubmitTextColor(mContext.resources.getColor(R.color.theme_text_color))
        picker.setTitleText("选择地区")
        picker.setTitleTextColor(mContext.resources.getColor(R.color.black_66_color))
        picker.setTextColor(mContext.resources.getColor(R.color.theme_text_color), mContext.resources.getColor(R.color.black_66_color))
        picker.setTextSize(15)
        picker.setLineVisible(true)
        picker.setLineRatio(0f)
        picker.setItemPaddingTopBottom(10)
        picker.setHeight(DensityUtil.getScreenHeight(mContext) / 3)
        picker.setGravity(Gravity.BOTTOM)
        picker.setOnAddressPickListener(onAddressPickListener)
        picker.setBackgroundColor(mContext.resources.getColor(R.color.transparent))
        picker.getRootView().setBackgroundColor(mContext.resources.getColor(R.color.white))
//        picker.getRootView().setBackgroundResource(R.drawable.shape_top_round_white_8dp);
//        picker.show();
        return picker
    }
}
