Skip to content

Commit 4f590cd

Browse files
committed
feat: add DisableNavigationBarContrast function and update theme to allow custom navigation bar colors
1 parent 88826c5 commit 4f590cd

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

app/src/main/java/com/rosan/installer/ui/theme/InstallerTheme.kt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.rosan.installer.ui.theme
22

3+
import android.app.Activity
34
import android.os.Build
5+
import android.view.View
46
import androidx.activity.ComponentActivity
57
import androidx.compose.foundation.isSystemInDarkTheme
68
import androidx.compose.material3.MaterialTheme
@@ -55,9 +57,27 @@ fun InstallerTheme(
5557
}
5658
}
5759

60+
DisableNavigationBarContrast(view)
61+
5862
MaterialTheme(
5963
colorScheme = colorScheme,
6064
typography = Typography,
6165
content = content
6266
)
63-
}
67+
}
68+
69+
/**
70+
* Disable navigation bar contrast enforcement.
71+
* This is useful for devices where the navigation bar color should not be enforced
72+
* to match the system theme, allowing for custom colors.
73+
*/
74+
@Composable
75+
fun DisableNavigationBarContrast(view: View) {
76+
val view = LocalView.current
77+
if (!view.isInEditMode) {
78+
SideEffect {
79+
val window = (view.context as Activity).window
80+
window.isNavigationBarContrastEnforced = false
81+
}
82+
}
83+
}

app/src/main/res/values/themes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33

4-
<style name="Theme.Installer" parent="Theme.Material3.DayNight" />
4+
<style name="Theme.Installer" parent="Theme.Material3.DayNight">
5+
<!-- Compat Navigation Bar Color when ModalBottomSheet activated -->
6+
<item name="android:enforceNavigationBarContrast">false</item>
7+
</style>
58

69
<style name="Theme.Installer.Translucent" parent="Theme.Installer">
710
<item name="android:windowIsTranslucent">true</item>

0 commit comments

Comments
 (0)