Browse Source

feat: support go back to topic list by Android back action

dev
kdxcxs 4 years ago
parent
commit
5c121dec37
  1. 2
      README.md
  2. 16
      src/ui/YooForumUI.js

2
README.md

@ -30,5 +30,5 @@
- [ ] 支持显示回复图片
- [ ] 在回复中显示头像
- [x] 当滑动到页面底部时显示"加载更多"
- [ ] 支持通过 Android BackHandler 从话题详情返回话题列表
- [x] 支持通过 Android BackHandler 从话题详情返回话题列表

16
src/ui/YooForumUI.js

@ -9,6 +9,7 @@ import {
Animated,
Dimensions,
Pressable,
BackHandler,
} from 'react-native';
import YooForumTopic from '../component/YooForumTopic';
import YooReply from './YooReply';
@ -88,9 +89,24 @@ export default class YooForumUI extends Component {
this.replyRef = createRef();
this.showDetail = this.showDetail.bind(this);
this.hideDetail = this.hideDetail.bind(this);
this.handleAndroidBack = this.handleAndroidBack.bind(this);
this.currentForumTopicUI = null;
}
componentDidMount() {
this.backHandler = BackHandler.addEventListener(
'hardwareBackPress',
this.handleAndroidBack,
);
}
handleAndroidBack() {
if (this.currentForumTopicUI){
this.hideDetail();
return true;
}
}
showDetail(ForumTopicUI) {
this.currentForumTopicUI = ForumTopicUI;
this.replyRef.current.scrollTo({x: 0, y: 0, animated: false});

Loading…
Cancel
Save