All files / components OnboardingSlide.tsx

100% Statements 1/1
100% Branches 6/6
100% Functions 1/1
100% Lines 1/1

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                                        3x                                                                  
import React from 'react';
import { Image, ImageSourcePropType, View } from 'react-native';
import { YStack, Text } from 'tamagui';
 
interface Props {
  title: string;
  description?: string;
  image?: ImageSourcePropType;
  maxImageWidth?: number;
  maxImageHeight?: number;
  index?: number;
}
 
export function OnboardingSlide({
  title,
  description,
  image,
  maxImageWidth = 300,
  maxImageHeight = 300,
}: Props) {
  return (
    <YStack
      flex={1}
      justifyContent="flex-start"
      alignItems="center"
      paddingHorizontal="$6"
      paddingTop="$4"
    >
      <View style={{ alignItems: 'center', justifyContent: 'center', marginBottom: 12 }}>
        {image ? (
          <Image
            source={image}
            style={{ width: maxImageWidth, height: maxImageHeight, resizeMode: 'contain' }}
            accessible
            accessibilityLabel={title}
          />
        ) : null}
      </View>
 
      <Text fontSize="$8" fontWeight="700" marginTop="$3" marginBottom="$2" textAlign="center">
        {title}
      </Text>
 
      {description ? (
        <Text fontSize="$4" color="$gray10" textAlign="center" style={{ flexShrink: 1 }}>
          {description}
        </Text>
      ) : null}
    </YStack>
  );
}
 
export default OnboardingSlide;