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 io.flutter.embedding.android.FlutterFragment
import io.flutter.view.FlutterView

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

abstract class BaseFlutterFragment : FlutterFragment() {

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

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        initChannelPlugin()
    }

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

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