pytech-ui 1.0.34 → 1.0.36
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/android/src/main/java/expo/modules/pytechui/Navigation/NavigationWrapperView.kt +17 -12
- package/build/jetpack-compose/components/Host.d.ts +2 -3
- package/build/jetpack-compose/components/Host.js +3 -9
- package/build/jetpack-compose/components/NavigationWrapper.d.ts +8 -6
- package/build/jetpack-compose/components/NavigationWrapper.js +8 -4
- package/build/jetpack-compose/index.d.ts +0 -1
- package/build/jetpack-compose/index.js +0 -1
- package/package.json +1 -1
- package/build/jetpack-compose/components/NavigationButton.d.ts +0 -7
- package/build/jetpack-compose/components/NavigationButton.js +0 -16
|
@@ -10,16 +10,13 @@ import androidx.navigation.NavHostController
|
|
|
10
10
|
import androidx.navigation.compose.NavHost
|
|
11
11
|
import androidx.navigation.compose.composable
|
|
12
12
|
import androidx.navigation.compose.rememberNavController
|
|
13
|
+
import expo.modules.kotlin.records.Field
|
|
14
|
+
import expo.modules.kotlin.records.Record
|
|
13
15
|
import expo.modules.kotlin.views.ComposeProps
|
|
14
16
|
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
15
17
|
import expo.modules.pytechui.findChildBySlotName
|
|
16
18
|
import expo.modules.ui.SlotView
|
|
17
19
|
|
|
18
|
-
object PytechRoutes {
|
|
19
|
-
const val SCREEN_A = "screen_A"
|
|
20
|
-
const val SCREEN_B = "screen_B"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* Referencia global al NavController del wrapper activo.
|
|
25
22
|
* Se setea al montar `NavigationWrapperView` y se limpia al desmontarlo.
|
|
@@ -39,13 +36,22 @@ object PytechNavigation {
|
|
|
39
36
|
/** Disponible para cualquier composable renderizado dentro del wrapper. */
|
|
40
37
|
val LocalPytechNavController = staticCompositionLocalOf<NavHostController?> { null }
|
|
41
38
|
|
|
39
|
+
data class NavigationRouteRecord(
|
|
40
|
+
@Field val route: String = "",
|
|
41
|
+
) : Record
|
|
42
|
+
|
|
42
43
|
data class NavigationWrapperProps(
|
|
43
|
-
val
|
|
44
|
+
val routes: List<NavigationRouteRecord> = emptyList(),
|
|
45
|
+
val startDestination: String = "",
|
|
44
46
|
) : ComposeProps
|
|
45
47
|
|
|
46
48
|
@Composable
|
|
47
49
|
internal fun FunctionalComposableScope.NavigationWrapperViewContent(props: NavigationWrapperProps) {
|
|
48
50
|
val navController = rememberNavController()
|
|
51
|
+
val routeNames = props.routes.map { it.route }.filter { it.isNotEmpty() }
|
|
52
|
+
val startDestination = props.startDestination.takeIf { it.isNotEmpty() }
|
|
53
|
+
?: routeNames.firstOrNull()
|
|
54
|
+
?: return
|
|
49
55
|
|
|
50
56
|
DisposableEffect(navController) {
|
|
51
57
|
PytechNavigation.navController = navController
|
|
@@ -56,17 +62,16 @@ internal fun FunctionalComposableScope.NavigationWrapperViewContent(props: Navig
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
val screenA = findChildBySlotName(PytechRoutes.SCREEN_A)
|
|
60
|
-
val screenB = findChildBySlotName(PytechRoutes.SCREEN_B)
|
|
61
|
-
|
|
62
65
|
CompositionLocalProvider(LocalPytechNavController provides navController) {
|
|
63
66
|
NavHost(
|
|
64
67
|
navController = navController,
|
|
65
|
-
startDestination =
|
|
68
|
+
startDestination = startDestination,
|
|
66
69
|
modifier = Modifier.fillMaxSize(),
|
|
67
70
|
) {
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
routeNames.forEach { route ->
|
|
72
|
+
val slot = findChildBySlotName(route)
|
|
73
|
+
composable(route) { RenderScreen(slot) }
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { HostProps as ExpoHostProps } from '@expo/ui/jetpack-compose';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export declare const Host: ({ style, screenB, ...props }: HostProps) => import("react").JSX.Element;
|
|
2
|
+
export type HostProps = ExpoHostProps;
|
|
3
|
+
export declare const Host: ({ style, children, ...props }: HostProps) => import("react").JSX.Element;
|
|
@@ -3,14 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Host = void 0;
|
|
4
4
|
const expo_1 = require("expo");
|
|
5
5
|
const jetpack_compose_1 = require("@expo/ui/jetpack-compose");
|
|
6
|
-
const NavigationWrapper_1 = require("./NavigationWrapper");
|
|
7
6
|
const ExtendedTheme = (0, expo_1.requireNativeView)('PytechUi', 'ExtendedTheme');
|
|
8
|
-
const Host = ({ style,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<ExtendedTheme>
|
|
12
|
-
{hasNavigation ? (<NavigationWrapper_1.NavigationWrapper screenA={props.children} screenB={screenB} startDestination='screen_A'/>) : (props.children)}
|
|
13
|
-
</ExtendedTheme>
|
|
14
|
-
</jetpack_compose_1.Host>);
|
|
15
|
-
};
|
|
7
|
+
const Host = ({ style, children, ...props }) => (<jetpack_compose_1.Host style={{ flex: 1, ...style }} {...props}>
|
|
8
|
+
<ExtendedTheme>{children}</ExtendedTheme>
|
|
9
|
+
</jetpack_compose_1.Host>);
|
|
16
10
|
exports.Host = Host;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export type
|
|
2
|
+
export type NavigationRouteDefinition = {
|
|
3
|
+
route: string;
|
|
4
|
+
screen: ReactNode;
|
|
5
|
+
};
|
|
3
6
|
export type NavigationWrapperProps = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
startDestination?: NavigationRoute;
|
|
7
|
+
routes: NavigationRouteDefinition[];
|
|
8
|
+
startDestination?: string;
|
|
7
9
|
};
|
|
8
|
-
export declare const navigate: (route:
|
|
10
|
+
export declare const navigate: (route: string) => Promise<void>;
|
|
9
11
|
export declare const goBack: () => Promise<boolean>;
|
|
10
|
-
export declare const NavigationWrapper: ({
|
|
12
|
+
export declare const NavigationWrapper: ({ routes, startDestination }: NavigationWrapperProps) => import("react").JSX.Element;
|
|
@@ -9,8 +9,12 @@ const navigate = (route) => Native.navigate(route);
|
|
|
9
9
|
exports.navigate = navigate;
|
|
10
10
|
const goBack = () => Native.goBack();
|
|
11
11
|
exports.goBack = goBack;
|
|
12
|
-
const NavigationWrapper = ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const NavigationWrapper = ({ routes, startDestination }) => {
|
|
13
|
+
const resolvedStartDestination = startDestination ?? routes[0]?.route;
|
|
14
|
+
return (<NavigationWrapperNativeView routes={routes.map(({ route }) => ({ route }))} startDestination={resolvedStartDestination}>
|
|
15
|
+
{routes.map(({ route, screen }) => (<SlotNativeView key={route} slotName={route}>
|
|
16
|
+
{screen}
|
|
17
|
+
</SlotNativeView>))}
|
|
18
|
+
</NavigationWrapperNativeView>);
|
|
19
|
+
};
|
|
16
20
|
exports.NavigationWrapper = NavigationWrapper;
|
|
@@ -11,7 +11,6 @@ export * from './components/List';
|
|
|
11
11
|
export * from './components/ListItem/index';
|
|
12
12
|
export * from './components/Menu';
|
|
13
13
|
export * from './components/NavigationWrapper';
|
|
14
|
-
export * from './components/NavigationButton';
|
|
15
14
|
export * from './components/PagePicker';
|
|
16
15
|
export * from './components/PullToRefreshBox';
|
|
17
16
|
export * from './components/Section';
|
|
@@ -27,7 +27,6 @@ __exportStar(require("./components/List"), exports);
|
|
|
27
27
|
__exportStar(require("./components/ListItem/index"), exports);
|
|
28
28
|
__exportStar(require("./components/Menu"), exports);
|
|
29
29
|
__exportStar(require("./components/NavigationWrapper"), exports);
|
|
30
|
-
__exportStar(require("./components/NavigationButton"), exports);
|
|
31
30
|
__exportStar(require("./components/PagePicker"), exports);
|
|
32
31
|
__exportStar(require("./components/PullToRefreshBox"), exports);
|
|
33
32
|
__exportStar(require("./components/Section"), exports);
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ButtonProps } from '@expo/ui/jetpack-compose';
|
|
2
|
-
import { NavigationRoute } from './NavigationWrapper';
|
|
3
|
-
export type NavigationButtonProps = Omit<ButtonProps, 'onClick'> & {
|
|
4
|
-
route: NavigationRoute;
|
|
5
|
-
onClick?: (route: NavigationRoute) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const NavigationButton: ({ route, onClick, children, ...props }: NavigationButtonProps) => import("react").JSX.Element;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NavigationButton = void 0;
|
|
4
|
-
const jetpack_compose_1 = require("@expo/ui/jetpack-compose");
|
|
5
|
-
const NavigationWrapper_1 = require("./NavigationWrapper");
|
|
6
|
-
const TextSlot_1 = require("./TextSlot");
|
|
7
|
-
const NavigationButton = ({ route, onClick, children, ...props }) => {
|
|
8
|
-
const handleClick = () => {
|
|
9
|
-
onClick?.(route);
|
|
10
|
-
(0, NavigationWrapper_1.navigate)(route);
|
|
11
|
-
};
|
|
12
|
-
return (<jetpack_compose_1.Button {...props} onClick={handleClick}>
|
|
13
|
-
{typeof children === 'string' ? <TextSlot_1.Text>{children}</TextSlot_1.Text> : children}
|
|
14
|
-
</jetpack_compose_1.Button>);
|
|
15
|
-
};
|
|
16
|
-
exports.NavigationButton = NavigationButton;
|