tabbar 显示提醒红点

This commit is contained in:
mx1700 2019-07-22 21:59:36 +08:00
parent 72a6064efe
commit a19a7a6a53
3 changed files with 18 additions and 4 deletions

View file

@ -63,7 +63,7 @@ export default class Notification extends Component {
} }
renderLike(msg) { renderLike(msg) {
const body = `${msg.content.user.name} 给了你一个创可贴`; const body = `${msg.content.user.name} 给了你一个OK绷`;
return ( return (
<Touchable key={msg.link_id} onPress={() => this.props.onLikePress(msg)}> <Touchable key={msg.link_id} onPress={() => this.props.onLikePress(msg)}>
@ -99,8 +99,8 @@ const localStyle = StyleSheet.create({
lineHeight: 20 lineHeight: 20
}, },
icon2: { icon2: {
width: 14, width: 15,
height: 14, height: 15,
marginRight: 10, marginRight: 10,
marginTop: 4, marginTop: 4,
}, },

View file

@ -33,9 +33,10 @@ export default class NotificationList extends Component {
(async () => { (async () => {
try { try {
let notifications = await this.getMessages() let notifications = await this.getMessages();
this.notificationsData = notifications; this.notificationsData = notifications;
this.setNotifications(notifications); this.setNotifications(notifications);
this.props.onRefreshed && this.props.onRefreshed(notifications.length);
} catch (e) { } catch (e) {
this.setState({error: true}); this.setState({error: true});
} }

View file

@ -152,9 +152,21 @@ export default class NotificationPage extends Component {
_onRefresh() { _onRefresh() {
console.log(this.props.componentId);
this.restartTipTimer().done(); this.restartTipTimer().done();
} }
_onRefreshed(msgCount) {
if(msgCount > 99) {
msgCount = 99;
}
Navigation.mergeOptions(this.props.componentId, {
bottomTab: {
badge: msgCount > 0 ? msgCount.toString() : null,
}
});
}
refresh() { refresh() {
if(this.list) { if(this.list) {
this.list.refresh(false); this.list.refresh(false);
@ -172,6 +184,7 @@ export default class NotificationPage extends Component {
<NotificationList ref={(r) => {this.list = r}} <NotificationList ref={(r) => {this.list = r}}
isHistory={false} isHistory={false}
onRefresh={this._onRefresh.bind(this)} onRefresh={this._onRefresh.bind(this)}
onRefreshed={this._onRefreshed.bind(this)}
isSetRead={true} isSetRead={true}
{...this.props}/> {...this.props}/>
</View> </View>