Skip to content

Commit 29564f9

Browse files
authored
Merge pull request #51 from funnyzak/feature/topic
2 parents 4b5ffb6 + ff8a0cf commit 29564f9

File tree

14 files changed

+359
-165
lines changed

14 files changed

+359
-165
lines changed

src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"intro": "This project used React Native to build a V2EX mobile client application. The main goal was to build a React Native rapid development scaffold."
55
},
66
"common": {
7-
"more":"More",
7+
"more": "More",
88
"home": "Home",
99
"integrated": "Integrated",
1010
"help": "Help",
@@ -79,6 +79,7 @@
7979
},
8080
"label": {
8181
"registedMember": "Registered Member",
82+
"latestReplay": "Latest Replay",
8283
"topicCount": "Topic Count",
8384
"postedTime": "Posted $",
8485
"lastReplyTime": "Last Replyed $",

src/i18n/locales/zh.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@
7979
},
8080
"label": {
8181
"registedMember": "注册会员",
82+
"latestReplay": "最新回复",
8283
"topicCount": "主题数量",
8384
"postedTime": "发布于 $",
8485
"lastReplyTime": "最后回复于 $",
8586
"replyedCount": "回复数量",
86-
"replyedTime": "回复于",
87+
"replyedTime": "回复于 $",
8788
"createSince": "创建至今",
8889
"profileLastModified": "最近修改于 $。",
8990
"activeLatest": "最近活跃于 $。",
@@ -148,9 +149,9 @@
148149
"token": "输入API令牌..",
149150
"search": "搜索关键字...",
150151
"message": "写点啥...",
151-
"empty": "无内容",
152-
"noResult": "无内容",
153-
"noFound": "未找到无内容。 ",
152+
"empty": "无内容",
153+
"noResult": "无内容",
154+
"noFound": "未找到内容 ",
154155
"noTopics": "还没有任何主题.",
155156
"noReplies": "还没有任何回复.",
156157
"noNodes": "还没有任何节点.",
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Created by leon<[email protected]> on 22/04/28.
3+
*/
4+
import React from 'react'
5+
import { View, ViewStyle, TextStyle, StyleProp, ImageSourcePropType, Image } from 'react-native'
6+
7+
import { Text, Button, Spinner, Placeholder } from '@src/components'
8+
import { ITheme, SylCommon, useTheme } from '@src/theme'
9+
import { translate } from '@src/i18n'
10+
import { NavigationService, ROUTES } from '@src/navigation'
11+
import { V2exObject } from '@src/types'
12+
import { BorderLine } from './General'
13+
14+
/**
15+
* TabCardContainer props
16+
*/
17+
export interface TabCardContainerProps {
18+
containerStyle?: StyleProp<ViewStyle>
19+
20+
title?: string
21+
22+
icon?: ImageSourcePropType
23+
24+
children?: React.ReactNode
25+
}
26+
27+
const TabCardContainer: React.FC<TabCardContainerProps> = ({
28+
containerStyle,
29+
title,
30+
icon,
31+
children
32+
}: TabCardContainerProps) => {
33+
const { theme } = useTheme()
34+
35+
const renderContent = () => {
36+
return (
37+
<View style={[SylCommon.Card.container(theme), styles.container(theme), containerStyle]}>
38+
<View style={styles.tabBar(theme)}>
39+
{icon && <Image source={icon} width={20} height={20} style={{ marginRight: theme.spacing.small }} />}
40+
<Text style={{ ...theme.typography.bodyText }}>{title ?? ''}</Text>
41+
</View>
42+
<BorderLine />
43+
<View style={styles.content(theme)}>{children}</View>
44+
</View>
45+
)
46+
}
47+
48+
return renderContent()
49+
}
50+
51+
const styles = {
52+
container: (theme: ITheme): ViewStyle => ({
53+
flexDirection: 'column'
54+
}),
55+
tabBar: (theme: ITheme): ViewStyle => ({
56+
display: 'flex',
57+
flexDirection: 'row',
58+
justifyContent: 'flex-start',
59+
alignItems: 'center',
60+
height: 36
61+
}),
62+
content: (theme: ITheme): ViewStyle => ({
63+
marginVertical: theme.spacing.small
64+
})
65+
}
66+
67+
export default TabCardContainer
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export { default as NotFound } from './NotFound'
2+
export { default as TabCardContainer } from './TabCardContainer'
3+
24
export * from './General'

src/screens/components/topic/Replay.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/screens/components/topic/ReplayList.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/screens/components/topic/TopicCardItem.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export interface TopicCardItemProps {
2424
*/
2525
displayStyle?: 'simple' | 'full' | 'auto'
2626

27+
/**
28+
* Whether to show last reply users
29+
*/
30+
showlastReplay?: boolean
31+
2732
/**
2833
* Topic Info
2934
*/
@@ -35,7 +40,13 @@ export interface TopicCardItemProps {
3540
onPress?: (topic: V2exObject.Topic) => void
3641
}
3742

38-
const TopicCardItem = ({ containerStyle, displayStyle = 'auto', topic, onPress }: TopicCardItemProps) => {
43+
const TopicCardItem = ({
44+
containerStyle,
45+
showlastReplay = true,
46+
displayStyle = 'auto',
47+
topic,
48+
onPress
49+
}: TopicCardItemProps) => {
3950
const { theme } = useTheme()
4051

4152
const display_style = useMemo(
@@ -90,7 +101,7 @@ const TopicCardItem = ({ containerStyle, displayStyle = 'auto', topic, onPress }
90101

91102
<View style={styles.infoMainItem(theme)}>
92103
<View style={styles.summaryContainer(theme)}>
93-
{topic.last_reply_by !== '' && (
104+
{topic.last_reply_by !== '' && showlastReplay ? (
94105
<TextWithIconPress
95106
containerStyle={[{ marginRight: theme.spacing.small }]}
96107
text={topic.last_reply_by}
@@ -100,7 +111,7 @@ const TopicCardItem = ({ containerStyle, displayStyle = 'auto', topic, onPress }
100111
NavigationService.navigate(ROUTES.Profile, { username: topic.last_reply_by })
101112
}}
102113
/>
103-
)}
114+
) : null}
104115
<TextWithIconPress
105116
containerStyle={[{ marginRight: theme.spacing.small }]}
106117
text={topic.replies.toString()}
@@ -157,7 +168,7 @@ const styles = {
157168
}),
158169
infoMainItem: (theme: ITheme): ViewStyle => ({
159170
flexDirection: 'row',
160-
marginBottom: theme.spacing.tiny,
171+
marginBottom: theme.spacing.small,
161172
justifyContent: 'space-between'
162173
}),
163174
summaryContainer: (theme: ITheme): ViewStyle => ({

src/screens/components/topic/TopicInfo.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
/**
22
* Created by leon<[email protected]> on 22/04/01.
33
*/
4-
import React from 'react'
5-
import { View, ViewStyle, TextStyle } from 'react-native'
6-
7-
import { Text, Button, Spinner, Placeholder } from '@src/components'
84
import { ITheme, SylCommon, useTheme } from '@src/theme'
9-
import { translate } from '@src/i18n'
10-
import { NavigationService, ROUTES } from '@src/navigation'
115
import { V2exObject } from '@src/types'
6+
import React from 'react'
7+
import { StyleProp, View, ViewStyle } from 'react-native'
8+
import RenderHtml from 'react-native-render-html'
9+
import TopicCardItem from './TopicCardItem'
1210

1311
/**
14-
* // TODO: TopicInfo
1512
* TopicInfo props
1613
*/
1714
export interface TopicInfoProps {
1815
/**
19-
* TopicInfo width
16+
* container style
2017
*/
21-
width?: number | string
18+
containerStyle?: StyleProp<ViewStyle>
2219

2320
/**
24-
* TopicInfo height
21+
* TopicInfo width
2522
*/
26-
height?: number | string
23+
info: V2exObject.Topic
2724
}
2825

29-
const TopicInfo: React.FC<TopicInfoProps> = ({ width, height }: TopicInfoProps) => {
26+
const TopicInfo: React.FC<TopicInfoProps> = ({ containerStyle, info }: TopicInfoProps) => {
27+
const { theme } = useTheme()
28+
3029
const renderContent = () => {
3130
return (
32-
<View>
33-
<Text>Hello World, TopicInfo.</Text>
31+
<View style={[SylCommon.Card.container(theme), styles.container(theme), containerStyle]}>
32+
<TopicCardItem topic={info} showlastReplay={false} />
33+
<RenderHtml
34+
source={{
35+
html: `<div style="color:${theme.colors.bodyText}">${info.content_rendered}</div>` || '<p></p>'
36+
}}
37+
contentWidth={theme.dimens.WINDOW_WIDTH - theme.spacing.large * 2}
38+
/>
3439
</View>
3540
)
3641
}
@@ -40,7 +45,7 @@ const TopicInfo: React.FC<TopicInfoProps> = ({ width, height }: TopicInfoProps)
4045

4146
const styles = {
4247
container: (theme: ITheme): ViewStyle => ({
43-
flex: 1
48+
paddingVertical: theme.spacing.medium
4449
})
4550
}
4651

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Created by leon<[email protected]> on 22/04/28.
3+
*/
4+
import { translate } from '@src/i18n'
5+
import { ITheme, useTheme } from '@src/theme'
6+
import { V2exObject } from '@src/types'
7+
import React from 'react'
8+
import { StyleProp, ViewStyle } from 'react-native'
9+
import { ReplayList } from '.'
10+
import { TabCardContainer } from '../common'
11+
12+
/**
13+
* TopicReplay props
14+
*/
15+
export interface TopicReplayProps {
16+
containerStyle?: StyleProp<ViewStyle>
17+
18+
info: V2exObject.Topic
19+
}
20+
21+
const TopicReplay: React.FC<TopicReplayProps> = ({ containerStyle, info }: TopicReplayProps) => {
22+
const { theme } = useTheme()
23+
24+
const renderContent = () => {
25+
return (
26+
<TabCardContainer
27+
containerStyle={[styles.container(theme), containerStyle]}
28+
icon={theme.assets.images.icons.tabbar.title.comment}
29+
title={translate('label.latestReplay')}>
30+
<ReplayList topicId={info.id} />
31+
</TabCardContainer>
32+
)
33+
}
34+
35+
return renderContent()
36+
}
37+
38+
const styles = {
39+
container: (theme: ITheme): ViewStyle => ({
40+
marginTop: theme.spacing.small,
41+
flex: 1
42+
})
43+
}
44+
45+
export default TopicReplay

0 commit comments

Comments
 (0)