@granite-js/react-native 0.1.23-next.6 → 0.1.23-next.7
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/CHANGELOG.md +15 -0
- package/dist/native-modules/natives/GraniteModule.brick.d.ts +1 -1
- package/dist/router/components/CanGoBackGuard.d.ts +2 -1
- package/package.json +10 -10
- package/src/native-modules/natives/GraniteModule.brick.ts +1 -1
- package/src/router/Router.tsx +17 -3
- package/src/router/components/CanGoBackGuard.tsx +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.23-next.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @granite-js/plugin-core@0.1.23-next.7
|
|
10
|
+
- @granite-js/style-utils@0.1.23-next.7
|
|
11
|
+
- @granite-js/lottie@0.1.23-next.7
|
|
12
|
+
- @granite-js/native@0.1.23-next.7
|
|
13
|
+
- @granite-js/image@0.1.23-next.7
|
|
14
|
+
- @granite-js/mpack@0.1.23-next.7
|
|
15
|
+
- @granite-js/jest@0.1.23-next.7
|
|
16
|
+
- @granite-js/cli@0.1.23-next.7
|
|
17
|
+
|
|
3
18
|
## 0.1.23-next.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BrickModuleSpec } from 'brick-module';
|
|
2
2
|
interface GraniteModuleSpec extends BrickModuleSpec {
|
|
3
3
|
readonly moduleName: 'GraniteModule';
|
|
4
|
-
closeView(): void
|
|
4
|
+
closeView(): Promise<void>;
|
|
5
5
|
schemeUri: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const GraniteModule: GraniteModuleSpec & {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export declare function CanGoBackGuard({ children, canGoBack, onBack, setIosSwipeGestureEnabled, }: {
|
|
2
|
+
export declare function CanGoBackGuard({ children, canGoBack, onBack, isInitialScreen, setIosSwipeGestureEnabled, }: {
|
|
3
3
|
canGoBack: boolean;
|
|
4
|
+
isInitialScreen: boolean;
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
onBack?: () => void;
|
|
6
7
|
setIosSwipeGestureEnabled?: ({ isEnabled }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/react-native",
|
|
3
|
-
"version": "0.1.23-next.
|
|
3
|
+
"version": "0.1.23-next.7",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.js"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@babel/core": "^7.24.9",
|
|
87
87
|
"@babel/preset-env": "^7.24.8",
|
|
88
88
|
"@babel/preset-typescript": "^7.24.7",
|
|
89
|
-
"@granite-js/native": "0.1.23-next.
|
|
89
|
+
"@granite-js/native": "0.1.23-next.7",
|
|
90
90
|
"@testing-library/dom": "^10.4.0",
|
|
91
91
|
"@testing-library/react": "^16.1.0",
|
|
92
92
|
"@types/babel__core": "^7",
|
|
@@ -105,20 +105,20 @@
|
|
|
105
105
|
"vitest": "^2.1.8"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@granite-js/native": "0.1.23-next.
|
|
108
|
+
"@granite-js/native": "0.1.23-next.7",
|
|
109
109
|
"@types/react": "*",
|
|
110
110
|
"brick-module": "*",
|
|
111
111
|
"react": "*",
|
|
112
112
|
"react-native": "*"
|
|
113
113
|
},
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"@granite-js/cli": "0.1.23-next.
|
|
116
|
-
"@granite-js/image": "0.1.23-next.
|
|
117
|
-
"@granite-js/jest": "0.1.23-next.
|
|
118
|
-
"@granite-js/lottie": "0.1.23-next.
|
|
119
|
-
"@granite-js/mpack": "0.1.23-next.
|
|
120
|
-
"@granite-js/plugin-core": "0.1.23-next.
|
|
121
|
-
"@granite-js/style-utils": "0.1.23-next.
|
|
115
|
+
"@granite-js/cli": "0.1.23-next.7",
|
|
116
|
+
"@granite-js/image": "0.1.23-next.7",
|
|
117
|
+
"@granite-js/jest": "0.1.23-next.7",
|
|
118
|
+
"@granite-js/lottie": "0.1.23-next.7",
|
|
119
|
+
"@granite-js/mpack": "0.1.23-next.7",
|
|
120
|
+
"@granite-js/plugin-core": "0.1.23-next.7",
|
|
121
|
+
"@granite-js/style-utils": "0.1.23-next.7",
|
|
122
122
|
"es-toolkit": "^1.39.8",
|
|
123
123
|
"react-native-url-polyfill": "1.3.0"
|
|
124
124
|
}
|
package/src/router/Router.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
RouteProp,
|
|
8
8
|
} from '@granite-js/native/@react-navigation/native';
|
|
9
9
|
import { NativeStackNavigationOptions } from '@granite-js/native/@react-navigation/native-stack';
|
|
10
|
-
import { ComponentProps, ComponentType, Fragment, PropsWithChildren, ReactElement, useCallback } from 'react';
|
|
10
|
+
import { ComponentProps, ComponentType, Fragment, PropsWithChildren, ReactElement, useCallback, useState } from 'react';
|
|
11
11
|
import { InitialProps } from '..';
|
|
12
12
|
import { closeView } from '../native-modules';
|
|
13
13
|
import { BackButton } from './components/BackButton';
|
|
@@ -163,9 +163,23 @@ export function Router({
|
|
|
163
163
|
[canGoBack, defaultScreenOption, headerLeft]
|
|
164
164
|
);
|
|
165
165
|
|
|
166
|
+
const [isInitialScreen, setIsInitialScreen] = useState(true);
|
|
167
|
+
|
|
166
168
|
return (
|
|
167
|
-
<NavigationContainer
|
|
168
|
-
|
|
169
|
+
<NavigationContainer
|
|
170
|
+
onStateChange={(state) => {
|
|
171
|
+
setIsInitialScreen(state ? state?.index === 0 : true);
|
|
172
|
+
}}
|
|
173
|
+
ref={navigationRef}
|
|
174
|
+
{...navigationContainerProps}
|
|
175
|
+
linking={linkingOptions}
|
|
176
|
+
>
|
|
177
|
+
<CanGoBackGuard
|
|
178
|
+
canGoBack={canGoBack}
|
|
179
|
+
isInitialScreen={isInitialScreen}
|
|
180
|
+
onBack={onBack}
|
|
181
|
+
setIosSwipeGestureEnabled={setIosSwipeGestureEnabled}
|
|
182
|
+
>
|
|
169
183
|
<Container {...initialProps}>
|
|
170
184
|
<StackNavigator.Navigator initialRouteName={initialRouteName} screenOptions={screenOptions}>
|
|
171
185
|
{Screens}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { ReactNode, useEffect } from 'react';
|
|
2
2
|
import { BackHandler } from 'react-native';
|
|
3
|
-
import { useIsInitialScreen } from '../hooks/useIsInitialScreen';
|
|
4
3
|
|
|
5
4
|
export function CanGoBackGuard({
|
|
6
5
|
children,
|
|
7
6
|
canGoBack,
|
|
8
7
|
onBack,
|
|
8
|
+
isInitialScreen,
|
|
9
9
|
setIosSwipeGestureEnabled,
|
|
10
10
|
}: {
|
|
11
11
|
canGoBack: boolean;
|
|
12
|
+
isInitialScreen: boolean;
|
|
12
13
|
children: ReactNode;
|
|
13
14
|
onBack?: () => void;
|
|
14
15
|
setIosSwipeGestureEnabled?: ({ isEnabled }: { isEnabled: boolean }) => void;
|
|
15
16
|
}) {
|
|
16
|
-
const isInitialScreen = useIsInitialScreen();
|
|
17
|
-
|
|
18
17
|
const shouldBlockGoingBack = !canGoBack;
|
|
19
18
|
|
|
20
19
|
useEffect(() => {
|