Skip to content

Commit

Permalink
clean nfc screen and carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
remicolin committed Aug 27, 2024
1 parent 89fbcb9 commit 32209f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
10 changes: 2 additions & 8 deletions app/src/components/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react'
import { AnimatePresence } from '@tamagui/animate-presence'
import { ArrowLeft, ArrowRight, Nfc, ShieldCheck } from '@tamagui/lucide-icons'
import { ArrowLeft, Nfc } from '@tamagui/lucide-icons'
import { Button, Image, XStack, YStack, styled, Text } from 'tamagui'
import { bgBlue, bgGreen, borderColor, textBlack, textColor1, textColor2 } from '../utils/colors'
import CustomButton from './CustomButton'
Expand Down Expand Up @@ -36,18 +36,16 @@ const wrap = (min: number, max: number, v: number) => {
interface CarouselProps {
images: string[];
height?: number;
onSlideChange?: (index: number) => void;
handleNfcScan?: () => void;
}

export function Carousel({ images, height = 300, onSlideChange, handleNfcScan }: CarouselProps) {
export function Carousel({ images, height = 300, handleNfcScan }: CarouselProps) {
const [[page, going], setPage] = useState([0, 0])

const imageIndex = wrap(0, images.length, page)
const paginate = (going: number) => {
const newPage = page + going
setPage([newPage, going])
onSlideChange?.(newPage)
}

const isLastImage = imageIndex === images.length - 1
Expand Down Expand Up @@ -99,10 +97,6 @@ export function Carousel({ images, height = 300, onSlideChange, handleNfcScan }:
<Text color={textBlack} fontSize="$5" mt="$2" textAlign='center' style={{ opacity: 0.7 }} fontStyle='italic'>{currentSlide.subtitle}</Text>
</YStack>

{/* <XStack justifyContent='center' alignItems='center' gap="$1.5" position="absolute" style={{ bottom: 120, left: 0, right: 0 }}>
<ShieldCheck color={textBlack} size={14} />
<Text color={textBlack} fontSize="$4" >private and secured</Text>
</XStack> */}
<XStack f={1} />

<CustomButton
Expand Down
13 changes: 1 addition & 12 deletions app/src/screens/NfcScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import { YStack, Text, XStack, Button, ScrollView } from 'tamagui';
import { Nfc, X } from '@tamagui/lucide-icons';
import { bgGreen, borderColor, textBlack, textColor1 } from '../utils/colors';
import { Carousel } from '../components/Carousel';
import US_PASSPORT from '../images/us-passport.png'
Expand All @@ -12,25 +11,17 @@ import PHONE_SCANBUTTON from "../images/phone_scanbutton.png"

import Dialog from "react-native-dialog";
import NfcManager from 'react-native-nfc-manager';
import { Platform, Linking, Dimensions } from 'react-native';
import { Platform, Linking } from 'react-native';

interface NfcScreenProps {
handleNFCScan: () => void;
}

const NfcScreen: React.FC<NfcScreenProps> = ({ handleNFCScan }) => {
const [isLastSlideReached, setIsLastSlideReached] = useState(false);
const [dialogVisible, setDialogVisible] = useState(false);
const [dialogMessage, setDialogMessage] = useState('');
const [isNfcSupported, setIsNfcSupported] = useState(true);
const carouselImages = [US_PASSPORT, REMOVE_CASE, US_PASSPORT_LASTPAGE, Platform.OS === 'ios' ? US_PASSPORT_LASTPAGE_IOS : US_PASSPORT_LASTPAGE_ANDROID, PHONE_SCANBUTTON,];
const windowHeight = Dimensions.get('window').height;

const handleSlideChange = (index: number) => {
if (index === carouselImages.length - 1) {
setIsLastSlideReached(true);
}
};

const openNfcSettings = () => {
if (Platform.OS === 'ios') {
Expand Down Expand Up @@ -70,12 +61,10 @@ const NfcScreen: React.FC<NfcScreenProps> = ({ handleNFCScan }) => {
return (
<ScrollView flex={1} contentContainerStyle={{ flexGrow: 1 }}>
<YStack f={1} p="$3" >
{/* <Text fontSize="$8" fow="bold" mt="$1.5" mb="$3" color={textColor1} textAlign='center'>Verify your passport using NFC</Text> */}
<Text fontSize="$9" mt="$0" color={textBlack} mb="$4" ml="$2">Verify your passport using <Text fontSize="$9" color={textBlack} style={{ textDecorationLine: 'underline', textDecorationColor: bgGreen }}>NFC</Text></Text>
<Carousel
images={carouselImages}
height={300}
onSlideChange={handleSlideChange}
handleNfcScan={handleNfcScan}
/>
<Dialog.Container visible={dialogVisible}>
Expand Down

0 comments on commit 32209f3

Please sign in to comment.