react-native-elements#Avatar TypeScript Examples

The following examples show how to use react-native-elements#Avatar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OnboardFace.tsx    From SQUID with MIT License 5 votes vote down vote up
OnboardFace = () => {
  const [uri, setUri] = useState(userPrivateData.getFace())

  useEffect(() => {
    if (uri) {
      RNFS.exists(uri).then(exists => {
        if (!exists) {
          setUri(null)
        }
      })
    }
  }, [])

  const navigation = useNavigation()

  const navigateToCamera = () => {
    navigation.navigate('OnboardFaceCamera', { setUri })
  }

  const onSubmit = async () => {
    if (uri) {
      await userPrivateData.setFace(uri, { isTempUri: true })
      navigation.navigate('OnboardLocation')
    }
  }

  return (
    <SafeAreaView style={styles.container}>
      <StatusBar backgroundColor={COLORS.WHITE} barStyle="dark-content" />
      <FormHeader>
        <View style={styles.header}>
          <Text style={styles.title}>{I18n.t('profile_picture')}</Text>
          <Text style={styles.subtitle}>{I18n.t('straight_and_clear_face_portrait')}</Text>
        </View>
      </FormHeader>
      <View style={styles.content}>
        <TouchableOpacity onPress={navigateToCamera}>
          <Avatar
            size={250}
            rounded
            overlayContainerStyle={{ backgroundColor: '#E6F2FA' }}
            source={uri ? { uri } : require('./camera-mask.png')}
          />
        </TouchableOpacity>
        <TouchableOpacity
          style={{
            borderStyle: 'dashed',
            borderWidth: 1,
            flexDirection: 'row',
            alignItems: 'center',
            paddingVertical: 8,
            borderColor: COLORS.BLUE,
            paddingHorizontal: 16,
            marginTop: 12,
            borderRadius: 8,
          }}
          onPress={navigateToCamera}
        >
          <FeatherIcon name="camera" color={COLORS.BLUE} size={20} />
          <ColorText color={COLORS.BLUE} style={{ marginLeft: 12, fontSize: FONT_SIZES[700] }}>
            {uri ? I18n.t('retake_photo') : I18n.t('take_photo')}
          </ColorText>
        </TouchableOpacity>
      </View>
      <View style={styles.footer}>
        <PrimaryButton
          style={{ width: '100%' }}
          containerStyle={{ width: '100%'}}
          title={I18n.t('next')}
          onPress={onSubmit}
          disabled={!uri}
        />
      </View>
    </SafeAreaView>
  )
}