Skip to content

Commit 458c0de

Browse files
authored
Add Material2 / Material3 themes (#42)
1 parent b4336b6 commit 458c0de

File tree

21 files changed

+194
-99
lines changed

21 files changed

+194
-99
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,27 @@ Add the library plugin in your `app.json` config file and [create a new build](h
5757
}
5858
```
5959

60+
_📌 The available plugins options are:_
61+
62+
```ts
63+
type Options = {
64+
android?: {
65+
// use an edge-to-edge version of `Theme.{MaterialComponents,Material3}.DayNight.NoActionBar`
66+
parentTheme?: "Material2" | "Material3"; // optional, default is `undefined` (`Theme.EdgeToEdge`)
67+
};
68+
};
69+
```
70+
6071
> [!NOTE]
6172
> This library is not yet supported in the [Expo Go](https://expo.dev/go) sandbox app.
6273
6374
### Bare React Native
6475

65-
Edit your `android/app/src/main/res/values/styles.xml` file to inherit from the provided theme:
76+
Edit your `android/app/src/main/res/values/styles.xml` file to inherit from one of the provided themes:
6677

6778
```diff
6879
<resources>
80+
<!-- inherit from Theme.EdgeToEdge / Theme.EdgeToEdge.Material2 / Theme.EdgeToEdge.Material3 -->
6981
- <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
7082
+ <style name="AppTheme" parent="Theme.EdgeToEdge">
7183
<!-- … -->

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ repositories {
7070
dependencies {
7171
//noinspection GradleDynamicVersion
7272
implementation "com.facebook.react:react-native:+" // From node_modules
73+
implementation "com.google.android.material:material:${safeExtGet("materialVersion", "1.12.0")}"
7374
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<bool name="windowLightSystemBars">false</bool>
4+
</resources>

android/src/main/res/values-night-v27/styles.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<bool name="windowLightSystemBars">false</bool>
4+
</resources>

android/src/main/res/values-night/styles.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<bool name="windowLightSystemBars">true</bool>
4+
</resources>
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<style name="Theme.EdgeToEdge.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
4-
<item name="android:windowLightStatusBar">true</item>
5-
<item name="android:windowLightNavigationBar">true</item>
3+
<style name="Theme.EdgeToEdge" parent="Theme.EdgeToEdge.Common">
4+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
5+
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
66
</style>
77

8-
<style name="Theme.EdgeToEdge" parent="Theme.EdgeToEdge.Common">
8+
<style name="Theme.EdgeToEdge.Material2" parent="Theme.EdgeToEdge.Material2.Common">
9+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
10+
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
11+
</style>
12+
13+
<style name="Theme.EdgeToEdge.Material3" parent="Theme.EdgeToEdge.Material3.Common">
14+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
915
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
1016
</style>
1117
</resources>

android/src/main/res/values-v29/styles.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<style name="Theme.EdgeToEdge" parent="Theme.EdgeToEdge.Common">
4+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
5+
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
6+
<item name="android:enforceStatusBarContrast">false</item>
7+
<item name="android:enforceNavigationBarContrast">true</item>
8+
</style>
9+
10+
<style name="Theme.EdgeToEdge.Material2" parent="Theme.EdgeToEdge.Material2.Common">
11+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
12+
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
13+
<item name="android:enforceStatusBarContrast">false</item>
14+
<item name="android:enforceNavigationBarContrast">true</item>
15+
</style>
16+
17+
<style name="Theme.EdgeToEdge.Material3" parent="Theme.EdgeToEdge.Material3.Common">
18+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
419
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
520
<item name="android:enforceStatusBarContrast">false</item>
621
<item name="android:enforceNavigationBarContrast">true</item>

android/src/main/res/values-v30/styles.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<style name="Theme.EdgeToEdge" parent="Theme.EdgeToEdge.Common">
4+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
5+
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
6+
<item name="android:enforceStatusBarContrast">false</item>
7+
<item name="android:enforceNavigationBarContrast">true</item>
8+
</style>
9+
10+
<style name="Theme.EdgeToEdge.Material2" parent="Theme.EdgeToEdge.Material2.Common">
11+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
12+
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
13+
<item name="android:enforceStatusBarContrast">false</item>
14+
<item name="android:enforceNavigationBarContrast">true</item>
15+
</style>
16+
17+
<style name="Theme.EdgeToEdge.Material3" parent="Theme.EdgeToEdge.Material3.Common">
18+
<item name="android:windowLightNavigationBar">@bool/windowLightSystemBars</item>
419
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
520
<item name="android:enforceStatusBarContrast">false</item>
621
<item name="android:enforceNavigationBarContrast">true</item>

0 commit comments

Comments
 (0)