package com.ydl.ydlcommon.base.flutter.base

import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

/**
 * 公共通道插件类
 * Created by xj on 2019/9/30.
 */
class BaseFlutterChannelPlugin: MethodChannel.MethodCallHandler {

    companion object {
        const val CHANNEL: String = "lib/common/channel"

        const val ACTION_GET_APPINFO_INITIAL_DATA = "action_get_initial_app_info_data" //获取主包信息的数据

        fun rigister(activity: FlutterActivity) {
            MethodChannel(activity.flutterView, CHANNEL).setMethodCallHandler(BaseFlutterChannelPlugin(activity))
        }
    }

    private var mActivity: FlutterActivity? = null

    private constructor(activity: FlutterActivity) {
        mActivity = activity
    }

    override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
        methodCall?.let {
            when (methodCall.method) {
                  // 获取主包信息的数据
                //todo xujian
//                ACTION_GET_APPINFO_INITIAL_DATA -> {
//                    val mRequestMap = mutableMapOf(
//                            "isDevelopment" to (BuildConfig.FLUTTER_API != "prod"),
//                            "uid" to ,
//                            "accessToken" to LoginHelper.getInstance().user.accessToken,
//                            "version" to RxAppTool.getAppVersionName(mActivity?.applicationContext),
//                            "isFromApp" to "1",
//                            "osBuild" to RxDeviceTool.getBuildBrandModel() + "," + RxDeviceTool.getSDKVersionName() + "," + RxAppTool.getAppVersionName(mActivity?.applicationContext)
//                    )
//                }
            }
        }
    }

}