diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-07-21 16:43:47 -0500 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-07-21 16:43:47 -0500 |
commit | 29ed3d2ecf1fd6de8af0f25f6d541fe2adaf61f9 (patch) | |
tree | afc0d632c981c097013a2fbb1c15decc1e78bec0 /src/view/com/post-thread/PostThreadItem.tsx | |
parent | 28dbc5f5e614b3caf08d36a7edaaf19a0ee0f0bc (diff) | |
download | voidsky-29ed3d2ecf1fd6de8af0f25f6d541fe2adaf61f9.tar.zst |
Add header to PostThread view; update navigation to include stacking so that each tab maintains its own browsing history
Diffstat (limited to 'src/view/com/post-thread/PostThreadItem.tsx')
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 2b72b7e4b..5e01ac0a6 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -1,13 +1,6 @@ import React from 'react' import {observer} from 'mobx-react-lite' -import { - Image, - ImageSourcePropType, - StyleSheet, - Text, - TouchableOpacity, - View, -} from 'react-native' +import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native' import {bsky, AdxUri} from '@adxp/mock-api' import moment from 'moment' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' @@ -15,14 +8,9 @@ import {OnNavigateContent} from '../../routes/types' import {PostThreadViewPostModel} from '../../../state/models/post-thread-view' import {s} from '../../lib/styles' import {pluralize} from '../../lib/strings' +import {AVIS} from '../../lib/assets' -const IMAGES: Record<string, ImageSourcePropType> = { - 'alice.com': require('../../assets/alice.jpg'), - 'bob.com': require('../../assets/bob.jpg'), - 'carla.com': require('../../assets/carla.jpg'), -} - -function iter<T>(n: number, fn: (i: number) => T): Array<T> { +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)) @@ -49,13 +37,13 @@ export const PostThreadItem = observer(function PostThreadItem({ return ( <TouchableOpacity style={styles.outer} onPress={onPressOuter}> <View style={styles.layout}> - {iter(Math.abs(item._depth), () => ( - <View style={styles.replyBar} /> + {iter(Math.abs(item._depth), (i: number) => ( + <View key={i} style={styles.replyBar} /> ))} <View style={styles.layoutAvi}> <Image style={styles.avi} - source={IMAGES[item.author.name] || IMAGES['alice.com']} + source={AVIS[item.author.name] || AVIS['alice.com']} /> </View> <View style={styles.layoutContent}> @@ -104,14 +92,14 @@ export const PostThreadItem = observer(function PostThreadItem({ <View style={styles.ctrls}> <View style={styles.ctrl}> <FontAwesomeIcon - style={[styles.ctrlIcon, s.gray]} + style={styles.ctrlIcon} icon={['far', 'comment']} /> <Text>{item.replyCount}</Text> </View> <View style={styles.ctrl}> <FontAwesomeIcon - style={[styles.ctrlIcon, s.gray]} + style={styles.ctrlIcon} icon="retweet" size={22} /> @@ -119,14 +107,14 @@ export const PostThreadItem = observer(function PostThreadItem({ </View> <View style={styles.ctrl}> <FontAwesomeIcon - style={[styles.ctrlIcon, s.gray]} + style={styles.ctrlIcon} icon={['far', 'heart']} /> <Text>{item.likeCount}</Text> </View> <View style={styles.ctrl}> <FontAwesomeIcon - style={[styles.ctrlIcon, s.gray]} + style={styles.ctrlIcon} icon="share-from-square" /> </View> @@ -204,5 +192,6 @@ const styles = StyleSheet.create({ }, ctrlIcon: { marginRight: 5, + color: 'gray', }, }) |