Skip to content

Commit 29610f8

Browse files
committedOct 21, 2024
fix input mask v2
1 parent d72290d commit 29610f8

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed
 

‎app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"backgroundColor": "#fa4454"
2222
},
2323
"package": "dev.vasc.vshop2",
24-
"versionCode": 66
24+
"versionCode": 67
2525
},
2626
"web": {
2727
"bundler": "metro",

‎components/popups/DonatePopup.tsx

+8-11
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export default function DonatePopup() {
4040
const { t } = useTranslation();
4141
const { visible, hideDonatePopup } = useDonatePopupStore();
4242
const [currency, setCurrency] = useState<ICurrency>();
43-
const [amount, setAmount] = useState("");
43+
const [amount, setAmount] = useState({ rawText: "", text: "" });
4444
const validAmount = currency
45-
? Number.parseFloat(amount) >= currency.minimum
45+
? Number.parseFloat(amount.text) >= currency.minimum
4646
: false;
4747
const { user } = useUserStore();
4848
const { initPaymentSheet, presentPaymentSheet } = useStripe();
@@ -51,7 +51,7 @@ export default function DonatePopup() {
5151

5252
const initializePaymentSheet = async () => {
5353
const res = await generatePaymentSheet({
54-
amount: Number.parseFloat(amount),
54+
amount: Number.parseFloat(amount.text),
5555
riotId: user.id,
5656
currencyCode: currency?.code.toLowerCase() ?? "",
5757
});
@@ -139,8 +139,6 @@ export default function DonatePopup() {
139139
</View>
140140
<Paragraph>{t("donate_msg")}</Paragraph>
141141
<TextInput
142-
value={amount}
143-
onChangeText={(value) => setAmount(value)}
144142
left={
145143
<TextInput.Affix
146144
text={currency?.symbol}
@@ -153,11 +151,10 @@ export default function DonatePopup() {
153151
render={(props) => (
154152
<MaskedTextInput
155153
{...props}
156-
onChangeText={(text, rawText) => {
157-
if (props.onChangeText) {
158-
props.onChangeText(rawText);
159-
}
160-
}}
154+
value={amount.rawText}
155+
onChangeText={(text, rawText) =>
156+
setAmount({ text, rawText })
157+
}
161158
type="currency"
162159
options={{
163160
decimalSeparator: !currency?.zeroDecimal && ".",
@@ -190,7 +187,7 @@ export default function DonatePopup() {
190187
<Button onPress={hideDonatePopup}>{t("no")}</Button>
191188
<Button
192189
onPress={openPaymentSheet}
193-
disabled={!currency || !validAmount || amount.length === 0}
190+
disabled={!currency || !validAmount || amount.text.length === 0}
194191
>
195192
{t("donate")}
196193
</Button>

0 commit comments

Comments
 (0)
Failed to load comments.