From 71594d069c5f5fa35eb60238409be20e51997c85 Mon Sep 17 00:00:00 2001
From: Paul Frazee <pfrazee@gmail.com>
Date: Wed, 31 Aug 2022 21:02:12 -0500
Subject: Update post thread aesthetics

---
 src/view/com/post-thread/PostThreadItem.tsx | 209 +++++++++++++++-------------
 1 file changed, 114 insertions(+), 95 deletions(-)

(limited to 'src/view/com/post-thread/PostThreadItem.tsx')

diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx
index ed411131f..376ec6805 100644
--- a/src/view/com/post-thread/PostThreadItem.tsx
+++ b/src/view/com/post-thread/PostThreadItem.tsx
@@ -9,14 +9,6 @@ import {ago, pluralize} from '../../lib/strings'
 import {AVIS} from '../../lib/assets'
 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({
   item,
   onPressShare,
@@ -61,41 +53,83 @@ export const PostThreadItem = observer(function PostThreadItem({
       .catch(e => console.error('Failed to toggle like', record, e))
   }
 
-  return (
-    <TouchableOpacity style={styles.outer} onPress={onPressOuter}>
-      <View style={styles.layout}>
-        {iter(Math.abs(item._depth), (i: number) => (
-          <View key={i} style={styles.replyBar} />
-        ))}
-        <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]}>
-              &middot; {ago(item.indexedAt)}
-            </Text>
+  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 (
+      <View style={styles.outer}>
+        <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, s.mt5]}>
+              <Text
+                style={[styles.metaItem, s.f15, s.bold]}
+                onPress={onPressAuthor}>
+                {item.author.displayName}
+              </Text>
+              <Text style={[styles.metaItem, s.f14, s.gray5]}>
+                &middot; {ago(item.indexedAt)}
+              </Text>
+            </View>
+            <View style={styles.meta}>
+              <Text
+                style={[styles.metaItem, s.f14, s.gray5]}
+                onPress={onPressAuthor}>
+                @{item.author.name}
+              </Text>
+            </View>
           </View>
-          <Text
-            style={[
-              styles.postText,
-              ...(item._isHighlightedPost
-                ? [s.f16, s['lh16-1.3']]
-                : [s.f15, s['lh15-1.3']]),
-            ]}>
+        </View>
+        <View style={[s.pl10, s.pr10, s.pb10]}>
+          <Text style={[styles.postText, s.f18, s['lh18-1.3']]}>
             {record.text}
           </Text>
           {item._isHighlightedPost && hasEngagement ? (
@@ -124,74 +158,59 @@ export const PostThreadItem = observer(function PostThreadItem({
           ) : (
             <></>
           )}
-          <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}
-              />
+          <View style={[s.pl10]}>
+            <Ctrls />
+          </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={
-                  item.myState.hasReposted ? [s.bold, s.green3, s.f13] : s.f13
-                }>
-                {item.repostCount}
+                style={[styles.metaItem, s.f15, s.bold]}
+                onPress={onPressAuthor}>
+                {item.author.displayName}
               </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}
+                style={[styles.metaItem, s.f14, s.gray5]}
+                onPress={onPressAuthor}>
+                @{item.author.name}
+              </Text>
+              <Text style={[styles.metaItem, s.f14, s.gray5]}>
+                &middot; {ago(item.indexedAt)}
               </Text>
-            </TouchableOpacity>
-            <TouchableOpacity
-              style={styles.ctrl}
-              onPress={() => onPressShare(item.uri)}>
-              <FontAwesomeIcon
-                style={styles.ctrlIcon}
-                icon="share-from-square"
-                size={14}
-              />
-            </TouchableOpacity>
+            </View>
+            <Text style={[styles.postText, s.f15, s['lh15-1.3']]}>
+              {record.text}
+            </Text>
+            <Ctrls />
           </View>
         </View>
-      </View>
-    </TouchableOpacity>
-  )
+      </TouchableOpacity>
+    )
+  }
 })
 
 const styles = StyleSheet.create({
   outer: {
-    marginTop: 1,
     backgroundColor: colors.white,
+    borderRadius: 10,
+    margin: 2,
+    marginBottom: 0,
   },
   layout: {
     flexDirection: 'row',
   },
-  replyBar: {
-    width: 5,
-    backgroundColor: colors.gray2,
-    marginRight: 2,
-  },
   layoutAvi: {
     width: 70,
     paddingLeft: 10,
-- 
cgit 1.4.1

