浏览代码

fix: correct ranking display

Oleksandr Honcharov 1 年之前
父节点
当前提交
ee0ca7fdd4
共有 1 个文件被更改,包括 8 次插入22 次删除
  1. 8 22
      src/screens/InAppScreens/TravellersScreen/Components/Profile.tsx

+ 8 - 22
src/screens/InAppScreens/TravellersScreen/Components/Profile.tsx

@@ -99,7 +99,7 @@ export const Profile: FC<Props> = ({
     ) : null;
   };
 
-  const EmptyScore = () => {
+  const EmptyScore: FC<{ scoreName: string }> = ({ scoreName }) => {
     return (
       <View
         style={{
@@ -110,8 +110,8 @@ export const Profile: FC<Props> = ({
           marginBottom: 10
         }}
       >
-        <Text style={[styles.scoreHeaderText, { flex: 0 }]}></Text>
-        <Text style={[styles.scoreNameText, { flex: 0 }]}></Text>
+        <Text style={[styles.scoreHeaderText, { flex: 0 }]}>-</Text>
+        <Text style={[styles.scoreNameText, { flex: 0 }]}>{scoreName}</Text>
       </View>
     );
   };
@@ -189,26 +189,12 @@ export const Profile: FC<Props> = ({
         </View>
 
         <View style={styles.rankingScoresWrapper}>
-          {score.slice(1).map((number, index) => {
-            if (!number) return <EmptyScore />;
+          {score.map((number, index) => {
+            if (scoreNames[index] === 'SLOW' && number >= 4500)
+              return <EmptyScore scoreName={scoreNames[index]} />;
             if (scoreNames[index] === 'YES' && number >= 10000)
-              return (
-                <View
-                  style={{
-                    display: 'flex',
-                    alignItems: 'center',
-                    justifyContent: 'center',
-                    flexDirection: 'column',
-                    marginBottom: 10,
-                    width: 40,
-                    borderWidth: 1
-                  }}
-                >
-                  <Text style={[styles.scoreHeaderText, { flex: 0 }]}>-</Text>
-                  <Text style={[styles.scoreNameText, { flex: 0 }]}>YES</Text>
-                </View>
-              );
-            if (scoreNames[index] === 'SLOW' && number >= 4500) return <EmptyScore />;
+              return <EmptyScore scoreName={scoreNames[index]} />;
+            if (!number) return <EmptyScore scoreName={scoreNames[index]} />;
             if (index === active_score) return;
             return (
               <View