Skip to content

Commit 66cb3f5

Browse files
authored
feat: introduce material you theme for Expo Config Plugin (#244)
* feat: introduce material you dynamic style * docs: update contributing readme, various documentaion fixes
1 parent d43c4c6 commit 66cb3f5

File tree

8 files changed

+57
-25
lines changed

8 files changed

+57
-25
lines changed

.changeset/cyan-horses-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-bottom-tabs': patch
3+
---
4+
5+
feat: introduce material you theme for Expo plugin

CONTRIBUTING.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ yarn workspace react-native-bottom-tabs-example android
4242

4343
To run the React Native example app on iOS:
4444

45+
Make sure to install [`cocoapods-swift-modular-headers`](https://github.com/callstack/cocoapods-swift-modular-headers) gem, otherwise `pod install` will fail.
46+
47+
```sh
48+
gem install cocoapods-swift-modular-headers
49+
```
50+
51+
Next you can install cocoapods.
52+
4553
```sh
4654
cd apps/example/ios
4755
pod install
@@ -55,20 +63,20 @@ To run the Expo example:
5563
yarn workspace example-expo start
5664
```
5765

58-
By default, the example is configured to build with the old architecture. To run the example with the new architecture, you can do the following:
66+
By default, the example is configured to build with the new architecture. To run the example with the old architecture, you can do the following:
5967

6068
1. For Android, run:
6169

6270
```sh
6371
cd apps/example
64-
ORG_GRADLE_PROJECT_newArchEnabled=true yarn android
72+
ORG_GRADLE_PROJECT_newArchEnabled=false yarn android
6573
```
6674

6775
2. For iOS, run:
6876

6977
```sh
7078
cd apps/example/ios
71-
RCT_NEW_ARCH_ENABLED=1 pod install
79+
RCT_NEW_ARCH_ENABLED=0 pod install
7280
cd -
7381
yarn example ios
7482
```
@@ -82,7 +90,7 @@ yarn clean
8290
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
8391

8492
```sh
85-
Running "SwiftuiTabviewExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
93+
Running "ReactNativeBottomTabsExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
8694
```
8795

8896
Note the `"fabric":true` and `"concurrentRoot":true` properties.
@@ -129,26 +137,14 @@ Our pre-commit hooks verify that the linter and tests pass when committing.
129137

130138
### Publishing to npm
131139

132-
We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
140+
We use [changesets](https://github.com/changesets/changesets) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
133141

134142
To publish new versions, run the following:
135143

136144
```sh
137-
yarn release
145+
yarn publish-packages
138146
```
139147

140-
### Scripts
141-
142-
The `package.json` file contains various scripts for common tasks:
143-
144-
- `yarn`: setup project by installing dependencies.
145-
- `yarn typecheck`: type-check files with TypeScript.
146-
- `yarn lint`: lint files with ESLint.
147-
- `yarn test`: run unit tests with Jest.
148-
- `yarn workspace react-native-bottom-tabs-example start`: start the Metro server for the example app.
149-
- `yarn workspace react-native-bottom-tabs-example android`: run the example app on Android.
150-
- `yarn workspace react-native-bottom-tabs-example ios`: run the example app on iOS.
151-
152148
### Sending a pull request
153149

154150
> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).

docs/docs/docs/getting-started/quick-start.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { PackageManagerTabs } from '@theme';
66

77
<PackageManagerTabs command="install react-native-bottom-tabs" />
88

9+
If you are going to use [React Navigation / Expo Router Integration](/docs/guides/usage-with-react-navigation) make sure to install `@bottom-tabs/react-navigation`.
10+
11+
<PackageManagerTabs command="install @bottom-tabs/react-navigation" />
12+
913
<details>
1014
<summary>If you use React Native <b>version 0.75 or lower</b></summary>
1115

docs/docs/docs/guides/android-native-styling.md renamed to docs/docs/docs/guides/android-native-styling.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Android Native Styling
22

3+
React Native Bottom Tabs uses native platform primitives to ensure a consistent look and feel across platforms. This means that the appearance of the tabs is controlled by the native platform styling.
4+
5+
<div style={{ display: 'flex', justifyContent: 'center' }}>
6+
<video controls width="350" src="https://github.com/user-attachments/assets/8846e85b-c646-4aab-b668-59d0997ca007" />
7+
</div>
8+
39
## Expo users
410

511
Use Expo Config Plugin for Material 3 styling:
@@ -21,6 +27,12 @@ If you want to use Material2 styling, you can pass `theme` option to the plugin:
2127
}
2228
```
2329

30+
Available options:
31+
32+
- `material2` - Material Design 2 styling
33+
- `material3` - Material Design 3 styling
34+
- `material3-dynamic` - Material Design 3 styling with dynamic theming (Material You)
35+
2436
## React Native Community CLI users
2537

2638
Inside of your `android/app/src/main/res/values/styles.xml` file you can customize the appearance of the native bottom tabs.
@@ -35,6 +47,17 @@ Inside of your `android/app/src/main/res/values/styles.xml` file you can customi
3547
</resources>
3648
```
3749

50+
For Material 3 Dynamic theming (Material You), you can use `Theme.Material3.DynamicColors.DayNight.NoActionBar`:
51+
52+
```diff
53+
<resources>
54+
- <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
55+
+ <style name="AppTheme" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
56+
<!-- … -->
57+
</style>
58+
</resources>
59+
```
60+
3861
If you want to use Material Design 2, you can extend from `Theme.MaterialComponents.DayNight.NoActionBar`:
3962

4063
```diff

docs/docs/docs/guides/edge-to-edge-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In order to enable edge-to-edge follow installation instructions for [react-nati
66

77
:::note
88

9-
When using `react-native-edge-to-edge` config plugin, you don't need `react-native-bottom-tabs` config plugin. Make sure to set `parentTheme` to be either `Material2` or `Material3`.
9+
When using `react-native-edge-to-edge` config plugin, you don't need `react-native-bottom-tabs` config plugin. Make sure to set `parentTheme` to be one of `Material2` or `Material3` themes.
1010

1111
```json
1212
{

docs/docs/docs/guides/usage-with-expo-router.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ export default function TabLayout() {
4646

4747
For props and more information, see the [React Navigation integration guide](/docs/guides/usage-with-react-navigation).
4848

49-
Example: [EvanBacon/expo-router-react-native-bottom-tabs](https://github.com/EvanBacon/expo-router-react-native-bottom-tabs)
49+
Example: [okwasniewski/ExpoNativeTabs](https://github.com/okwasniewski/ExpoNativeTabs)
5050

docs/docs/docs/guides/usage-with-react-navigation.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ Available options:
123123
It's recommended to use `transparent` or `opaque` without lazy loading as the tab bar background flashes when a view is rendered lazily.
124124
:::
125125

126-
### `tabBarActiveTintColor`
126+
#### `tabBarActiveTintColor`
127127

128128
Color for the active tab.
129129

130-
### `tabBarInactiveTintColor`
130+
#### `tabBarInactiveTintColor`
131131

132132
Color for the inactive tabs.
133133

@@ -280,7 +280,7 @@ React.useEffect(() => {
280280

281281
### Hooks
282282

283-
`useBottomTabBarHeight`
283+
#### `useBottomTabBarHeight`
284284

285285
This hook returns the height of the bottom tab bar. This is useful when you want to place a component above the tab bar on iOS. It's not needed to offset the content of the screen as the navigator does it automatically.
286286

packages/react-native-bottom-tabs/src/expo.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
withAndroidStyles,
55
} from '@expo/config-plugins';
66

7+
const MATERIAL3_THEME_DYANMIC =
8+
'Theme.Material3.DynamicColors.DayNight.NoActionBar';
79
const MATERIAL3_THEME = 'Theme.Material3.DayNight.NoActionBar';
810
const MATERIAL2_THEME = 'Theme.MaterialComponents.DayNight.NoActionBar';
911

@@ -12,7 +14,7 @@ type ConfigProps = {
1214
* Define theme that should be used.
1315
* @default 'material3'
1416
*/
15-
theme: 'material2' | 'material3';
17+
theme: 'material2' | 'material3' | 'material3-dynamic';
1618
};
1719

1820
const withMaterial3Theme: ConfigPlugin<ConfigProps> = (config, options) => {
@@ -22,7 +24,9 @@ const withMaterial3Theme: ConfigPlugin<ConfigProps> = (config, options) => {
2224
stylesConfig.modResults.resources.style =
2325
stylesConfig.modResults.resources.style?.map((style) => {
2426
if (style.$.name === 'AppTheme') {
25-
if (theme === 'material2') {
27+
if (theme === 'material3-dynamic') {
28+
style.$.parent = MATERIAL3_THEME_DYANMIC;
29+
} else if (theme === 'material2') {
2630
style.$.parent = MATERIAL2_THEME;
2731
} else {
2832
style.$.parent = MATERIAL3_THEME;

0 commit comments

Comments
 (0)