mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-24 08:55:14 +03:00
Revert "fixed posts not showing in profile screen"
This reverts commit 9ae24649b1
.
This commit is contained in:
parent
9ae24649b1
commit
0094704efc
@ -1,6 +1,7 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { View, TouchableHighlight } from 'react-native';
|
||||
import { View as AnimatedView } from 'react-native-animatable';
|
||||
import Animated, { EasingNode } from 'react-native-reanimated';
|
||||
|
||||
// Constants
|
||||
|
||||
// Components
|
||||
@ -16,38 +17,55 @@ class CollapsibleCardView extends PureComponent {
|
||||
* @prop { type } title - Collapsible title.
|
||||
*
|
||||
*/
|
||||
anime = {
|
||||
height: new Animated.Value(-1),
|
||||
expanded: false,
|
||||
contentHeight: 0,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.anime.expanded = props.expanded;
|
||||
|
||||
this.state = {
|
||||
expanded: props.expanded || false,
|
||||
};
|
||||
this.animatedContainerRef = React.createRef(null);
|
||||
}
|
||||
|
||||
_toggleOnPress = () => {
|
||||
const { expanded } = this.state;
|
||||
if (this.animatedContainerRef.current) {
|
||||
this.animatedContainerRef.current.animate({
|
||||
0: { height: expanded ? 0 : 200, opacity: expanded ? 0 : 1 },
|
||||
1: { height: expanded ? 200 : 0, opacity: expanded ? 1 : 0 },
|
||||
});
|
||||
// Component Functions
|
||||
_initContentHeight = (event) => {
|
||||
if (this.anime.contentHeight > 0) {
|
||||
return;
|
||||
}
|
||||
this.anime.contentHeight = event.nativeEvent.layout.height;
|
||||
this.anime.height.setValue(this.anime.expanded ? this._getMaxValue() : this._getMinValue());
|
||||
};
|
||||
|
||||
const { handleOnExpanded } = this.props;
|
||||
_getMaxValue = () => this.anime.contentHeight;
|
||||
|
||||
_getMinValue = () => 0;
|
||||
|
||||
_toggleOnPress = () => {
|
||||
const { handleOnExpanded, moreHeight } = this.props;
|
||||
Animated.timing(this.anime.height, {
|
||||
toValue: this.anime.expanded ? this._getMinValue() : this._getMaxValue() + (moreHeight || 0),
|
||||
duration: 200,
|
||||
easing: EasingNode.inOut(EasingNode.ease),
|
||||
}).start();
|
||||
this.anime.expanded = !this.anime.expanded;
|
||||
|
||||
this.setState({
|
||||
expanded: !expanded,
|
||||
expanded: this.anime.expanded,
|
||||
});
|
||||
|
||||
if (handleOnExpanded && expanded) {
|
||||
if (handleOnExpanded && this.anime.expanded) {
|
||||
handleOnExpanded();
|
||||
}
|
||||
};
|
||||
|
||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
||||
const { isExpanded, locked } = this.props;
|
||||
const { isExpanded, moreHeight, locked } = this.props;
|
||||
const { expanded } = this.state;
|
||||
|
||||
if (
|
||||
@ -57,6 +75,10 @@ class CollapsibleCardView extends PureComponent {
|
||||
) {
|
||||
this._toggleOnPress();
|
||||
}
|
||||
|
||||
if (moreHeight !== nextProps.moreHeight) {
|
||||
this.anime.height.setValue(this._getMaxValue() + nextProps.moreHeight);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -96,11 +118,12 @@ class CollapsibleCardView extends PureComponent {
|
||||
)}
|
||||
</TouchableHighlight>
|
||||
|
||||
<AnimatedView ref={this.animatedContainerRef} duration={500}>
|
||||
<View style={styles.content}>
|
||||
<View style={[!fitContent && !noContainer && styles.contentBody]}>{children}</View>
|
||||
</View>
|
||||
</AnimatedView>
|
||||
<Animated.View
|
||||
style={[styles.content, { height: this.anime.height, opacity: expanded ? 1 : 0 }]}
|
||||
onLayout={(e) => this._initContentHeight(e)}
|
||||
>
|
||||
<View style={[!fitContent && !noContainer && styles.contentBody]}>{children}</View>
|
||||
</Animated.View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user