Browse Source

fix(YooForum): now the position of reply is changed with topic title height instead of a fixed value

dev 0.0.3a
kdxcxs 4 years ago
parent
commit
63fd23a718
  1. 7
      src/ui/YooForumTopicUI.js
  2. 6
      src/ui/YooForumUI.js

7
src/ui/YooForumTopicUI.js

@ -32,6 +32,7 @@ export default class YooForumTopicUI extends Component {
this.state = { this.state = {
detailShowing: false, detailShowing: false,
layoutY: 0, layoutY: 0,
layoutHeight: 0,
translate: new Animated.ValueXY({x: 0, y: 0}), translate: new Animated.ValueXY({x: 0, y: 0}),
}; };
this.topicHeaderRef = createRef(); this.topicHeaderRef = createRef();
@ -50,6 +51,7 @@ export default class YooForumTopicUI extends Component {
this.state.layoutY, this.state.layoutY,
this.onAnimationFinished, this.onAnimationFinished,
this.props.replies, this.props.replies,
this.state.layoutHeight,
); );
} else { } else {
this.props.hideDetail(this.state.translate, this.onAnimationFinished); this.props.hideDetail(this.state.translate, this.onAnimationFinished);
@ -65,7 +67,10 @@ export default class YooForumTopicUI extends Component {
]} ]}
onPress={this.onPress} onPress={this.onPress}
onLayout={(event) => { onLayout={(event) => {
this.setState({layoutY: event.nativeEvent.layout.y}); this.setState({
layoutY: event.nativeEvent.layout.y,
layoutHeight: event.nativeEvent.layout.height,
});
}}> }}>
<View ref={this.topicHeaderRef}> <View ref={this.topicHeaderRef}>
<Text style={styles.owner}>{this.props.topic.owner}</Text> <Text style={styles.owner}>{this.props.topic.owner}</Text>

6
src/ui/YooForumUI.js

@ -90,14 +90,14 @@ export default class YooForumUI extends Component {
this.hideDetail = this.hideDetail.bind(this); this.hideDetail = this.hideDetail.bind(this);
} }
showDetail(translate, layoutY, onAnimationFinished, replies) { showDetail(translate, layoutY, onAnimationFinished, replies, layoutHeight) {
this.replyRef.current.scrollTo({x: 0, y: 0, animated: false}); this.replyRef.current.scrollTo({x: 0, y: 0, animated: false});
this.setState({ this.setState({
scrollEnabled: false, scrollEnabled: false,
currentReplies: replies, currentReplies: replies,
}); });
this.state.replyTranslateY.setValue( this.state.replyTranslateY.setValue(
this.state.currentPosition + 100 + screenHeight, this.state.currentPosition + layoutHeight + screenHeight,
); );
Animated.parallel([ Animated.parallel([
Animated.timing(translate, { Animated.timing(translate, {
@ -114,7 +114,7 @@ export default class YooForumUI extends Component {
useNativeDriver: true, useNativeDriver: true,
}), }),
Animated.timing(this.state.replyTranslateY, { Animated.timing(this.state.replyTranslateY, {
toValue: this.state.currentPosition + 100, toValue: this.state.currentPosition + layoutHeight + 8,
duration: 250, duration: 250,
delay: 250, delay: 250,
useNativeDriver: true, useNativeDriver: true,

Loading…
Cancel
Save