package cn.muchinfo.rma.view.base.home.customerdata

import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.inputmethod.EditorInfo
import cn.muchinfo.rma.R
import cn.muchinfo.rma.view.autoWidget.*
import cn.muchinfo.rma.view.base.BaseActivity
import org.jetbrains.anko.*

class CustomerDataDetailsActivity : BaseActivity<CustomerDataViewModel>(){


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        verticalLayout {
            background = resources.getDrawable(R.color.white)
            topBar {
                commonLeftButton()
                commonTitle {
                    textResource = R.string.add_customer_data
                }
            }
            frameLayout {
                scrollView {
                    verticalLayout {
                        linearLayout {
                            gravity = Gravity.CENTER_VERTICAL
                            background = resources.getDrawable(R.color.rma_details_status)//rma_pass_status已通过背景色
                            imageView {
                                imageResource = R.mipmap.rma_wait_status
                                imageResource = R.mipmap.rma_pass_status
                            }.lparams(autoSize(38), autoSize(38)) {
                                marginStart = autoSize(37)
                            }
                            textView {
                                text = "待审核"
                                textSizeAuto = 31
                                textColorInt = R.color.rma_yellow_text_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(20)
                            }
                        }.lparams(matchParent, autoSize(60))

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "客户类型"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "企业"
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "企业名称"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "深圳前海铜矿贸易有限公司 "
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart =  autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "证件类型"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "营业执照 "
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "证件号码"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "9GW432675475247HJM"
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "营业执照"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "查看附件"
                                textColorInt = R.color.rma_yellow_text_color
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "手机号码"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "18389389711"
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "联系电话"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "0755-6437264"
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(136))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "通讯地址"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)

                            }

                            verticalLayout {
                                textView {
                                    text = "广东省 深圳市 福田区"
                                    textColorInt = R.color.black
                                    textSizeAuto = 31
                                }.lparams(wrapContent, wrapContent)

                                textView {
                                    text = "金融基地2栋10楼E单元"
                                    textColorInt = R.color.black
                                    textSizeAuto = 31
                                }.lparams(wrapContent, wrapContent) {
                                    topMargin = autoSize(15)
                                }
                            }.lparams(matchParent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(220))

                        viewItemUI()

                        linearLayout {

                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "备        注"
                                textSizeAuto = 31
                                textColorInt = R.color.p_normal_summary_txt_color
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            textView {
                                text = "螺纹钢的采购价按上海有色网AMMA00铝"
                                textColorInt = R.color.black
                                textSizeAuto = 31
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(80)
                            }
                        }.lparams(matchParent, autoSize(220))

                        view {
                            background = resources.getDrawable(R.color.rma_hint_line_color_eee)
                        }.lparams(matchParent, autoSize(20))

                        linearLayout {
                            gravity = Gravity.CENTER_VERTICAL
                            textView {
                                text = "备        注"
                                textSizeAuto = 31
                                textColorInt = R.color.rma_black_33
                            }.lparams(wrapContent, wrapContent) {
                                marginStart = autoSize(59)
                            }

                            editText {
                                hint = "请输入备注"
                                background = null
                                inputType = EditorInfo.TYPE_CLASS_TEXT
//                    setDecimalInputType()
                                hintColorStr = "#CCCCCC"
                                textSizeAuto = 31
                                textColorStr = "#333333"
                            }.lparams(matchParent, autoSize(260)) {
                                marginStart = autoSize(59)
                            }
                        }.lparams(matchParent, autoSize(136))
                        view {
                            background = resources.getDrawable(R.color.rma_hint_line_color_eee)
                        }.lparams(matchParent, autoSize(200))
                    }
                }

                linearLayout {
                    background = resources.getDrawable(R.color.white)
                    gravity = Gravity.CENTER_VERTICAL
                    textView {
                        gravity = Gravity.CENTER
                        backgroundResource = R.mipmap.rma_save_info_bg
                        text = "审核拒绝"
                        textSizeAuto = 38
                        textColorInt = R.color.rma_star_color
                    }.lparams(autoSize(419), autoSize(119)){
                        marginStart = autoSize(24)
                    }

                    textView {
                        gravity = Gravity.CENTER
                        backgroundResource = R.mipmap.rma_submit_bg
                        text = "审核通过"
                        textColorInt = R.color.white
                        textSizeAuto = 38
                    }.lparams(autoSize(419), autoSize(119)){
                        marginStart = autoSize(13)
                    }

                    textView {
                        gravity = Gravity.CENTER
                        visibility = View.GONE
                        backgroundResource = R.mipmap.rma_submit_bg
                        text = "撤销"
                        textColorInt = R.color.white
                        textSizeAuto = 38
                    }.lparams(autoSize(780), autoSize(119)){
                        marginStart = autoSize(59)
                    }

                }.lparams(matchParent, autoSize(144)){
                    gravity = Gravity.BOTTOM
                }

            }
        }
    }

    private fun _LinearLayout.viewItemUI() {
        view {
            background = resources.getDrawable(R.color.rma_hint_line_color_eee)
        }.lparams(matchParent, autoSize(1)) {
            marginStart = autoSize(60)
        }
    }

}