package com.casic.dcms.utils;

import android.app.Activity;
import android.view.ViewGroup;

import androidx.annotation.ColorRes;
import androidx.fragment.app.Fragment;

import com.gyf.immersionbar.ImmersionBar;
import com.pengxh.androidx.lite.kit.ContextKit;
import com.pengxh.androidx.lite.kit.IntKit;

public class ViewGroupKit {
    public static void initImmersionBar(ViewGroup viewGroup, Activity activity, boolean isDarkFont, @ColorRes int color) {
        ImmersionBar.with(activity)
                .statusBarDarkFont(isDarkFont)
                .statusBarColorInt(IntKit.convertColor(activity, color))
                .init();
        //根据不同设备状态栏高度设置statusBarView高度
        int statusBarHeight = ContextKit.getStatusBarHeight(activity);
        viewGroup.setPadding(0, statusBarHeight, 0, 0);
        viewGroup.requestLayout();
    }

    public static void initImmersionBar(ViewGroup viewGroup, Fragment fragment, boolean isDarkFont, @ColorRes int color) {
        ImmersionBar.with(fragment)
                .statusBarDarkFont(isDarkFont)
                .statusBarColorInt(IntKit.convertColor(fragment.requireContext(), color))
                .init();
        //根据不同设备状态栏高度设置statusBarView高度
        int statusBarHeight = ContextKit.getStatusBarHeight(fragment.requireContext());
        viewGroup.setPadding(0, statusBarHeight, 0, 0);
        viewGroup.requestLayout();
    }
}
