From 98b2b4020c8ff559aef7b4953da5a457848fd232 Mon Sep 17 00:00:00 2001 From: Lakshmi Vyshnavi Vutukuri Date: Sun, 9 Feb 2025 13:53:12 -0800 Subject: [PATCH] Created a Player Selector component; Added index; Added tests --- app/index.tsx | 30 +-- components/PlayerSelector.tsx | 64 ++++++ components/__tests__/PlayerSelector.test.tsx | 57 +++++ package-lock.json | 215 +++++++++++++++++++ package.json | 4 + 5 files changed, 358 insertions(+), 12 deletions(-) create mode 100644 components/PlayerSelector.tsx create mode 100644 components/__tests__/PlayerSelector.test.tsx diff --git a/app/index.tsx b/app/index.tsx index 866b635..7c7e016 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,15 +1,21 @@ -import { Text, View } from "react-native"; +import React, { useState } from "react"; +import { ScrollView, Text } from "react-native"; +import PlayerSelector from "@/components/PlayerSelector"; + +const IndexScreen = () => { + const [playerCount, setPlayerCount] = useState(2); -export default function Index() { return ( - - Edit app/index.tsx to edit this screen. - + + + Poker Chip Helper + + + + ); -} +}; +export default IndexScreen; diff --git a/components/PlayerSelector.tsx b/components/PlayerSelector.tsx new file mode 100644 index 0000000..b51ff4c --- /dev/null +++ b/components/PlayerSelector.tsx @@ -0,0 +1,64 @@ +import React from "react"; +import { View, Text, Button, Image, StyleSheet } from "react-native"; + +interface PlayerSelectorProps { + playerCount: number; + setPlayerCount: React.Dispatch>; +} + +const PlayerSelector: React.FC = ({ + playerCount, + setPlayerCount, +}) => { + const increasePlayers = () => { + if (playerCount < 8) setPlayerCount(playerCount + 1); + }; + + const decreasePlayers = () => { + if (playerCount > 2) setPlayerCount(playerCount - 1); + }; + + return ( + + + + Select Number of Players: + + + {playerCount} + +