Skip to content

Commit a2f2f16

Browse files
committed
SES-4620 - better sheet theme handling
1 parent a507d2f commit a2f2f16

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/src/main/java/org/thoughtcrime/securesms/ui/components/BottomSheets.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.thoughtcrime.securesms.ui.components
22

3+
import android.app.Activity
4+
import android.graphics.Color
5+
import android.os.Build
36
import androidx.annotation.DrawableRes
47
import androidx.annotation.StringRes
58
import androidx.compose.foundation.clickable
@@ -20,6 +23,7 @@ import androidx.compose.material3.Text
2023
import androidx.compose.material3.rememberModalBottomSheetState
2124
import androidx.compose.material3.rememberStandardBottomSheetState
2225
import androidx.compose.runtime.Composable
26+
import androidx.compose.runtime.DisposableEffect
2327
import androidx.compose.runtime.SideEffect
2428
import androidx.compose.ui.Alignment.Companion.CenterVertically
2529
import androidx.compose.ui.Modifier
@@ -67,12 +71,20 @@ fun BaseBottomSheet(
6771
// make sure the status and navigation bars follow our theme color's light vs dark
6872
val view = LocalView.current
6973
val isLight = LocalColors.current.isLight
70-
(view.parent as? DialogWindowProvider)?.window?.let { window ->
71-
SideEffect {
74+
75+
DisposableEffect(Unit) {
76+
val window = (view.parent as? DialogWindowProvider)?.window
77+
if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
78+
val prev = window.isNavigationBarContrastEnforced
79+
window.isNavigationBarContrastEnforced = false
7280
// Set status bar color
7381
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = isLight
7482
// Set navigation bar color
7583
WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = isLight
84+
85+
onDispose { window.isNavigationBarContrastEnforced = prev }
86+
} else {
87+
onDispose { }
7688
}
7789
}
7890

0 commit comments

Comments
 (0)