react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

feat: add shared element transitions

Open WoLewicki opened this issue 2 years ago • 6 comments

Description

PR adding shared element transitions to native-stack. Please consider a draft for now since there is no Android implementation and only basic examples work on iOS. Most of the code is based on the shared element transitions in react-native-navigation since it also uses UIViewController as a container of the screen.

Test code and steps to reproduce

Test1089.tsx

Checklist

  • [x] Included code example that can be used to test this change
  • [ ] Updated TS types
  • [ ] Updated documentation:
    • [ ] https://github.com/software-mansion/react-native-screens/blob/master/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
    • [ ] https://github.com/software-mansion/react-native-screens/blob/master/native-stack/README.md
    • [ ] https://github.com/software-mansion/react-native-screens/blob/master/createNativeStackNavigator/README.md
    • [ ] https://github.com/software-mansion/react-native-screens/blob/master/src/types.tsx
    • [ ] https://github.com/software-mansion/react-native-screens/blob/master/src/native-stack/types.tsx
  • [ ] Ensured that CI passes

WoLewicki avatar Aug 27 '21 12:08 WoLewicki

Can't wait for this!

I'm thinking I may be able to get this to work on Web in userland by mapping nativeID to framer-motion's layoutId

nandorojo avatar Nov 25 '21 17:11 nandorojo

To follow up, I believe I figured out the Web side for this. I'm thinking of including it as a component in moti if this gets released with reanimated or react-native-screens. I think it could work like this for Web:

// index.tsx
import Animated from 'react-native-reanimated'

export const SharedView = Animated.View
// index.web.tsx
import { unstable_createElement } from 'react-native-web'
import { motion } from 'framer-motion'

const MotionView = (props) => unstable_createElement(motion.div, props);

export function SharedView({ nativeID, ...props }) {
  return <MotionView layoutId={nativeID} {...props} />
}

@WoLewicki I'm sure you have a lot on your plate, but do you think this will end up getting merged? It would be game changing.

nandorojo avatar Apr 14 '22 14:04 nandorojo

We are working on coupling SET platform specifics with reanimated ability to animate all view's props. You can watch the progress here and here. We are planning to prioritize it in the next days.

WoLewicki avatar Apr 19 '22 11:04 WoLewicki

That’s amazing news. You guys continue to innovate!

nandorojo avatar Apr 19 '22 12:04 nandorojo

That is indeed amazing news!

hirbod avatar Apr 27 '22 20:04 hirbod

As an update from my end, I did manage to get layout animation working on Web, so once this works on native, I should be able to add cross-platform support to Moti.

nandorojo avatar May 16 '22 15:05 nandorojo