Skip to content

Commit 929aa14

Browse files
authored
Merge branch 'main' into feat/TextField-v6
2 parents 72dcdd5 + 490a502 commit 929aa14

22 files changed

Lines changed: 2258 additions & 521 deletions

docs/docs/guides/01-getting-started.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ Minimum requirements:
4949

5050
Follow the [React Native Reanimated installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/).
5151

52-
If you're on a vanilla React Native project, you also need to install and link [@react-native-vector-icons/material-design-icons](https://github.com/oblador/react-native-vector-icons).
52+
If you're on a vanilla React Native project, you also need to install [@react-native-vector-icons/material-design-icons](https://github.com/oblador/react-native-vector-icons/tree/master/packages/material-design-icons).
5353

54-
Specifically `MaterialDesignIcons` icon pack needs to be included in the project, because some components use those internally (e.g. `AppBar.BackAction` on Android).
54+
Specifically, the `MaterialDesignIcons` icon pack needs to be included in the project because some components use those icons internally, such as `AppBar.BackAction` on Android.
5555

5656
```bash npm2yarn
5757
npm install @react-native-vector-icons/material-design-icons
5858
```
5959

6060
:::note
61-
The `react-native-vector-icons` library requires some additional setup steps for each platform. To ensure proper use of icon fonts, please follow their [installation guide](https://github.com/oblador/react-native-vector-icons?tab=readme-ov-file#setup).
61+
`@react-native-vector-icons/material-design-icons` may require some additional setup steps depending on platform. To ensure the icon font is configured correctly, please follow the upstream [installation guide](https://github.com/oblador/react-native-vector-icons?tab=readme-ov-file#setup).
6262
:::
6363

6464
:::info

docs/docs/guides/03-icons.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import IconsList from '@site/src/components/IconsList.tsx';
1010

1111
## Configuring icons
1212

13-
Many of the components require the [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons) library to render correctly. If you're using Expo, you don't need to do anything extra, but if it's a vanilla React Native project, you need to link the library as described in the [getting started guide](./01-getting-started.mdx).
13+
Many of the components render icon names using [`@react-native-vector-icons/material-design-icons`](https://github.com/oblador/react-native-vector-icons/tree/master/packages/material-design-icons). In Expo projects this usually works without extra setup. In vanilla React Native projects, install the package and complete any required platform setup as described in the [getting started guide](./01-getting-started.mdx).
1414

1515
:::note
1616
If you opted out of vector icons support using [babel-plugin-optional-require](https://github.com/satya164/babel-plugin-optional-require), you won't be able to use icon names for the icon prop. Some components may not look correct without vector icons and might need extra configuration.

docs/docs/guides/05-react-native-web.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Using on the Web
66

77
React Native Paper supports web via [React Native for Web](https://necolas.github.io/react-native-web/), which lets you run React Native components in a browser using React DOM.
88

9-
Before continuing, make sure you have React Native Paper installed and configured by following the [Getting Started guide](getting-started.md).
9+
Before continuing, make sure you have React Native Paper installed and configured by following the [Getting Started guide](01-getting-started.mdx).
1010

1111
## Setting up web support with Expo
1212

docs/docusaurus.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ const config = {
3737
tagline: 'Material Design for React Native',
3838
url,
3939
baseUrl,
40-
onBrokenLinks: 'log',
41-
onBrokenMarkdownLinks: 'log',
4240
favicon: 'images/favicon.ico',
4341

4442
// GitHub pages deployment config.
@@ -54,6 +52,10 @@ const config = {
5452
locales: ['en'],
5553
},
5654

55+
onBrokenLinks: 'throw',
56+
onDuplicateRoutes: 'throw',
57+
onBrokenMarkdownLinks: 'throw',
58+
5759
plugins: [
5860
[
5961
'./component-docs-plugin',

docs/plugins/docusaurus-react-native-plugin.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ module.exports = function () {
1212
react: path.resolve('node_modules/react'),
1313
'react-native$': 'react-native-web',
1414
'react-native-paper': path.resolve('../src'),
15-
'react-native-vector-icons/MaterialCommunityIcons': path.resolve(
16-
'node_modules/@react-native-vector-icons/material-design-icons'
17-
),
15+
'@react-native-vector-icons/get-image': false,
1816
},
1917
extensions: ['.web.js'],
2018
},

docs/src/css/custom.css

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ html[data-theme='light'] .gallery-dark {
128128
height: 124px;
129129
align-items: center;
130130
text-align: center;
131+
}
131132

132-
@media (max-width: 680px) {
133+
@media (max-width: 680px) {
134+
.icons-list-icon-container {
133135
width: 96px;
134136
}
135137
}
@@ -153,10 +155,10 @@ html[data-theme='light'] .gallery-dark {
153155
flex-wrap: wrap;
154156
justify-content: center;
155157
margin: 24px 0;
158+
}
156159

157-
&:last-child {
158-
justify-content: flex-start;
159-
}
160+
.icons-list-results:last-child {
161+
justify-content: flex-start;
160162
}
161163

162164
.icons-list-searchbar {
@@ -171,15 +173,15 @@ html[data-theme='light'] .gallery-dark {
171173
border-radius: 3px;
172174
transition: background-color 0.3s;
173175
outline: 0;
176+
}
174177

175-
&:focus,
176-
&:hover {
177-
background-color: #e7e7e7;
178-
}
178+
.icons-list-searchbar:focus,
179+
.icons-list-searchbar:hover {
180+
background-color: #e7e7e7;
181+
}
179182

180-
*:focus-visible {
181-
outline: auto;
182-
}
183+
.icons-list-searchbar:focus-visible {
184+
outline: auto;
183185
}
184186

185187
@font-face {

docs/src/data/extendedExamples/BottomNavigationBar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const staticCode = `import { Text, View } from 'react-native';
22
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
33
import { Provider, BottomNavigation } from 'react-native-paper';
4-
import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
4+
import MaterialCommunityIcons from '@react-native-vector-icons/material-design-icons';
55
import {
66
CommonActions,
77
createStaticNavigation,
@@ -103,7 +103,7 @@ const dynamicCode = `import { Text, View } from 'react-native';
103103
import { NavigationContainer, CommonActions } from '@react-navigation/native';
104104
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
105105
import { Provider, BottomNavigation } from 'react-native-paper';
106-
import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
106+
import MaterialCommunityIcons from '@react-native-vector-icons/material-design-icons';
107107
108108
function HomeScreen() {
109109
return (
Lines changed: 97 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,103 @@
11
import * as React from 'react';
2-
import { Platform, StyleSheet, View } from 'react-native';
2+
import { StyleSheet, View } from 'react-native';
33

4-
import { Palette, Switch, Text, TouchableRipple } from 'react-native-paper';
4+
import { Switch, Text, useTheme } from 'react-native-paper';
55

66
import ScreenWrapper from '../ScreenWrapper';
77

8+
const Row = ({
9+
label,
10+
children,
11+
}: {
12+
label: string;
13+
children: React.ReactNode;
14+
}) => (
15+
<View style={styles.row}>
16+
<Text>{label}</Text>
17+
<View style={styles.right}>{children}</View>
18+
</View>
19+
);
20+
821
const SwitchExample = () => {
9-
const [valueNormal, setNormalValue] = React.useState<boolean>(true);
10-
const [valueCustom, setCustomValue] = React.useState<boolean>(true);
22+
const theme = useTheme();
23+
const [defaultOn, setDefaultOn] = React.useState(true);
24+
const [defaultCheckedIconOn, setDefaultCheckedIconOn] = React.useState(true);
25+
const [defaultIconOn, setDefaultIconOn] = React.useState(true);
26+
const [customOn, setCustomOn] = React.useState(true);
27+
const [customIconOn, setCustomIconOn] = React.useState(true);
28+
const [disableAll, setDisableAll] = React.useState(false);
1129

12-
const switchValueNormalLabel = `switch ${
13-
valueNormal === true ? 'on' : 'off'
14-
}`;
15-
const switchValueCustomlLabel = `switch ${
16-
valueCustom === true ? 'on' : 'off'
17-
}`;
30+
const tertiaryTheme = React.useMemo(
31+
() => ({
32+
colors: {
33+
primary: theme.colors.tertiary,
34+
onPrimary: theme.colors.onTertiary,
35+
primaryContainer: theme.colors.tertiaryContainer,
36+
secondary: theme.colors.tertiary,
37+
},
38+
}),
39+
[theme]
40+
);
1841

19-
return Platform.OS === 'android' ? (
42+
return (
2043
<ScreenWrapper style={styles.container}>
21-
<TouchableRipple onPress={() => setNormalValue(!valueNormal)}>
22-
<View style={styles.row}>
23-
<Text>Normal {switchValueNormalLabel}</Text>
24-
<View pointerEvents="none">
25-
<Switch value={valueNormal} />
26-
</View>
27-
</View>
28-
</TouchableRipple>
29-
<TouchableRipple onPress={() => setCustomValue(!valueCustom)}>
30-
<View style={styles.row}>
31-
<Text>Custom {switchValueCustomlLabel}</Text>
32-
<View pointerEvents="none">
33-
<Switch value={valueCustom} color={Palette.tertiary50} />
34-
</View>
35-
</View>
36-
</TouchableRipple>
37-
<View style={styles.row}>
38-
<Text>Switch on (disabled)</Text>
39-
<Switch disabled value />
40-
</View>
41-
<View style={styles.row}>
42-
<Text>Switch off (disabled)</Text>
43-
<Switch disabled />
44-
</View>
45-
</ScreenWrapper>
46-
) : (
47-
<ScreenWrapper style={styles.container}>
48-
<View style={styles.row}>
49-
<Text>Normal {switchValueNormalLabel}</Text>
44+
<Row label="Default">
45+
<Switch
46+
value={defaultOn}
47+
onValueChange={setDefaultOn}
48+
disabled={disableAll}
49+
/>
50+
</Row>
51+
52+
<Row label="Default with icon when on">
53+
<Switch
54+
value={defaultCheckedIconOn}
55+
onValueChange={setDefaultCheckedIconOn}
56+
checkedIcon="check"
57+
disabled={disableAll}
58+
/>
59+
</Row>
60+
61+
<Row label="Default with icon">
5062
<Switch
51-
value={valueNormal}
52-
onValueChange={() => setNormalValue(!valueNormal)}
63+
value={defaultIconOn}
64+
onValueChange={setDefaultIconOn}
65+
checkedIcon="check"
66+
uncheckedIcon="close"
67+
disabled={disableAll}
5368
/>
54-
</View>
55-
<View style={styles.row}>
56-
<Text>Custom {switchValueCustomlLabel}</Text>
69+
</Row>
70+
71+
<Row label="Custom (tertiary theme)">
5772
<Switch
58-
value={valueCustom}
59-
onValueChange={() => setCustomValue(!valueCustom)}
60-
color={Palette.tertiary50}
73+
value={customOn}
74+
onValueChange={setCustomOn}
75+
theme={tertiaryTheme}
76+
disabled={disableAll}
6177
/>
62-
</View>
63-
<View style={styles.row}>
64-
<Text>Switch on (disabled)</Text>
65-
<Switch value disabled />
66-
</View>
67-
<View style={styles.row}>
68-
<Text>Switch off (disabled)</Text>
69-
<Switch value={false} disabled />
70-
</View>
78+
</Row>
79+
80+
<Row label="Custom with icon">
81+
<Switch
82+
value={customIconOn}
83+
onValueChange={setCustomIconOn}
84+
checkedIcon="white-balance-sunny"
85+
uncheckedIcon="moon-waning-crescent"
86+
theme={tertiaryTheme}
87+
disabled={disableAll}
88+
/>
89+
</Row>
90+
91+
<View
92+
style={[
93+
styles.separator,
94+
{ backgroundColor: theme.colors.outlineVariant },
95+
]}
96+
/>
97+
98+
<Row label="Disable all switches">
99+
<Switch value={disableAll} onValueChange={setDisableAll} />
100+
</Row>
71101
</ScreenWrapper>
72102
);
73103
};
@@ -85,6 +115,16 @@ const styles = StyleSheet.create({
85115
paddingVertical: 8,
86116
paddingHorizontal: 16,
87117
},
118+
right: {
119+
flexDirection: 'row',
120+
alignItems: 'center',
121+
gap: 12,
122+
},
123+
separator: {
124+
height: 1,
125+
marginHorizontal: 16,
126+
marginVertical: 16,
127+
},
88128
});
89129

90130
export default SwitchExample;

jest/testSetup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ jest.mock('react-native-worklets', () =>
88
require('react-native-worklets/lib/module/mock')
99
);
1010

11+
jest.mock('react-native-reanimated', () =>
12+
require('react-native-reanimated/mock')
13+
);
14+
1115
jest.mock('@react-native-vector-icons/material-design-icons', () => {
1216
const React = require('react');
1317
const { Text } = require('react-native');

src/components/BottomNavigation/BottomNavigationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const Touchable = <Route extends BaseRoute>({
241241
* import { useState } from 'react';
242242
* import { View } from 'react-native';
243243
* import { BottomNavigation, Text, Provider } from 'react-native-paper';
244-
* import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
244+
* import MaterialCommunityIcons from '@react-native-vector-icons/material-design-icons';
245245
*
246246
* function HomeScreen() {
247247
* return (

0 commit comments

Comments
 (0)