Skip to content

Commit cca22a4

Browse files
committed
chore: consolidate index files
1 parent cf21710 commit cca22a4

8 files changed

Lines changed: 202 additions & 403 deletions

File tree

.circleci/config.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
executors:
44
default:
55
docker:
6-
- image: cimg/node:20.19.0
6+
- image: cimg/node:22.15.0
77
working_directory: ~/react-native-paper
88

99
commands:
@@ -20,30 +20,17 @@ jobs:
2020
- attach_project
2121
- restore_cache:
2222
keys:
23-
- dependencies-{{ checksum "package.json" }}
23+
- dependencies-{{ checksum "yarn.lock" }}
2424
- dependencies-
25-
- restore_cache:
26-
keys:
27-
- dependencies-example-{{ checksum "example/package.json" }}
28-
- dependencies-example-
2925
- run:
3026
name: Install dependencies
3127
command: |
32-
sudo corepack enable
33-
yarn --cwd example --immutable
34-
yarn --cwd docs --immutable
3528
yarn --immutable
3629
- save_cache:
37-
key: dependencies-{{ checksum "package.json" }}
30+
key: dependencies-{{ checksum "yarn.lock" }}
3831
paths:
3932
- node_modules
40-
- save_cache:
41-
key: dependencies-docs-{{ checksum "docs/package.json" }}
42-
paths:
4333
- docs/node_modules
44-
- save_cache:
45-
key: dependencies-example-{{ checksum "example/package.json" }}
46-
paths:
4734
- example/node_modules
4835
- persist_to_workspace:
4936
root: .

example/src/DrawerItems.tsx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import * as React from 'react';
2-
import {
3-
ColorValue,
4-
I18nManager,
5-
Platform,
6-
StyleSheet,
7-
View,
8-
} from 'react-native';
2+
import { ColorValue, Platform, StyleSheet, View } from 'react-native';
93

