package com.remax.visualnovel.extension

import android.app.Activity
import android.view.View
import com.remax.visualnovel.utils.StatusBarUtils

/**
 * Created by HJW on 2023/3/20
 */

@Suppress("DEPRECATION")
fun Activity.changeStatusBarVisibility(isLand: Boolean) {
    if (isLand) {
        // 隐藏状态栏和导航栏，拉出状态栏和导航栏显示一会儿后消失。
        window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_FULLSCREEN
                or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
    } else {
        //显示状态栏和导航栏
        window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
        StatusBarUtils.setTransparent(this)
    }
}