Skip to content

Commit c6f9a8f

Browse files
authored
feat: ✨ introduce separate package for navigation integration (#152)
* feat: ✨ introduce separate package for navigation integration * fix: 🐛 centralize tsconfig * fix: expo example * fix: 🐛 package.json definitions
1 parent f35cf37 commit c6f9a8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+377
-425
lines changed

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ module.exports = {
1515
},
1616
],
1717
},
18-
ignorePatterns: ['**/lib/**', '**/dist/**', '**/node_modules/**'],
18+
ignorePatterns: [
19+
'**/lib/**',
20+
'**/dist/**',
21+
'**/node_modules/**',
22+
'expo-env.d.ts',
23+
],
1924
};

apps/example-expo/app/(tabs)/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import { withLayoutContext } from 'expo-router';
4-
import createNativeBottomTabNavigator from '../../../../packages/react-native-bottom-tabs/src/react-navigation/navigators/createNativeBottomTabNavigator';
4+
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
55

66
const Tabs = withLayoutContext(createNativeBottomTabNavigator().Navigator);
77

apps/example-expo/app/(tabs)/explore.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { StyleSheet, Image } from 'react-native';
22

3-
import { Collapsible } from '@/components/Collapsible';
4-
import { ExternalLink } from '@/components/ExternalLink';
5-
import { ThemedText } from '@/components/ThemedText';
6-
import { ThemedView } from '@/components/ThemedView';
3+
import { Collapsible } from '../../components/Collapsible';
4+
import { ExternalLink } from '../../components/ExternalLink';
5+
import { ThemedText } from '../../components/ThemedText';
6+
import { ThemedView } from '../../components/ThemedView';
77
import { ScrollView } from 'react-native-gesture-handler';
88

99
function TabTwoScreen() {
@@ -46,7 +46,7 @@ function TabTwoScreen() {
4646
provide files for different screen densities
4747
</ThemedText>
4848
<Image
49-
source={require('@/assets/images/react-logo.png')}
49+
source={require('../../assets/images/react-logo.png')}
5050
style={{ alignSelf: 'center' }}
5151
/>
5252
<ExternalLink href="https://reactnative.dev/docs/images">

apps/example-expo/app/(tabs)/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ScrollView, StyleSheet, Platform } from 'react-native';
22

3-
import { ThemedText } from '@/components/ThemedText';
4-
import { ThemedView } from '@/components/ThemedView';
3+
import { ThemedText } from '../../components/ThemedText';
4+
import { ThemedView } from '../../components/ThemedView';
55

66
function HomeScreen() {
77
return (

apps/example-expo/app/+not-found.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Link, Stack } from 'expo-router';
22
import { StyleSheet } from 'react-native';
33

4-
import { ThemedText } from '@/components/ThemedText';
5-
import { ThemedView } from '@/components/ThemedView';
4+
import { ThemedText } from '../components/ThemedText';
5+
import { ThemedView } from '../components/ThemedView';
66

77
export default function NotFoundScreen() {
88
return (

apps/example-expo/app/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as SplashScreen from 'expo-splash-screen';
99
import { StatusBar } from 'expo-status-bar';
1010
import { useEffect } from 'react';
1111

12-
import { useColorScheme } from '@/hooks/useColorScheme';
12+
import { useColorScheme } from '../hooks/useColorScheme';
1313

1414
// Prevent the splash screen from auto-hiding before asset loading is complete.
1515
SplashScreen.preventAutoHideAsync();

apps/example-expo/babel.config.js

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
const path = require('path');
2-
const pak = require('../../packages/react-native-bottom-tabs/package.json');
2+
const fs = require('fs');
33

4-
module.exports = {
5-
presets: ['babel-preset-expo'],
6-
plugins: [
7-
[
8-
'module-resolver',
4+
const packages = path.resolve(__dirname, '..', '..', 'packages');
5+
6+
/** @type {import('@babel/core').TransformOptions} */
7+
module.exports = function (api) {
8+
api.cache(true);
9+
10+
const alias = Object.fromEntries(
11+
fs
12+
.readdirSync(packages)
13+
.filter((name) => !name.startsWith('.'))
14+
.map((name) => {
15+
const pak = require(`../../packages/${name}/package.json`);
16+
17+
if (pak.source == null) {
18+
return null;
19+
}
20+
21+
return [pak.name, path.resolve(packages, name, pak.source)];
22+
})
23+
.filter(Boolean)
24+
);
25+
26+
return {
27+
presets: ['babel-preset-expo'],
28+
overrides: [
929
{
10-
extensions: ['.tsx', '.ts', '.js', '.json'],
11-
alias: {
12-
'react-native-bottom-tabs': path.join(
13-
__dirname,
14-
'../../packages/react-native-bottom-tabs',
15-
pak.source
16-
),
17-
},
30+
exclude: /\/node_modules\//,
31+
plugins: [
32+
[
33+
'module-resolver',
34+
{
35+
extensions: ['.tsx', '.ts', '.js', '.json'],
36+
alias,
37+
},
38+
],
39+
],
1840
},
1941
],
20-
],
42+
};
2143
};

apps/example-expo/components/Collapsible.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { PropsWithChildren, useState } from 'react';
22
import { StyleSheet, TouchableOpacity } from 'react-native';
33

4-
import { ThemedText } from '@/components/ThemedText';
5-
import { ThemedView } from '@/components/ThemedView';
4+
import { ThemedText } from './ThemedText';
5+
import { ThemedView } from './ThemedView';
66

77
export function Collapsible({
88
children,

apps/example-expo/components/ThemedText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Text, type TextProps, StyleSheet } from 'react-native';
22

3-
import { useThemeColor } from '@/hooks/useThemeColor';
3+
import { useThemeColor } from '../hooks/useThemeColor';
44

55
export type ThemedTextProps = TextProps & {
66
lightColor?: string;

apps/example-expo/components/ThemedView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { View, type ViewProps } from 'react-native';
22

3-
import { useThemeColor } from '@/hooks/useThemeColor';
3+
import { useThemeColor } from '../hooks/useThemeColor';
44

55
export type ThemedViewProps = ViewProps & {
66
lightColor?: string;

0 commit comments

Comments
 (0)