@@ -3,7 +3,6 @@ package com.reactnativenavigation.utils
33import android.app.Activity
44import android.graphics.Color
55import android.graphics.Rect
6- import android.os.Build
76import android.view.View
87import android.view.Window
98import androidx.annotation.ColorInt
@@ -16,7 +15,6 @@ import kotlin.math.ceil
1615
1716object SystemUiUtils {
1817 private const val STATUS_BAR_HEIGHT_M = 24
19- private const val STATUS_BAR_HEIGHT_L = 25
2018 internal const val STATUS_BAR_HEIGHT_TRANSLUCENCY = 0.65f
2119 private var statusBarHeight = - 1
2220 var navigationBarDefaultColor = - 1
@@ -38,7 +36,7 @@ object SystemUiUtils {
3836 val contentViewTop = contentView.top
3937 abs(contentViewTop - statusBarHeight)
4038 }
41- } ? : if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . M ) STATUS_BAR_HEIGHT_M else STATUS_BAR_HEIGHT_L
39+ } ? : STATUS_BAR_HEIGHT_M
4240 statusBarHeight
4341 }
4442 return res
@@ -77,8 +75,6 @@ object SystemUiUtils {
7775
7876 @JvmStatic
7977 fun setStatusBarColorScheme (window : Window ? , view : View , isDark : Boolean ) {
80- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .M ) return
81-
8278 window?.let {
8379 WindowInsetsControllerCompat (window, view).isAppearanceLightStatusBars = isDark
8480 // Workaround: on devices with api 30 status bar icons flickers or get hidden when removing view
@@ -121,18 +117,17 @@ object SystemUiUtils {
121117 @ColorInt color : Int ,
122118 translucent : Boolean
123119 ) {
124- val opaqueColor =
125- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .M ) {
126- Color .BLACK
127- } else {
128- val colorAlpha = Color .alpha(color)
129- val alpha = if (translucent && colorAlpha == 255 ) STATUS_BAR_HEIGHT_TRANSLUCENCY else colorAlpha/ 255.0f
130- val red: Int = Color .red(color)
131- val green: Int = Color .green(color)
132- val blue: Int = Color .blue(color)
133- Color .argb(ceil(alpha * 255 ).toInt(), red, green, blue)
134- }
135- window?.statusBarColor = opaqueColor
120+ val colorAlpha = Color .alpha(color)
121+ val alpha = if (translucent && colorAlpha == 255 ) STATUS_BAR_HEIGHT_TRANSLUCENCY else colorAlpha/ 255.0f
122+ val red: Int = Color .red(color)
123+ val green: Int = Color .green(color)
124+ val blue: Int = Color .blue(color)
125+ val opaqueColor = Color .argb(ceil(alpha * 255 ).toInt(), red, green, blue)
126+ setStatusBarColor(window, opaqueColor)
127+ }
128+
129+ fun setStatusBarColor (window : Window ? , color : Int ) {
130+ window?.statusBarColor = color
136131 }
137132
138133 @JvmStatic
0 commit comments