package cn.muchinfo.rma.view.base.future.costs

import android.os.Bundle
import cn.muchinfo.rma.R
import cn.muchinfo.rma.global.data.AmountLogData
import cn.muchinfo.rma.view.autoWidget.commonLeftButton
import cn.muchinfo.rma.view.autoWidget.commonTitle
import cn.muchinfo.rma.view.autoWidget.topBar
import cn.muchinfo.rma.view.base.BaseActivity
import cn.muchinfo.rma.view.base.future.detailsView
import cn.muchinfo.rma.view.base.future.trade.itemView
import kotlinx.android.synthetic.main.layout_item_content.view.*
import org.jetbrains.anko.verticalLayout

/**
 * 资金流水详情页面
 */
class CostDetailsActivity : BaseActivity<CostViewModel>(){

    val data by lazy {
        intent.getParcelableExtra<AmountLogData>("data") as AmountLogData
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        verticalLayout {
            //头部标题
            topBar {
                commonLeftButton()
                commonTitle {
                    text = "流水详情"
                }
            }

            detailsView(title = "操作类型",content = data.OPERATETYPENAME ?: "")

            itemView()

            detailsView(title = "合约名称",content = data.dgoodsname ?: "")

            itemView()

            detailsView(title = "合约代码",content = data.dgoodscode ?: "")

            itemView()

            detailsView(title = "变动前金额",content = data.balance ?: "")

            itemView()

            when {
                data.amount?.toDouble() ?: 0.0 < 0.0 -> {
                    detailsView(title = "变动金额",content = data.amount ?: "",contentColor = R.color.rma_green_color)
                }
                data.amount?.toDouble() ?: 0.0 > 0.0 -> {
                    detailsView(title = "变动金额",content = data.amount ?: "",contentColor = R.color.rma_red_color)
                }
                data.amount?.toDouble() ?: 0.0 == 0.0 -> {
                    detailsView(title = "变动金额",content = data.amount ?: "")
                }
            }

            itemView()

            detailsView(title = "变动后金额",content = data.currentbalance ?: "")

            itemView()

            detailsView(title = "币种",content = data.currencyid ?: "")

            itemView()

            detailsView(title = "关联单号",content = data.relationorderid ?: "")

            itemView()

            detailsView(title = "时间",content = data.createtime ?: "")

            itemView()
        }
    }

}