Skip to content

Commit

Permalink
- [x] [超展开] 列表能看见历史帖子有多少新回复, 表现为(+30) +10
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Jul 13, 2019
1 parent 620516b commit 3c21f03
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 101 deletions.
4 changes: 2 additions & 2 deletions screens/_/icon/tabs-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-05-19 20:13:12
* @Last Modified by: czy0729
* @Last Modified time: 2019-05-30 15:33:33
* @Last Modified time: 2019-07-13 01:55:14
*/
import React from 'react'
import { StyleSheet } from 'react-native'
Expand Down Expand Up @@ -31,7 +31,7 @@ const styles = StyleSheet.create({
padding: _.sm
},
right: {
marginRight: -_.sm
marginRight: IOS ? -_.sm : 0
},
ios: {
marginBottom: _.tabsHeight
Expand Down
3 changes: 2 additions & 1 deletion screens/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-03-13 08:34:37
* @Last Modified by: czy0729
* @Last Modified time: 2019-07-12 00:42:09
* @Last Modified time: 2019-07-13 01:54:35
*/
import React from 'react'
import { StyleSheet, View } from 'react-native'
Expand Down Expand Up @@ -36,6 +36,7 @@ class Home extends React.Component {
/>
<IconTabsHeader
name='search'
position='right'
onPress={() => navigation.push('Search')}
/>
</>
Expand Down
2 changes: 1 addition & 1 deletion screens/rakuen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-04-26 13:40:51
* @Last Modified by: czy0729
* @Last Modified time: 2019-07-12 23:56:11
* @Last Modified time: 2019-07-13 01:56:06
*/
import React from 'react'
import { View } from 'react-native'
Expand Down
34 changes: 26 additions & 8 deletions screens/rakuen/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-04-27 20:21:08
* @Last Modified by: czy0729
* @Last Modified time: 2019-06-01 18:52:41
* @Last Modified time: 2019-07-13 03:35:28
*/
import React from 'react'
import { StyleSheet } from 'react-native'
Expand All @@ -22,23 +22,35 @@ const Item = (
) => {
const isTop = index === 0
const topicId = href.replace('/rakuen/topic/', '')
const { _loaded } = $.comments(topicId)
const readed = $.readed(topicId)
const isReaded = !!readed.time
const replyCount = parseInt(replies.match(/\d+/g))

let replyText = `+${replyCount}`
let replyAdd
if (isReaded) {
if (replyCount > readed.replies) {
replyText = `+${readed.replies}`
replyAdd = `+${replyCount - readed.replies}`
}
}

return (
<Touchable
style={[styles.container, _loaded && styles.readed, style]}
style={[styles.container, isReaded && styles.readed, style]}
highlight
onPress={() => {
// 对评论大于200的帖子进行网页跳转
const _replies = parseInt(replies.match(/\d+/g))
if (_replies > 200) {
if (replyCount > 200) {
info('该帖评论多, 自动使用浏览器打开')
setTimeout(() => {
open(`${HOST}${href}`)
}, 1600)
} else {
$.onItemPress(topicId, replyCount)
appNavigate(href, navigation, {
_title: title,
_replies: replies,
_replies: `(+${replyCount})`,
_group: group,
_time: time,
_avatar: avatar
Expand All @@ -51,10 +63,16 @@ const Item = (
<Flex.Item style={[styles.item, !isTop && styles.border, _.ml.sm]}>
<Text size={16}>
{title}
<Text type='main' size={12} lineHeight={16}>
<Text type={isReaded ? 'sub' : 'main'} size={12} lineHeight={16}>
{' '}
{replies}
({replyText})
</Text>
{!!replyAdd && (
<Text type='main' size={12} lineHeight={16}>
{' '}
{replyAdd}
</Text>
)}
</Text>
<Text style={_.mt.sm} type='sub' size={12}>
{correctTime(time)}
Expand Down
18 changes: 10 additions & 8 deletions screens/rakuen/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-04-27 14:09:17
* @Last Modified by: czy0729
* @Last Modified time: 2019-06-02 14:31:21
* @Last Modified time: 2019-07-13 03:17:03
*/
import React from 'react'
import { observable, computed } from 'mobx'
Expand Down Expand Up @@ -69,8 +69,8 @@ export default class ScreenRakuen extends store {
return computed(() => rakuenStore.rakuen(scope, type)).get()
}

comments(topidId) {
return computed(() => rakuenStore.comments(topidId)).get()
readed(topicId) {
return computed(() => rakuenStore.readed(topicId)).get()
}

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ export default class ScreenRakuen extends store {
_tabs[index].title = (
<Popover
data={MODEL_RAKUEN_TYPE_GROUP.data.map(item => item.label)}
onSelect={this.onGroupMenuClick}
onSelect={this.onGroupMenuPress}
>
<Text size={10} type='sub' lineHeight={14}>
<Text size={14}>小组</Text>{' '}
Expand All @@ -124,7 +124,7 @@ export default class ScreenRakuen extends store {
_tabs[index].title = (
<Popover
data={MODEL_RAKUEN_TYPE_MONO.data.map(item => item.label)}
onSelect={this.onMonoMenuClick}
onSelect={this.onMonoMenuPress}
>
<Text size={10} type='sub' lineHeight={14}>
<Text size={14}>人物</Text>{' '}
Expand Down Expand Up @@ -189,21 +189,23 @@ export default class ScreenRakuen extends store {
this.setStorage(undefined, undefined, namespace)
}

onGroupMenuClick = title => {
onGroupMenuPress = title => {
this.setState({
group: MODEL_RAKUEN_TYPE_GROUP.getValue(title)
})
this.fetchRakuen(true)
this.setStorage(undefined, undefined, namespace)
}

onMonoMenuClick = title => {
onMonoMenuPress = title => {
this.setState({
mono: MODEL_RAKUEN_TYPE_MONO.getValue(title)
})
this.fetchRakuen(true)
this.setStorage(undefined, undefined, namespace)
}

// -------------------- action --------------------
onItemPress = (topicId, replies) => {
rakuenStore.updateTopicReaded(topicId, replies)
}
}
2 changes: 1 addition & 1 deletion screens/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-04-12 13:56:44
* @Last Modified by: czy0729
* @Last Modified time: 2019-07-13 01:12:34
* @Last Modified time: 2019-07-13 01:56:00
*/
import React from 'react'
import { View } from 'react-native'
Expand Down
2 changes: 1 addition & 1 deletion screens/topic/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-04-29 19:55:09
* @Last Modified by: czy0729
* @Last Modified time: 2019-06-18 00:20:33
* @Last Modified time: 2019-07-13 02:39:53
*/
import { observable, computed } from 'mobx'
import { userStore, rakuenStore, subjectStore } from '@stores'
Expand Down
Loading

0 comments on commit 3c21f03

Please sign in to comment.