Skip to content

Commit

Permalink
fix: remove save button
Browse files Browse the repository at this point in the history
  • Loading branch information
reneaaron committed Sep 12, 2024
1 parent 215f2ad commit 3b87cdc
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions pages/settings/FiatCurrency.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { router } from "expo-router";
import React from "react";
import { View, FlatList, TouchableOpacity } from "react-native";
import Toast from "react-native-toast-message";
import { Button } from "~/components/ui/button";
import { Text } from "~/components/ui/text";
import { useAppStore } from "~/lib/state/appStore";
import Screen from "~/components/Screen";
import { cn } from "~/lib/utils";
import CurrencyList from 'currency-list';
import { router } from "expo-router";
import Toast from "react-native-toast-message";

const currencies: [string, string][] = Object.entries(CurrencyList.getAll("en_US")).map(([code, details]) => [code, details.name]);

Expand All @@ -16,10 +15,20 @@ export function FiatCurrency() {
useAppStore.getState().fiatCurrency,
);

function select(iso: string) {
setFiatCurrency(iso);
useAppStore.getState().setFiatCurrency(fiatCurrency);
Toast.show({
type: "success",
text1: "Fiat currency updated",
});
router.back();
}

const renderCurrencyItem = ({ item }: { item: [string, string] }) => (
<TouchableOpacity
className={cn("p-4 flex flex-row gap-2 border-b border-input", item[0] === fiatCurrency && "bg-muted")}
onPress={() => setFiatCurrency(item[0])}
onPress={() => select(item[0])}
>
<Text className={cn("text-lg", item[0] === fiatCurrency && "font-bold2")}>
{item[1]}
Expand All @@ -39,19 +48,6 @@ export function FiatCurrency() {
keyExtractor={(item) => item[0]}
className="flex-1 mb-4"
/>
<Button
size="lg"
onPress={() => {
useAppStore.getState().setFiatCurrency(fiatCurrency);
Toast.show({
type: "success",
text1: "Fiat currency updated",
});
router.back();
}}
>
<Text>Save</Text>
</Button>
</View>
);
}

0 comments on commit 3b87cdc

Please sign in to comment.