Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REGRESSION] Use LayoutAnimation instead of Transition API #1338

Merged
merged 3 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { defaultHeader, onNavigationStateChange } from './utils/navigation';
import { loggerConfig, analytics } from './utils/log';
import Toast from './containers/Toast';
import RocketChat from './lib/rocketchat';
import LayoutAnimation from './utils/layoutAnimation';

useScreens();

Expand Down Expand Up @@ -313,14 +312,12 @@ export default class Root extends React.Component {
render() {
return (
<Provider store={store}>
<LayoutAnimation>
<App
ref={(navigatorRef) => {
Navigation.setTopLevelNavigator(navigatorRef);
}}
onNavigationStateChange={onNavigationStateChange}
/>
</LayoutAnimation>
<App
ref={(navigatorRef) => {
Navigation.setTopLevelNavigator(navigatorRef);
}}
onNavigationStateChange={onNavigationStateChange}
/>
</Provider>
);
}
Expand Down
15 changes: 6 additions & 9 deletions app/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import sharedStyles from './views/Styles';
import { isNotch, isIOS } from './utils/deviceInfo';
import { defaultHeader, onNavigationStateChange } from './utils/navigation';
import RocketChat from './lib/rocketchat';
import LayoutAnimation from './utils/layoutAnimation';

const InsideNavigator = createStackNavigator({
ShareListView: {
Expand Down Expand Up @@ -85,14 +84,12 @@ class Root extends React.Component {
onLayout={this.handleLayout}
>
<Provider store={store}>
<LayoutAnimation>
<AppContainer
ref={(navigatorRef) => {
Navigation.setTopLevelNavigator(navigatorRef);
}}
onNavigationStateChange={onNavigationStateChange}
/>
</LayoutAnimation>
<AppContainer
ref={(navigatorRef) => {
Navigation.setTopLevelNavigator(navigatorRef);
}}
onNavigationStateChange={onNavigationStateChange}
/>
</Provider>
</View>
);
Expand Down
38 changes: 2 additions & 36 deletions app/utils/layoutAnimation.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
import React from 'react';
import { Transition, Transitioning } from 'react-native-reanimated';
import PropTypes from 'prop-types';
import { LayoutAnimation } from 'react-native';

import debounce from './debounce';
import { isIOS } from './deviceInfo';
import sharedStyles from '../views/Styles';

const transition = (
<Transition.Together>
<Transition.In type='fade' />
<Transition.Out type='fade' />
<Transition.Change interpolation='easeInOut' />
</Transition.Together>
);

const TRANSITION_REF = React.createRef();

export const animateNextTransition = debounce(() => {
if (isIOS) {
TRANSITION_REF.current.animateNextTransition();
LayoutAnimation.easeInEaseOut();
}
}, 200, true);

const LayoutAnimation = ({ children }) => {
if (isIOS) {
return (
<Transitioning.View
style={sharedStyles.root}
transition={transition}
ref={TRANSITION_REF}
>
{children}
</Transitioning.View>
);
}
return children;
};

LayoutAnimation.propTypes = {
children: PropTypes.node
};

export default LayoutAnimation;