Skip to content

Commit ff8a0cf

Browse files
committed
feat: topic replay
1 parent ebeb247 commit ff8a0cf

File tree

5 files changed

+97
-9
lines changed

5 files changed

+97
-9
lines changed

src/i18n/locales/zh.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"postedTime": "发布于 $",
8585
"lastReplyTime": "最后回复于 $",
8686
"replyedCount": "回复数量",
87-
"replyedTime": "回复于",
87+
"replyedTime": "回复于 $",
8888
"createSince": "创建至今",
8989
"profileLastModified": "最近修改于 $。",
9090
"activeLatest": "最近活跃于 $。",
@@ -149,9 +149,9 @@
149149
"token": "输入API令牌..",
150150
"search": "搜索关键字...",
151151
"message": "写点啥...",
152-
"empty": "无内容",
153-
"noResult": "无内容",
154-
"noFound": "未找到内容 ",
152+
"empty": "无内容",
153+
"noResult": "无内容",
154+
"noFound": "未找到内容 ",
155155
"noTopics": "还没有任何主题.",
156156
"noReplies": "还没有任何回复.",
157157
"noNodes": "还没有任何节点.",

src/screens/components/common/TabCardContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const styles = {
5757
flexDirection: 'row',
5858
justifyContent: 'flex-start',
5959
alignItems: 'center',
60-
height: 30
60+
height: 36
6161
}),
6262
content: (theme: ITheme): ViewStyle => ({
6363
marginVertical: theme.spacing.small

src/screens/components/topic/TopicInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const TopicInfo: React.FC<TopicInfoProps> = ({ containerStyle, info }: TopicInfo
4545

4646
const styles = {
4747
container: (theme: ITheme): ViewStyle => ({
48-
paddingTop: theme.spacing.medium
48+
paddingVertical: theme.spacing.medium
4949
})
5050
}
5151

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Created by leon<[email protected]> on 22/04/28.
3+
*/
4+
import RenderHtml from 'react-native-render-html'
5+
import React, { useMemo } from 'react'
6+
import { View, ViewStyle, TextStyle, StyleProp } from 'react-native'
7+
8+
import { Text, Button, Spinner, Placeholder, Avatar } from '@src/components'
9+
import { ITheme, SylCommon, useTheme } from '@src/theme'
10+
import { translate } from '@src/i18n'
11+
import { NavigationService, ROUTES } from '@src/navigation'
12+
import { V2exObject } from '@src/types'
13+
import { BorderLine, TextWithIconPress } from '../common'
14+
import dayjs from 'dayjs'
15+
16+
/**
17+
* TopicReplayItem props
18+
*/
19+
export interface TopicReplayItemProps {
20+
containerStyle?: StyleProp<ViewStyle>
21+
22+
info: V2exObject.TopicReply
23+
}
24+
25+
const TopicReplayItem: React.FC<TopicReplayItemProps> = ({ containerStyle, info }: TopicReplayItemProps) => {
26+
const { theme } = useTheme()
27+
const avatar_link = useMemo(() => (info.member ? info.member.avatar || info.member.avatar_normal : undefined), [info])
28+
return (
29+
<View style={[styles.container(theme), containerStyle]}>
30+
<View style={styles.infoContainer(theme)}>
31+
<Avatar size={40} source={{ uri: avatar_link }} username={info.member?.username} style={styles.avatar(theme)} />
32+
33+
<View style={styles.infoMain(theme)}>
34+
<View style={styles.infoMainItem(theme)}>
35+
<TextWithIconPress
36+
text={info.member?.username ?? 'none'}
37+
textStyle={[{ color: theme.colors.secondary }]}
38+
onPress={() => {
39+
NavigationService.navigate(ROUTES.Profile, { username: info.member?.username })
40+
}}
41+
/>
42+
<TextWithIconPress
43+
text={translate('label.replyedTime').replace('$', dayjs(info.created * 1000).fromNow())}
44+
/>
45+
</View>
46+
<View style={styles.infoMainItem(theme)}>
47+
<RenderHtml
48+
source={{
49+
html: `<div style="color:${theme.colors.bodyText}">${info.content_rendered}</div>` || '<p></p>'
50+
}}
51+
contentWidth={theme.dimens.layoutContainerWidth - 40 - theme.spacing.large}
52+
/>
53+
</View>
54+
</View>
55+
</View>
56+
<BorderLine width={0.4} />
57+
</View>
58+
)
59+
}
60+
61+
const styles = {
62+
container: (theme: ITheme): ViewStyle => ({
63+
paddingTop: theme.spacing.medium,
64+
width: '100%',
65+
flexDirection: 'column',
66+
justifyContent: 'flex-start',
67+
alignItems: 'center'
68+
}),
69+
infoContainer: (theme: ITheme): ViewStyle => ({
70+
flexDirection: 'row',
71+
marginBottom: theme.spacing.small
72+
}),
73+
avatar: (theme: ITheme): ViewStyle => ({
74+
width: 40,
75+
marginRight: theme.spacing.large
76+
}),
77+
infoMain: (theme: ITheme): ViewStyle => ({
78+
flex: 1,
79+
justifyContent: 'flex-start',
80+
flexDirection: 'column'
81+
}),
82+
infoMainItem: (theme: ITheme): ViewStyle => ({
83+
flexDirection: 'row',
84+
marginBottom: theme.spacing.small,
85+
justifyContent: 'space-between'
86+
})
87+
}
88+
89+
export default TopicReplayItem

src/screens/components/topic/TopicReplayList.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const TopicReplayList: React.FC<TopicReplayListProps> = ({ containerStyle, topic
7777
return (
7878
<Placeholder
7979
placeholderText={translate('placeholder.noResult')}
80+
displayType={'text'}
8081
buttonText={translate('button.tryAgain')}
8182
buttonPress={onRefresh}
8283
/>
@@ -93,9 +94,7 @@ const styles = {
9394
container: (theme: ITheme): ViewStyle => ({
9495
flex: 1
9596
}),
96-
itemContainer: (theme: ITheme): ViewStyle => ({
97-
...SylCommon.Card.container(theme)
98-
}),
97+
itemContainer: (theme: ITheme): ViewStyle => ({}),
9998
itemSeparator: (theme: ITheme) => ({
10099
height: 0
101100
})

0 commit comments

Comments
 (0)