104
import { DrawerContentScrollView } from '@react-navigation/drawer';
115
import Constants, { ExecutionEnvironment } from 'expo-constants';
12-
import * as Updates from 'expo-updates';
136
import {
147
Badge,
158
Button,
@@ -124,16 +117,12 @@ function DrawerItems() {
124117
} = preferences;
125118

126119
const _handleToggleRTL = () => {
127-
if (expoGoExecution) {
120+
if (!isWeb && expoGoExecution) {
128121
setShowRTLDialog(true);
129122
return;
130123
}
131124

132125
toggleRTL();
133-
I18nManager.forceRTL(!isRTL);
134-
if (isWeb) {
135-
Updates.reloadAsync();
136-
}
137126
};
138127

139128
const _handleDismissRTLDialog = () => {
@@ -206,16 +195,14 @@ function DrawerItems() {
206195
</View>
207196
</TouchableRipple>
208197

209-
{!isWeb && (
210-
<TouchableRipple onPress={_handleToggleRTL}>
211-
<View style={[styles.preference, styles.v3Preference]}>
212-
<Text variant="labelLarge">RTL</Text>
213-
<View pointerEvents="none">
214-
<Switch value={isRTL} />
215-
</View>
198+
<TouchableRipple onPress={_handleToggleRTL}>
199+
<View style={[styles.preference, styles.v3Preference]}>
200+
<Text variant="labelLarge">RTL</Text>
201+
<View pointerEvents="none">
202+
<Switch value={isRTL} />
216203
</View>
217-
</TouchableRipple>
218-
)}
204+
</View>
205+
</TouchableRipple>
219206

220207
<TouchableRipple onPress={toggleCollapsed}>
221208
<View style={[styles.preference, styles.v3Preference]}>

example/src/ExampleList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default function ExampleList() {
139139
onPress={() => {
140140
// @ts-expect-error TypeScript can't call overloaded functions with union arguments.
141141
// https://github.com/microsoft/TypeScript/issues/40803
142-
navigation.navigate(id);
142+
navigation.navigate(item.id);
143143
}}
144144
/>
145145
)}

example/src/Examples/BottomNavigationBarExample.tsx

Lines changed: 82 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -29,101 +29,98 @@ function SettingsScreen() {
2929
);
3030
}
3131

32-
const BottomNavigationBarExample = Object.assign(
33-
createBottomTabNavigator({
34-
screenOptions: {
35-
headerShown: false,
36-
},
37-
tabBar: ({ navigation, state, descriptors }) => (
38-
<BottomNavigation.Bar
39-
navigationState={state}
40-
onTabPress={({ route, preventDefault }) => {
41-
const event = navigation.emit({
42-
type: 'tabPress',
43-
target: route.key,
44-
canPreventDefault: true,
32+
const BottomNavigationBarExample = createBottomTabNavigator({
33+
screenOptions: {
34+
headerShown: false,
35+
},
36+
tabBar: ({ navigation, state, descriptors }) => (
37+
<BottomNavigation.Bar
38+
navigationState={state}
39+
onTabPress={({ route, preventDefault }) => {
40+
const event = navigation.emit({
41+
type: 'tabPress',
42+
target: route.key,
43+
canPreventDefault: true,
44+
});
45+
46+
if (event.defaultPrevented) {
47+
preventDefault();
48+
} else {
49+
// Custom tab bars must target the tab navigator state.
50+
navigation.dispatch({
51+
...CommonActions.navigate(route.name, route.params),
52+
target: state.key,
4553
});
54+
}
55+
}}
56+
renderIcon={({ route, focused, color }) => {
57+
const tabBarIcon = descriptors[route.key].options.tabBarIcon;
4658

47-
if (event.defaultPrevented) {
48-
preventDefault();
49-
} else {
50-
// Custom tab bars must target the tab navigator state.
51-
navigation.dispatch({
52-
...CommonActions.navigate(route.name, route.params),
53-
target: state.key,
54-
});
55-
}
56-
}}
57-
renderIcon={({ route, focused, color }) => {
58-
const tabBarIcon = descriptors[route.key].options.tabBarIcon;
59+
const size = 24;
60+
const icon =
61+
typeof tabBarIcon === 'function'
62+
? tabBarIcon({ focused, color, size })
63+
: tabBarIcon;
5964

60-
const size = 24;
61-
const icon =
62-
typeof tabBarIcon === 'function'
63-
? tabBarIcon({ focused, color, size })
64-
: tabBarIcon;
65+
if (icon == null) {
66+
return null;
67+
}
6568

66-
if (icon == null) {
67-
return null;
68-
}
69+
if (React.isValidElement(icon)) {
70+
return icon;
71+
}
6972

70-
if (React.isValidElement(icon)) {
71-
return icon;
73+
if (typeof icon === 'object' && icon !== null && 'type' in icon) {
74+
switch (icon.type) {
75+
case 'sfSymbol':
76+
return <SFSymbol name={icon.name} size={size} color={color} />;
77+
case 'materialSymbol':
78+
return (
79+
<MaterialSymbol name={icon.name} size={size} color={color} />
80+
);
81+
case 'image':
82+
return (
83+
<Image
84+
accessibilityIgnoresInvertColors
85+
source={icon.source}
86+
resizeMode="contain"
87+
fadeDuration={0}
88+
style={{ width: size, height: size, tintColor: color }}
89+
/>
90+
);
7291
}
92+
}
7393

74-
if (typeof icon === 'object' && icon !== null && 'type' in icon) {
75-
switch (icon.type) {
76-
case 'sfSymbol':
77-
return <SFSymbol name={icon.name} size={size} color={color} />;
78-
case 'materialSymbol':
79-
return (
80-
<MaterialSymbol name={icon.name} size={size} color={color} />
81-
);
82-
case 'image':
83-
return (
84-
<Image
85-
accessibilityIgnoresInvertColors
86-
source={icon.source}
87-
resizeMode="contain"
88-
fadeDuration={0}
89-
style={{ width: size, height: size, tintColor: color }}
90-
/>
91-
);
92-
}
93-
}
94-
95-
throw new Error(
96-
'Tab bar icon is not a valid React element, SFSymbol, MaterialSymbol, or Image.'
97-
);
98-
}}
99-
getLabelText={({ route }) => descriptors[route.key].route.name}
100-
/>
101-
),
102-
screens: {
103-
Home: createBottomTabScreen({
104-
screen: HomeScreen,
105-
options: {
106-
tabBarIcon: ({ color, size }) => {
107-
return <Icon name="home" size={size} color={color} />;
108-
},
94+
throw new Error(
95+
'Tab bar icon is not a valid React element, SFSymbol, MaterialSymbol, or Image.'
96+
);
97+
}}
98+
getLabelText={({ route }) => descriptors[route.key].route.name}
99+
/>
100+
),
101+
screens: {
102+
Home: createBottomTabScreen({
103+
screen: HomeScreen,
104+
options: {
105+
tabBarIcon: ({ color, size }) => {
106+
return <Icon name="home" size={size} color={color} />;
109107
},
110-
}),
111-
Settings: createBottomTabScreen({
112-
screen: SettingsScreen,
113-
options: {
114-
tabBarIcon: ({ color, size }) => {
115-
return <Icon name="cog" size={size} color={color} />;
116-
},
108+
},
109+
}),
110+
Settings: createBottomTabScreen({
111+
screen: SettingsScreen,
112+
options: {
113+
tabBarIcon: ({ color, size }) => {
114+
return <Icon name="cog" size={size} color={color} />;
117115
},
118-
}),
119-
},
120-
}),
121-
{
122-
title: 'Bottom Navigation Bar',
123-
}
124-
);
116+
},
117+
}),
118+
},
119+
});
125120

126-
export default BottomNavigationBarExample;
121+
export default Object.assign(BottomNavigationBarExample, {
122+
title: 'Bottom Navigation Bar',
123+
});
127124

128125
const styles = StyleSheet.create({
129126
container: {

example/src/Examples/ThemingWithReactNavigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const HomeTab = createBottomTabNavigator({
3535
),
3636
},
3737
screens: {
38-
Home: createBottomTabScreen({
38+
ThemingHome: createBottomTabScreen({
3939
screen: HomeScreen,
4040
options: {
4141
tabBarIcon: Platform.select<BottomTabNavigationOptions['tabBarIcon']>({
@@ -53,7 +53,7 @@ const HomeTab = createBottomTabNavigator({
5353
}),
5454
},
5555
}),
56-
Settings: createBottomTabScreen({
56+
ThemingSettings: createBottomTabScreen({
5757
screen: SettingsScreen,
5858
options: {
5959
tabBarIcon: Platform.select<BottomTabNavigationOptions['tabBarIcon']>({

example/src/RootNavigator.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const Root = createNativeStackNavigator({
4949
options: {
5050
title: 'Examples',
5151
},
52+
linking: '',
5253
}),
5354
...fromEntries(
5455
(

0 commit comments

Comments
 (0)