add photo selection button
This commit is contained in:
@@ -15,6 +15,7 @@ import {atoms as a, useTheme} from '#/alf'
|
|||||||
import {Button, ButtonText, ButtonIcon} from '#/components/Button'
|
import {Button, ButtonText, ButtonIcon} from '#/components/Button'
|
||||||
import {News2_Stroke2_Corner0_Rounded as News} from '#/components/icons/News2'
|
import {News2_Stroke2_Corner0_Rounded as News} from '#/components/icons/News2'
|
||||||
import {StreamingLive_Stroke2_Corner0_Rounded as StreamingLive} from '#/components/icons/StreamingLive'
|
import {StreamingLive_Stroke2_Corner0_Rounded as StreamingLive} from '#/components/icons/StreamingLive'
|
||||||
|
import {Camera_Stroke2_Corner0_Rounded as Camera} from '#/components/icons/Camera'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
@@ -55,7 +56,7 @@ export function StepProfile() {
|
|||||||
const onboardDispatch = useOnboardingDispatch()
|
const onboardDispatch = useOnboardingDispatch()
|
||||||
const [avatar, setAvatar] = React.useState<Avatar>({
|
const [avatar, setAvatar] = React.useState<Avatar>({
|
||||||
placeholder: 'smile',
|
placeholder: 'smile',
|
||||||
backgroundColor: 'red',
|
backgroundColor: '#338388',
|
||||||
})
|
})
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -109,11 +110,12 @@ export function StepProfile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AvatarCircle() {
|
function AvatarCircle() {
|
||||||
|
const t = useTheme()
|
||||||
const avatar = useAvatar()
|
const avatar = useAvatar()
|
||||||
|
|
||||||
if (avatar.imageUri) {
|
if (avatar.imageUri) {
|
||||||
return (
|
return (
|
||||||
<View style={[styles.imageContainer]}>
|
<View style={[styles.imageContainer, t.atoms.border_contrast_high]}>
|
||||||
<Image
|
<Image
|
||||||
source={avatar.imageUri}
|
source={avatar.imageUri}
|
||||||
style={{flex: 1}}
|
style={{flex: 1}}
|
||||||
@@ -134,10 +136,17 @@ function AvatarCircle() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const colors = ['image', 'red', 'blue', 'green', 'orange'] as const
|
const colors = [
|
||||||
|
'#338388',
|
||||||
|
'#4ABFBD',
|
||||||
|
'#8AB17D',
|
||||||
|
'#E9C46A',
|
||||||
|
'#F4A261',
|
||||||
|
'#E76F51',
|
||||||
|
] as const
|
||||||
type Color = (typeof colors)[number]
|
type Color = (typeof colors)[number]
|
||||||
|
|
||||||
const emojis = ['smile', 'frown', 'eyes'] as const
|
const emojis = ['camera', 'smile', 'frown', 'eyes'] as const
|
||||||
type Emoji = (typeof emojis)[number]
|
type Emoji = (typeof emojis)[number]
|
||||||
const emojiItems: Record<Emoji, string> = {
|
const emojiItems: Record<Emoji, string> = {
|
||||||
smile: '😊',
|
smile: '😊',
|
||||||
@@ -146,6 +155,7 @@ const emojiItems: Record<Emoji, string> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ColorItem({color}: {color: Color}) {
|
function ColorItem({color}: {color: Color}) {
|
||||||
|
const t = useTheme()
|
||||||
const avatar = useAvatar()
|
const avatar = useAvatar()
|
||||||
const setAvatar = useSetAvatar()
|
const setAvatar = useSetAvatar()
|
||||||
|
|
||||||
@@ -156,17 +166,16 @@ function ColorItem({color}: {color: Color}) {
|
|||||||
}))
|
}))
|
||||||
}, [color, setAvatar])
|
}, [color, setAvatar])
|
||||||
|
|
||||||
if (color === 'image') return null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
style={[
|
style={[
|
||||||
styles.imageContainer,
|
styles.imageContainer,
|
||||||
styles.paletteContainer,
|
styles.paletteContainer,
|
||||||
|
t.atoms.border_contrast_high,
|
||||||
{
|
{
|
||||||
backgroundColor: color,
|
backgroundColor: color,
|
||||||
borderWidth: avatar.backgroundColor === color ? 3 : 1,
|
borderWidth: avatar.backgroundColor === color ? 4 : 2,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
@@ -178,6 +187,7 @@ function colorRenderItem({item}: ListRenderItemInfo<Color>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function EmojiItem({emoji}: {emoji: Emoji}) {
|
function EmojiItem({emoji}: {emoji: Emoji}) {
|
||||||
|
const t = useTheme()
|
||||||
const avatar = useAvatar()
|
const avatar = useAvatar()
|
||||||
const setAvatar = useSetAvatar()
|
const setAvatar = useSetAvatar()
|
||||||
|
|
||||||
@@ -188,14 +198,35 @@ function EmojiItem({emoji}: {emoji: Emoji}) {
|
|||||||
}))
|
}))
|
||||||
}, [emoji, setAvatar])
|
}, [emoji, setAvatar])
|
||||||
|
|
||||||
|
const onCameraPress = React.useCallback(() => {}, [])
|
||||||
|
|
||||||
|
if (emoji === 'camera') {
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
accessibilityRole="button"
|
||||||
|
style={[
|
||||||
|
styles.imageContainer,
|
||||||
|
styles.paletteContainer,
|
||||||
|
t.atoms.border_contrast_high,
|
||||||
|
{
|
||||||
|
borderWidth: avatar.placeholder === emoji ? 4 : 2,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onPress={onCameraPress}>
|
||||||
|
<Camera size="xl" style={[t.atoms.text_contrast_medium]} />
|
||||||
|
</Pressable>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
style={[
|
style={[
|
||||||
styles.imageContainer,
|
styles.imageContainer,
|
||||||
styles.paletteContainer,
|
styles.paletteContainer,
|
||||||
|
t.atoms.border_contrast_high,
|
||||||
{
|
{
|
||||||
borderWidth: avatar.placeholder === emoji ? 3 : 1,
|
borderWidth: avatar.placeholder === emoji ? 4 : 2,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onPress={onPress}>
|
onPress={onPress}>
|
||||||
|
|||||||
Reference in New Issue
Block a user