All files / src/screens/settingsSection/settingsScreen/Views MainInfos.tsx

66.66% Statements 2/3
100% Branches 0/0
50% Functions 1/2
66.66% Lines 2/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96                                                        2x                                   1x                                                                                                  
/**
 * @fileoverview MainInfo view of the SettingsScreen component
 * @module TopBar
 * @description It displays essential information about the account such as the name of the user, his profile picture and his username.
 * @requires react react-native
 */
 
import React from 'react'
import { View, Text, StyleSheet, Alert, Pressable } from 'react-native'
import FastImage from 'react-native-fast-image'
import colors from '@global/colors'
import DeviceInfo from 'react-native-device-info'
 
type Props = {
  accountImage: string
  email: string
  username: string
}
 
/**
 * @function MainInfos
 * @param accountImage The image of the account
 * @param firstName The first name of the account
 * @param lastName The last name of the account
 * @param username The username of the account
 * @returns
 */
export default function MainInfos({ accountImage, email, username }: Props) {
  return (
    <Pressable
      style={styles.container}
      delayLongPress={3000}
      onLongPress={() => Alert.alert('Version number', `${DeviceInfo.getVersion()}.${DeviceInfo.getBuildNumber()}`)}
    >
      <FastImage
        style={styles.accountImage}
        source={{ uri: accountImage }}
      />
      <View style={styles.textContainer}>
        <Text style={styles.name}>{email}</Text>
        <Text style={styles.username}>{`@${username}`}</Text>
      </View>
    </Pressable>
  )
}
 
const styles = StyleSheet.create({
  textContainer: {
    flexDirection: 'column',
    flex: 8,
    paddingLeft: 16,
  },
  name: {
    fontSize: 14,
    fontFamily: 'Poppins',
    fontWeight: '700',
  },
  username: {
    fontSize: 12,
    fontFamily: 'Poppins',
    fontWeight: '400',
  },
  container: {
    width: '100%',
    backgroundColor: colors.accent,
    borderRadius: 10,
    height: 120,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    paddingHorizontal: 16,
    shadowColor: colors.black,
    shadowOffset: {
      width: 0,
      height: 4,
    },
    shadowOpacity: 0.25,
    marginBottom: 16,
  },
  accountImage: {
    height: '66%',
    aspectRatio: 1,
    borderRadius: 100,
    backgroundColor: colors.white,
    flex: 3,
  },
  button: {
    height: '25%',
    flex: 1,
  },
  icon: {
    height: '100%',
    aspectRatio: 1,
  },
})