diff --git a/README.md b/README.md index 8f514f9..6319621 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ To create an APK build, use the following npx expo prebuild cd android ./gradlew assembleRelease # linux -./gradlew.bat assembleRelease # windows command +gradlew.bat assembleRelease # possible windows command ``` Then, see `android/app/build/outputs/apk/release/app-release.apk` for the output diff --git a/app.json b/app.json index a4b9e4e..501d4f3 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,7 @@ "slug": "poker-chips-helper", "version": "1.0.0", "orientation": "portrait", - "icon": "./assets/images/icon.png", + "icon": "./assets/images/icon1.png", "scheme": "myapp", "userInterfaceStyle": "automatic", "newArchEnabled": true, @@ -13,7 +13,7 @@ }, "android": { "adaptiveIcon": { - "foregroundImage": "./assets/images/icon.png", + "foregroundImage": "./assets/images/adaptive-icon.png", "backgroundColor": "#ffffff" }, "package": "com.anonymous.pokerchipshelper" diff --git a/app/index.tsx b/app/index.tsx index 163129f..2c2d790 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,12 +1,25 @@ import React, { useState, useEffect } from "react"; -import { ScrollView, Text, Alert, Button } from "react-native"; +import { + ScrollView, + Text, + Alert, + Button, + View, + StyleSheet, + TouchableOpacity, +} from "react-native"; +import { FontAwesome } from "@expo/vector-icons"; import PlayerSelector from "@/components/PlayerSelector"; import BuyInSelector from "@/components/BuyInSelector"; import ChipsSelector from "@/components/ChipsSelector"; import ChipDistributionSummary from "@/components/ChipDistributionSummary"; import ChipDetection from "@/components/ChipDetection"; +import CurrencySelector from "@/components/CurrencySelector"; import { saveState, loadState } from "@/components/CalculatorState"; -import { savePersistentState, loadPersistentState } from "@/components/PersistentState"; +import { + savePersistentState, + loadPersistentState, +} from "@/components/PersistentState"; export enum COLORS { "white", @@ -21,8 +34,9 @@ const IndexScreen: React.FC = () => { const [buyInAmount, setBuyInAmount] = useState(20); const [numberOfChips, setNumberOfChips] = useState(5); const [totalChipsCount, setTotalChipsCount] = useState([]); + const [selectedCurrency, setSelectedCurrency] = useState("$"); + const [isSettingsVisible, setIsSettingsVisible] = useState(false); - // Load persistent data on startup useEffect(() => { const loadPersistentData = async () => { try { @@ -30,12 +44,13 @@ const IndexScreen: React.FC = () => { const savedState = await loadPersistentState(); if (savedState) { console.log("Persistent state restored:", savedState); - setPlayerCount(savedState.playerCount); - setBuyInAmount(savedState.buyInAmount); - setNumberOfChips(savedState.numberOfChips); - setTotalChipsCount(savedState.totalChipsCount); + setPlayerCount(savedState.playerCount || 2); + setBuyInAmount(savedState.buyInAmount || 20); + setNumberOfChips(savedState.numberOfChips || 5); + setTotalChipsCount(savedState.totalChipsCount || []); + setSelectedCurrency(savedState.selectedCurrency || "$"); } else { - console.log("No persistent state found."); + console.log("No persistent state found, using defaults."); } } catch (error) { console.error("Error loading persistent state:", error); @@ -44,14 +59,18 @@ const IndexScreen: React.FC = () => { loadPersistentData(); }, []); - // Save game state to selected slot const handleSave = async (slot: "SLOT1" | "SLOT2") => { if (buyInAmount === null) { Alert.alert("Error", "Please select a valid buy-in amount"); return; } - const state = { playerCount, buyInAmount, numberOfChips, totalChipsCount }; - + const state = { + playerCount, + buyInAmount, + numberOfChips, + totalChipsCount, + selectedCurrency, + }; try { await saveState(slot, state); await savePersistentState(state); @@ -63,7 +82,6 @@ const IndexScreen: React.FC = () => { } }; - // Load game state from selected slot const handleLoad = async (slot: "SLOT1" | "SLOT2") => { try { const loadedState = await loadState(slot); @@ -72,6 +90,7 @@ const IndexScreen: React.FC = () => { setBuyInAmount(loadedState.buyInAmount); setNumberOfChips(loadedState.numberOfChips); setTotalChipsCount(loadedState.totalChipsCount); + setSelectedCurrency(loadedState.selectedCurrency || "$"); await savePersistentState(loadedState); console.log(`Game state loaded from ${slot}:`, loadedState); Alert.alert("Success", `State loaded from ${slot}`); @@ -86,29 +105,95 @@ const IndexScreen: React.FC = () => { return ( - - - { - const chipCountArray = Object.values(chipData); - setTotalChipsCount(chipCountArray); - }} /> + + setIsSettingsVisible(!isSettingsVisible)} + > + + + + + + + {isSettingsVisible && ( + + + + )} + + + + + + { + const chipCountArray = Object.values(chipData); + setTotalChipsCount(chipCountArray); + }} + /> + + -