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

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.ydl.ydlcommon.base.flutter.io.flutter.facade.Flutter
import com.ydl.ydlcommon.base.flutter.io.flutter.facade.FlutterFragment
import io.flutter.view.FlutterView

/**
 * flutter fragment 基类
 * Created by xj on 2019/9/30.
 */

abstract class BaseFlutterFragment : FlutterFragment() {
    private var mFlutterView: FlutterView? = null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): FlutterView {
        mFlutterView=Flutter.createView(
            activity!!,
            lifecycle,
            initialRoute())
        initChannelPlugin(mFlutterView!!)
        return  mFlutterView!!
    }

    /**
     * 路由，例 "quick_reply"
     */
    abstract fun initialRoute(): String

    /**
     * 初始化flutter channel插件
     */
    abstract fun initChannelPlugin(flutterView: FlutterView)
}
