Skip to content

Commit

Permalink
developing profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
LastStranger committed Feb 10, 2024
1 parent d7f1ca4 commit 1aaedaf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
20 changes: 13 additions & 7 deletions src/pages/Profile/hooks/useProfileInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@ type ProfileData = {

const useProfileInfo = (id: string) => {
const [data, setData] = useState<ProfileData | null>(null);
const [loading, setLoading] = useState(true);

useEffect(() => {
request.get(`/users/${id}`).then(res => {
const languages = res.data?.tags
?.filter(each => each.startsWith("language_"))
.reduce((acc, tag) => [...acc, getLanguage(tag)], []);
setData({ ...res.data, languages });
});
request
.get(`/users/${id}`)
.then(res => {
const languages = res.data?.tags
?.filter(each => each.startsWith("language_"))
.reduce((acc, tag) => [...acc, getLanguage(tag)], []);
setData({ ...res.data, languages });
})
.finally(() => {
setLoading(false);
});
}, []);

return data;
return [data, loading];
};

export default useProfileInfo;
15 changes: 13 additions & 2 deletions src/pages/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ type Props = {
id: string;
};
const Index = ({ route, navigation }) => {
const data = useProfileInfo(route.params.id);
console.warn("22");
const [data, loading] = useProfileInfo(route.params.id);
// console.warn("22");
if (loading) {
return (
<View className="flex-1 bg-[#0e1013]">
<Image
className="h-full w-full"
contentFit="contain"
source="https://assets.vrchat.com/www/images/loading.gif"
/>
</View>
);
}
return (
<View className="flex-1 bg-[#0e1013]">
{/*<SvgUri*/}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useUserStore from "../../store/useUserStore";
import { ParamListBase, useFocusEffect, useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { Url } from "@/navigation/types";
import { getLanguage, getRank, getRankColor } from "@/utils";
import { getLanguage, getRank, getRankColor, getRankColorByRank } from "@/utils";
import { Ionicons } from "@expo/vector-icons";
import Groups from "@/pages/home/components/Groups";
import { Image } from "expo-image";
Expand Down Expand Up @@ -80,7 +80,10 @@ const Index = () => {
<Text className="w-[210] text-xl text-vrcWhite">{userInfo.statusDescription}</Text>
</View>
<View
style={{ backgroundColor: getRankColor(currentRank) }}
style={{
backgroundColor: getRankColorByRank(currentRank),
transform: [{ scale: 0.8 }],
}}
className="flex-row items-center justify-center rounded-lg px-2 py-1"
>
<Ionicons name="shield" size={12} color="black" />
Expand Down
15 changes: 15 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ export function getRankColorByTags(tags: string[] = []) {
}
}

export function getRankColorByRank(rank: string): string {
switch (rank) {
case "Trusted":
return "text-trusted";
case "Known":
return "#ff7b42";
// case "system_trust_known":
// return "User";
// case "system_trust_basic":
// return "New";
default:
return "#cccccc";
}
}

export function getRankNameByTags(tags: string[]) {
const prefixRank = tags?.findLast(each => each.indexOf("system_trust_") !== -1);
return getRank(prefixRank);
Expand Down

0 comments on commit 1aaedaf

Please sign in to comment.