Update post thread aesthetics
parent
6bec139679
commit
71594d069c
|
@ -133,8 +133,6 @@ export const FeedItem = observer(function FeedItem({
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
outer: {
|
outer: {
|
||||||
// borderWidth: 1,
|
|
||||||
// borderColor: '#e8e8e8',
|
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
margin: 2,
|
margin: 2,
|
||||||
marginBottom: 0,
|
marginBottom: 0,
|
||||||
|
|
|
@ -75,7 +75,7 @@ export const PostThread = observer(function PostThread({uri}: {uri: string}) {
|
||||||
<PostThreadItem item={item} onPressShare={onPressShare} />
|
<PostThreadItem item={item} onPressShare={onPressShare} />
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<View style={s.h100pct}>
|
<View>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={posts}
|
data={posts}
|
||||||
keyExtractor={item => item._reactKey}
|
keyExtractor={item => item._reactKey}
|
||||||
|
|
|
@ -9,14 +9,6 @@ import {ago, pluralize} from '../../lib/strings'
|
||||||
import {AVIS} from '../../lib/assets'
|
import {AVIS} from '../../lib/assets'
|
||||||
import {useStores} from '../../../state'
|
import {useStores} from '../../../state'
|
||||||
|
|
||||||
function iter<T>(n: number, fn: (_i: number) => T): Array<T> {
|
|
||||||
const arr: T[] = []
|
|
||||||
for (let i = 0; i < n; i++) {
|
|
||||||
arr.push(fn(i))
|
|
||||||
}
|
|
||||||
return arr
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PostThreadItem = observer(function PostThreadItem({
|
export const PostThreadItem = observer(function PostThreadItem({
|
||||||
item,
|
item,
|
||||||
onPressShare,
|
onPressShare,
|
||||||
|
@ -61,12 +53,55 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
.catch(e => console.error('Failed to toggle like', record, e))
|
.catch(e => console.error('Failed to toggle like', record, e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Ctrls = () => (
|
||||||
|
<View style={styles.ctrls}>
|
||||||
|
<TouchableOpacity style={styles.ctrl} onPress={onPressReply}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
style={styles.ctrlIcon}
|
||||||
|
icon={['far', 'comment']}
|
||||||
|
size={14}
|
||||||
|
/>
|
||||||
|
<Text style={s.f13}>{item.replyCount}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleRepost}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
style={
|
||||||
|
item.myState.hasReposted ? styles.ctrlIconReposted : styles.ctrlIcon
|
||||||
|
}
|
||||||
|
icon="retweet"
|
||||||
|
size={18}
|
||||||
|
/>
|
||||||
|
<Text
|
||||||
|
style={item.myState.hasReposted ? [s.bold, s.green3, s.f13] : s.f13}>
|
||||||
|
{item.repostCount}
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleLike}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
style={item.myState.hasLiked ? styles.ctrlIconLiked : styles.ctrlIcon}
|
||||||
|
icon={[item.myState.hasLiked ? 'fas' : 'far', 'heart']}
|
||||||
|
size={14}
|
||||||
|
/>
|
||||||
|
<Text style={item.myState.hasLiked ? [s.bold, s.red3, s.f13] : s.f13}>
|
||||||
|
{item.likeCount}
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.ctrl}
|
||||||
|
onPress={() => onPressShare(item.uri)}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
style={styles.ctrlIcon}
|
||||||
|
icon="share-from-square"
|
||||||
|
size={14}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (item._isHighlightedPost) {
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity style={styles.outer} onPress={onPressOuter}>
|
<View style={styles.outer}>
|
||||||
<View style={styles.layout}>
|
<View style={styles.layout}>
|
||||||
{iter(Math.abs(item._depth), (i: number) => (
|
|
||||||
<View key={i} style={styles.replyBar} />
|
|
||||||
))}
|
|
||||||
<TouchableOpacity style={styles.layoutAvi} onPress={onPressAuthor}>
|
<TouchableOpacity style={styles.layoutAvi} onPress={onPressAuthor}>
|
||||||
<Image
|
<Image
|
||||||
style={styles.avi}
|
style={styles.avi}
|
||||||
|
@ -74,28 +109,27 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
/>
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<View style={styles.layoutContent}>
|
<View style={styles.layoutContent}>
|
||||||
<View style={styles.meta}>
|
<View style={[styles.meta, s.mt5]}>
|
||||||
<Text
|
<Text
|
||||||
style={[styles.metaItem, s.f15, s.bold]}
|
style={[styles.metaItem, s.f15, s.bold]}
|
||||||
onPress={onPressAuthor}>
|
onPress={onPressAuthor}>
|
||||||
{item.author.displayName}
|
{item.author.displayName}
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text style={[styles.metaItem, s.f14, s.gray5]}>
|
||||||
|
· {ago(item.indexedAt)}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.meta}>
|
||||||
<Text
|
<Text
|
||||||
style={[styles.metaItem, s.f14, s.gray5]}
|
style={[styles.metaItem, s.f14, s.gray5]}
|
||||||
onPress={onPressAuthor}>
|
onPress={onPressAuthor}>
|
||||||
@{item.author.name}
|
@{item.author.name}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[styles.metaItem, s.f14, s.gray5]}>
|
|
||||||
· {ago(item.indexedAt)}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
<Text
|
</View>
|
||||||
style={[
|
</View>
|
||||||
styles.postText,
|
<View style={[s.pl10, s.pr10, s.pb10]}>
|
||||||
...(item._isHighlightedPost
|
<Text style={[styles.postText, s.f18, s['lh18-1.3']]}>
|
||||||
? [s.f16, s['lh16-1.3']]
|
|
||||||
: [s.f15, s['lh15-1.3']]),
|
|
||||||
]}>
|
|
||||||
{record.text}
|
{record.text}
|
||||||
</Text>
|
</Text>
|
||||||
{item._isHighlightedPost && hasEngagement ? (
|
{item._isHighlightedPost && hasEngagement ? (
|
||||||
|
@ -124,74 +158,59 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
<View style={styles.ctrls}>
|
<View style={[s.pl10]}>
|
||||||
<TouchableOpacity style={styles.ctrl} onPress={onPressReply}>
|
<Ctrls />
|
||||||
<FontAwesomeIcon
|
|
||||||
style={styles.ctrlIcon}
|
|
||||||
icon={['far', 'comment']}
|
|
||||||
size={14}
|
|
||||||
/>
|
|
||||||
<Text style={s.f13}>{item.replyCount}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleRepost}>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
style={
|
|
||||||
item.myState.hasReposted
|
|
||||||
? styles.ctrlIconReposted
|
|
||||||
: styles.ctrlIcon
|
|
||||||
}
|
|
||||||
icon="retweet"
|
|
||||||
size={18}
|
|
||||||
/>
|
|
||||||
<Text
|
|
||||||
style={
|
|
||||||
item.myState.hasReposted ? [s.bold, s.green3, s.f13] : s.f13
|
|
||||||
}>
|
|
||||||
{item.repostCount}
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleLike}>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
style={
|
|
||||||
item.myState.hasLiked ? styles.ctrlIconLiked : styles.ctrlIcon
|
|
||||||
}
|
|
||||||
icon={[item.myState.hasLiked ? 'fas' : 'far', 'heart']}
|
|
||||||
size={14}
|
|
||||||
/>
|
|
||||||
<Text
|
|
||||||
style={item.myState.hasLiked ? [s.bold, s.red3, s.f13] : s.f13}>
|
|
||||||
{item.likeCount}
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity
|
|
||||||
style={styles.ctrl}
|
|
||||||
onPress={() => onPressShare(item.uri)}>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
style={styles.ctrlIcon}
|
|
||||||
icon="share-from-square"
|
|
||||||
size={14}
|
|
||||||
/>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<TouchableOpacity style={styles.outer} onPress={onPressOuter}>
|
||||||
|
<View style={styles.layout}>
|
||||||
|
<TouchableOpacity style={styles.layoutAvi} onPress={onPressAuthor}>
|
||||||
|
<Image
|
||||||
|
style={styles.avi}
|
||||||
|
source={AVIS[item.author.name] || AVIS['alice.com']}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<View style={styles.layoutContent}>
|
||||||
|
<View style={styles.meta}>
|
||||||
|
<Text
|
||||||
|
style={[styles.metaItem, s.f15, s.bold]}
|
||||||
|
onPress={onPressAuthor}>
|
||||||
|
{item.author.displayName}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[styles.metaItem, s.f14, s.gray5]}
|
||||||
|
onPress={onPressAuthor}>
|
||||||
|
@{item.author.name}
|
||||||
|
</Text>
|
||||||
|
<Text style={[styles.metaItem, s.f14, s.gray5]}>
|
||||||
|
· {ago(item.indexedAt)}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<Text style={[styles.postText, s.f15, s['lh15-1.3']]}>
|
||||||
|
{record.text}
|
||||||
|
</Text>
|
||||||
|
<Ctrls />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
outer: {
|
outer: {
|
||||||
marginTop: 1,
|
|
||||||
backgroundColor: colors.white,
|
backgroundColor: colors.white,
|
||||||
|
borderRadius: 10,
|
||||||
|
margin: 2,
|
||||||
|
marginBottom: 0,
|
||||||
},
|
},
|
||||||
layout: {
|
layout: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
replyBar: {
|
|
||||||
width: 5,
|
|
||||||
backgroundColor: colors.gray2,
|
|
||||||
marginRight: 2,
|
|
||||||
},
|
|
||||||
layoutAvi: {
|
layoutAvi: {
|
||||||
width: 70,
|
width: 70,
|
||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
|
|
Loading…
Reference in New Issue