feat: referral (#3761)

Co-authored-by: DIYgod <i@diygod.me>
Co-authored-by: Innei <tukon479@gmail.com>
This commit is contained in:
Stephen Zhou
2025-07-10 09:47:11 +08:00
committed by GitHub
co-authored by DIYgod Innei
parent 79c9b05246
commit 30bb37c7b9
62 changed files with 27487 additions and 20935 deletions
@@ -1,10 +1,13 @@
import { UserRole } from "@follow/constants"
import { cn } from "@follow/utils/utils"
import type { Image as ExpoImage } from "expo-image"
import { useCallback } from "react"
import { Text, TouchableOpacity, View } from "react-native"
import { measure, runOnJS, runOnUI, useAnimatedRef } from "react-native-reanimated"
import { PowerIcon } from "@/src/icons/power"
import { User4CuteFiIcon } from "@/src/icons/user_4_cute_fi"
import { accentColor } from "@/src/theme/colors"
import { useLightboxControls } from "../../lightbox/lightboxState"
import { Image } from "../image/Image"
@@ -15,8 +18,8 @@ interface UserAvatarProps {
name?: string | null
className?: string
color?: string
preview?: boolean
role?: UserRole | null
}
export const UserAvatar = ({
@@ -26,6 +29,7 @@ export const UserAvatar = ({
className,
color,
preview = true,
role,
}: UserAvatarProps) => {
const { openLightbox } = useLightboxControls()
const aviRef = useAnimatedRef<ExpoImage>()
@@ -58,6 +62,16 @@ export const UserAvatar = ({
})()
}, [aviRef, image, openLightbox])
const avatarBadge =
role && role !== UserRole.Free && role !== UserRole.Trial ? (
<View
className="absolute bottom-0 right-0 rounded-full"
style={{ width: size / 3, height: size / 3 }}
>
<PowerIcon color={accentColor} width={size / 3} height={size / 3} />
</View>
) : null
if (!image) {
return (
<View
@@ -79,21 +93,25 @@ export const UserAvatar = ({
) : (
<User4CuteFiIcon width={size} height={size} color={color} />
)}
{avatarBadge}
</View>
)
}
const imageContent = (
<Image
ref={aviRef}
source={{ uri: image }}
className={cn("rounded-full", className)}
style={{ width: size, height: size }}
proxy={{
width: size,
height: size,
}}
/>
<View className="relative">
<Image
ref={aviRef}
source={{ uri: image }}
className={cn("rounded-full", className)}
style={{ width: size, height: size }}
proxy={{
width: size,
height: size,
}}
/>
{avatarBadge}
</View>
)
return preview ? (