From 88b80235b3239549dc353dcc1fa9b055b24b89a4 Mon Sep 17 00:00:00 2001 From: Batr Kanzitelli Date: Mon, 27 Sep 2021 03:48:23 +0200 Subject: [PATCH 01/14] add shared element & libs --- ios/Podfile.lock | 6 ++++++ package.json | 5 ++++- yarn.lock | 23 ++++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7320c88..1d2b0ff 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -411,6 +411,8 @@ PODS: - RNScreens (3.7.2): - React-Core - React-RCTImage + - RNSharedElement (0.8.2): + - React - RNVectorIcons (8.1.0): - React-Core - Yoga (1.14.0) @@ -485,6 +487,7 @@ DEPENDENCIES: - RNLocalize (from `../node_modules/react-native-localize`) - RNReanimated (from `../node_modules/react-native-reanimated`) - RNScreens (from `../node_modules/react-native-screens`) + - RNSharedElement (from `../node_modules/react-native-shared-element`) - RNVectorIcons (from `../node_modules/react-native-vector-icons`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) @@ -594,6 +597,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-reanimated" RNScreens: :path: "../node_modules/react-native-screens" + RNSharedElement: + :path: "../node_modules/react-native-shared-element" RNVectorIcons: :path: "../node_modules/react-native-vector-icons" Yoga: @@ -659,6 +664,7 @@ SPEC CHECKSUMS: RNLocalize: 7f1e5792b65a839af55a9552d05b3558b66d017e RNReanimated: ad24db8af24e3fe1b5c462785bc3db8d5baae2ee RNScreens: 0591543e343c7444ea1756b6265d81a4295922c9 + RNSharedElement: 87baf6d04da5b068f000dd8c953d28a1196999c0 RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4 Yoga: aa0cb45287ebe1004c02a13f279c55a95f1572f4 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a diff --git a/package.json b/package.json index d78754c..191c3d1 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "@react-navigation/bottom-tabs": "^6.0.5", "@react-navigation/native": "^6.0.2", "@react-navigation/native-stack": "^6.1.0", + "@react-navigation/stack": "^6.0.7", "date-fns": "^2.24.0", "formik": "^2.2.9", "i18n-js": "^3.8.0", @@ -48,8 +49,10 @@ "react-native-restart": "^0.0.22", "react-native-safe-area-context": "^3.3.2", "react-native-screens": "^3.7.2", + "react-native-shared-element": "^0.8.2", "react-native-ui-lib": "^6.0.0", - "react-native-vector-icons": "^8.1.0" + "react-native-vector-icons": "^8.1.0", + "react-navigation-shared-element": "^3.1.3" }, "devDependencies": { "@babel/core": "^7.12.9", diff --git a/yarn.lock b/yarn.lock index a885e63..5d27d82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1376,6 +1376,15 @@ dependencies: nanoid "^3.1.23" +"@react-navigation/stack@^6.0.7": + version "6.0.7" + resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-6.0.7.tgz#305e66129d0b425802bb6ed4f24dbd2fb56ab74f" + integrity sha512-hxwhRZbn6zD2rInhItBeHTCPYzmurz+/8/MhtRevBEdLG0+61dik8Y+evg/mu6AsOU0WrDakTsLcHdf/9zkXzw== + dependencies: + "@react-navigation/elements" "^1.1.0" + color "^3.1.3" + warn-once "^0.1.0" + "@sideway/address@^4.1.0": version "4.1.2" resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.2.tgz#811b84333a335739d3969cfc434736268170cad1" @@ -4096,7 +4105,7 @@ hermes-profile-transformer@^0.0.6: dependencies: source-map "^0.7.3" -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -6832,6 +6841,11 @@ react-native-screens@^3.7.2: dependencies: warn-once "^0.1.0" +react-native-shared-element@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/react-native-shared-element/-/react-native-shared-element-0.8.2.tgz#64124ec7e19369b78b6924c93808e1ed058c8109" + integrity sha512-IalCG1Sn6Vq171JMh0cbHzf0dJxwUIGwf5baxWhZ6busLQ2AL0A0pFb86sLgOUtv+NZdZX2R1Xd+Ylqj8neuLw== + react-native-slider@^0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/react-native-slider/-/react-native-slider-0.11.0.tgz#b68a0bc43c8422b24cd57947cc5ac2bcdb58fadc" @@ -6913,6 +6927,13 @@ react-native@0.65.1: whatwg-fetch "^3.0.0" ws "^6.1.4" +react-navigation-shared-element@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/react-navigation-shared-element/-/react-navigation-shared-element-3.1.3.tgz#c75084ca8cab09063297a39ff1110de0dc732aab" + integrity sha512-U1BZp7dEdcTNHggfkq3WEBlJeg4HwFhFdj7a0i0Uql/7mg2IHQg/bZaqM2jQvJITkABge6Hz5fZixIF8jyzpkg== + dependencies: + hoist-non-react-statics "^3.3.2" + react-refresh@^0.4.0: version "0.4.3" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.4.3.tgz#966f1750c191672e76e16c2efa569150cc73ab53" From 75b7980bc6d0508257e9c08f6cba39851402a90b Mon Sep 17 00:00:00 2001 From: Batr Kanzitelli Date: Mon, 27 Sep 2021 03:48:39 +0200 Subject: [PATCH 02/14] SharedElement --- src/components/reanimated2.tsx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/components/reanimated2.tsx b/src/components/reanimated2.tsx index bf6a565..4966e69 100644 --- a/src/components/reanimated2.tsx +++ b/src/components/reanimated2.tsx @@ -1,6 +1,7 @@ import React from 'react'; import {View, Text} from 'react-native-ui-lib'; import Animated, {withSpring, useAnimatedStyle, useSharedValue} from 'react-native-reanimated'; +import {SharedElement} from 'react-navigation-shared-element'; import {Bounceable} from './bounceable'; @@ -20,16 +21,18 @@ export const Reanimated2: React.FC = ({stID}: Reanimated2Props }; return ( - - - - - - Bounceable - - - - - + + + + + + + Bounceable + + + + + + ); }; From 6e8768ae88a6db1fbcbcacb2ed0f65e965c6ee4c Mon Sep 17 00:00:00 2001 From: Batr Kanzitelli Date: Mon, 27 Sep 2021 03:50:09 +0200 Subject: [PATCH 03/14] shared element related types --- src/services/navigation/types.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/services/navigation/types.ts b/src/services/navigation/types.ts index 7fe20f0..a30cb10 100644 --- a/src/services/navigation/types.ts +++ b/src/services/navigation/types.ts @@ -1,7 +1,9 @@ import {BottomTabNavigationOptions} from '@react-navigation/bottom-tabs'; import {NativeStackNavigationOptions} from '@react-navigation/native-stack'; +import {StackNavigationOptions} from '@react-navigation/stack'; +import {SharedElementsComponentConfig} from 'react-navigation-shared-element'; -import {Modal, Screen, Tabs} from '../../screens'; +import {Modal, Screen, SharedScreen, SharedTransitionScreen, Tabs} from '../../screens'; type ScreenInfo = { name: string; @@ -27,3 +29,15 @@ export type ModalScreenInfo = ScreenInfo; export type ModalScreenLayouts = { [key in Modal]: ScreenInfo; }; + +export type SharedScreenLayouts = { + [key in SharedScreen]: ScreenInfo; +}; +export type SharedTransitionScreenInfo = ScreenInfo & { + sharedElements?: SharedElementsComponentConfig | undefined; + options: () => StackNavigationOptions; +}; +export type SharedTransitionScreenLayouts = { + [key in SharedTransitionScreen]: SharedTransitionScreenInfo; +}; +export type GenSharedStackNavigatorProps = SharedTransitionScreenInfo[]; From 5b54cff49d2b0640bad3938c57557ad3d366fa1b Mon Sep 17 00:00:00 2001 From: Batr Kanzitelli Date: Mon, 27 Sep 2021 03:50:25 +0200 Subject: [PATCH 04/14] shared screens --- src/screens/shared.tsx | 66 ++++++++++++++++++++++++++++++ src/screens/sharedTo.tsx | 88 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 src/screens/shared.tsx create mode 100644 src/screens/sharedTo.tsx diff --git a/src/screens/shared.tsx b/src/screens/shared.tsx new file mode 100644 index 0000000..d6f8cd9 --- /dev/null +++ b/src/screens/shared.tsx @@ -0,0 +1,66 @@ +import React from 'react'; +import {Alert, Image, ScrollView} from 'react-native'; +import {View, Button, Text} from 'react-native-ui-lib'; +import {observer} from 'mobx-react'; +import {NativeStackScreenProps} from '@react-navigation/native-stack'; + +import {ScreenProps} from '.'; +import {useServices} from '../services'; +// import { useStores } from '../stores'; +// import { useConstants } from '../utils/constants'; + +import {Section} from '../components/section'; +import {randomNum} from '../utils/help'; +import {Reanimated2} from '../components/reanimated2'; +import {useNavigation} from '@react-navigation/core'; +import {SharedElement} from 'react-navigation-shared-element'; +import {Bounceable} from '../components/bounceable'; + +type Props = NativeStackScreenProps; + +export const Shared: React.FC = observer(({route}) => { + const {value} = route.params ?? {value: randomNum()}; + const {nav, t} = useServices(); + const navv = useNavigation(); + // const {} = useStores(); + // const {} = useConstants(); + + return ( + + + {/* + Shared screen + */} + +
+ {/* */} + + + navv.push('SharedTo')}> + + + + + + + + {/*
+ + {/*