--------- Co-authored-by: Rem Helper <remhelper@abunchofknowitalls.com> Reviewed-on: https://git.abunchofknowitalls.com/joshuafhiggins/otunes/pulls/14
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
import { useQuery } from "convex/react"
|
|
import { Image } from "expo-image"
|
|
import { useRouter } from "expo-router"
|
|
import { Pressable, StyleSheet, Text, View } from "react-native"
|
|
|
|
import { initialsFromName } from "@/lib/format"
|
|
import { radius, useThemeColors } from "@/lib/theme"
|
|
import { api } from "@otunes/convex/_generated/api"
|
|
|
|
export function ProfileHeaderButton() {
|
|
const router = useRouter()
|
|
const colors = useThemeColors()
|
|
const user = useQuery(api.auth.currentUser)
|
|
|
|
return (
|
|
<Pressable
|
|
accessibilityLabel="Open profile"
|
|
accessibilityRole="button"
|
|
hitSlop={8}
|
|
onPress={() => router.push("/(app)/settings")}
|
|
style={({ pressed }) => [styles.button, { opacity: pressed ? 0.75 : 1 }]}
|
|
>
|
|
<View
|
|
style={[
|
|
styles.avatar,
|
|
{
|
|
backgroundColor: colors.muted,
|
|
borderColor: colors.border,
|
|
},
|
|
]}
|
|
>
|
|
{user?.image ? (
|
|
<Image source={{ uri: user.image }} style={styles.image} contentFit="cover" />
|
|
) : (
|
|
<Text style={[styles.initials, { color: colors.foreground }]}>
|
|
{initialsFromName(user?.name ?? "Me")}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
</Pressable>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
button: {
|
|
marginRight: 4,
|
|
},
|
|
avatar: {
|
|
width: 42,
|
|
height: 42,
|
|
borderRadius: radius.full,
|
|
borderWidth: 1,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
overflow: "hidden",
|
|
},
|
|
image: {
|
|
width: "100%",
|
|
height: "100%",
|
|
},
|
|
initials: {
|
|
fontSize: 14,
|
|
fontWeight: "700",
|
|
},
|
|
})
|