@idealyst/navigation 1.0.65 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/navigation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.67",
|
|
4
4
|
"description": "Cross-platform navigation library for React and React Native",
|
|
5
5
|
"readme": "README.md",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"publish:npm": "npm publish"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@idealyst/components": "^1.0.
|
|
42
|
-
"@idealyst/theme": "^1.0.
|
|
41
|
+
"@idealyst/components": "^1.0.67",
|
|
42
|
+
"@idealyst/theme": "^1.0.67",
|
|
43
43
|
"@react-navigation/bottom-tabs": "^7.0.0",
|
|
44
44
|
"@react-navigation/drawer": "^7.0.0",
|
|
45
45
|
"@react-navigation/native": "^7.0.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Button, View, Text } from "@idealyst/components";
|
|
3
|
-
import { TabLayoutProps } from "src/routing";
|
|
2
|
+
import { Button, View, Text, Pressable } from "@idealyst/components";
|
|
3
|
+
import { RouteParam, TabBarScreenOptions, TabLayoutProps } from "src/routing";
|
|
4
4
|
|
|
5
5
|
export default function CustomTabLayout({
|
|
6
6
|
routes,
|
|
@@ -9,7 +9,7 @@ export default function CustomTabLayout({
|
|
|
9
9
|
onNavigate,
|
|
10
10
|
currentPath
|
|
11
11
|
}: TabLayoutProps) {
|
|
12
|
-
|
|
12
|
+
console.log(routes)
|
|
13
13
|
return (
|
|
14
14
|
<View>
|
|
15
15
|
<View>
|
|
@@ -25,14 +25,12 @@ export default function CustomTabLayout({
|
|
|
25
25
|
</View>
|
|
26
26
|
<View style={{ flexDirection: 'row' }}>
|
|
27
27
|
{routes.map(route => (
|
|
28
|
-
<
|
|
29
|
-
variant={currentPath === route.fullPath ? 'contained' : 'outlined'}
|
|
28
|
+
<TabButton
|
|
30
29
|
key={route.path}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
</Button>
|
|
30
|
+
route={route}
|
|
31
|
+
onNavigate={onNavigate}
|
|
32
|
+
currentPath={currentPath}
|
|
33
|
+
/>
|
|
36
34
|
))}
|
|
37
35
|
</View>
|
|
38
36
|
<View>
|
|
@@ -41,4 +39,26 @@ export default function CustomTabLayout({
|
|
|
41
39
|
</View>
|
|
42
40
|
)
|
|
43
41
|
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type TabButtonProps = {
|
|
45
|
+
route: RouteParam<TabBarScreenOptions>
|
|
46
|
+
onNavigate: (path: string) => void
|
|
47
|
+
currentPath: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function TabButton({route, onNavigate, currentPath}: TabButtonProps) {
|
|
51
|
+
if (route.type !== 'screen') return null
|
|
52
|
+
return (
|
|
53
|
+
<Pressable
|
|
54
|
+
key={route.path}
|
|
55
|
+
onPress={() => onNavigate(route.path)}
|
|
56
|
+
style={{ margin: 4 }}
|
|
57
|
+
>
|
|
58
|
+
{route.options?.tabBarIcon?.({ size: 20, color: currentPath === route.path ? 'blue' : 'black' })}
|
|
59
|
+
<Text style={{ color: currentPath === route.fullPath ? 'blue' : 'black' }}>
|
|
60
|
+
{route.fullPath === '/' ? 'Home' : route.fullPath}
|
|
61
|
+
</Text>
|
|
62
|
+
</Pressable>
|
|
63
|
+
)
|
|
44
64
|
}
|
|
@@ -5,6 +5,7 @@ import { UnistylesRuntime } from 'react-native-unistyles';
|
|
|
5
5
|
import { NavigatorParam, RouteParam } from '../routing';
|
|
6
6
|
import { useNavigator } from '../context';
|
|
7
7
|
import { getNextTheme, getThemeDisplayName, isHighContrastTheme } from './unistyles';
|
|
8
|
+
import CustomTabLayout from './CustomTabLayout';
|
|
8
9
|
|
|
9
10
|
const HomeTabScreen = () => {
|
|
10
11
|
const navigator = useNavigator();
|
|
@@ -195,6 +196,7 @@ const ThemeTabScreen = () => (
|
|
|
195
196
|
const TabRouter: NavigatorParam = {
|
|
196
197
|
path: "/",
|
|
197
198
|
layout: 'tab',
|
|
199
|
+
layoutComponent: CustomTabLayout,
|
|
198
200
|
routes: [
|
|
199
201
|
{
|
|
200
202
|
path: '/',
|
|
@@ -13,7 +13,7 @@ import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
|
|
|
13
13
|
export const buildNavigator = (params: NavigatorParam, parentPath = '') => {
|
|
14
14
|
const NavigatorType = getNavigatorType(params);
|
|
15
15
|
return () => (
|
|
16
|
-
<NavigatorType.Navigator
|
|
16
|
+
<NavigatorType.Navigator screenOptions={{
|
|
17
17
|
headerShown: params.options?.headerShown
|
|
18
18
|
}}>
|
|
19
19
|
{params.routes.map((child) => buildScreen(child, NavigatorType))}
|
package/src/routing/types.ts
CHANGED
|
@@ -15,10 +15,7 @@ export type TabBarScreenOptions = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Icon component for tab/drawer navigation (React.ComponentType, React.ReactElement, function, or string)
|
|
17
17
|
*/
|
|
18
|
-
tabBarIcon?:
|
|
19
|
-
| React.ReactElement
|
|
20
|
-
| ((props: { focused: boolean; color: string; size: string }) => React.ReactElement)
|
|
21
|
-
| string;
|
|
18
|
+
tabBarIcon?: ((props: { focused: boolean; color: string; size: string | number }) => React.ReactElement)
|
|
22
19
|
|
|
23
20
|
/**
|
|
24
21
|
* Label for tab/drawer navigation
|