package com.lukouguoji.aerologic.page.gnj.move.stash.detail

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.google.gson.Gson
import com.lukouguoji.aerologic.R
import com.lukouguoji.aerologic.databinding.ActivityGnjMoveStashDetailBinding
import com.lukouguoji.aerologic.page.gnj.move.stash.photo.GnjMoveStashPhotoActivity
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.bean.MoveStashBean
import com.lukouguoji.module_base.common.Constant

/**
 * 国内进港移库「运单详情」（5.5 寸手持端专属页面，无平板变体）
 *
 * 由列表卡片的「查看详情」进入；「异常照片」卡片的加号槽位跳拍照上传页。
 * 展示字段全部由列表项带入（Gson JSON），零新增请求。
 */
class GnjMoveStashDetailActivity :
    BaseBindingActivity<ActivityGnjMoveStashDetailBinding, GnjMoveStashDetailViewModel>() {

    override fun layoutId() = R.layout.activity_gnj_move_stash_detail
    override fun viewModelClass() = GnjMoveStashDetailViewModel::class.java

    override fun initOnCreate(savedInstanceState: Bundle?) {
        setBackArrow("运单详情")
        binding.viewModel = viewModel
        binding.activity = this
        viewModel.initOnCreated(intent)
    }

    /** 「异常照片」加号槽位 → 拍照上传页 */
    fun openPhoto() {
        viewModel.dataBean.value?.let {
            GnjMoveStashPhotoActivity.start(this, it.mawbId, it.wbNo)
        }
    }

    companion object {
        @JvmStatic
        fun start(context: Context, bean: MoveStashBean) {
            context.startActivity(
                Intent(context, GnjMoveStashDetailActivity::class.java)
                    .putExtra(Constant.Key.DATA, Gson().toJson(bean))
            )
        }
    }
}
