Skip to content

Commit

Permalink
fix: donation button added
Browse files Browse the repository at this point in the history
  • Loading branch information
juanky201271 committed Mar 19, 2024
1 parent ad3b84e commit 467be2e
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 41 deletions.
1 change: 1 addition & 0 deletions app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"menudrawer-acc": "Open Menu Drawer",
"menu-acc": "Open Menu",
"donation": "Thanks for supporting Zingo!",
"donation-button": "Donate To Zingo ",
"restarting": "Error connecting to the Server, the App will restart in a few seconds.",
"change-privacy": "New privacy policy: ",
"addressbook": {
Expand Down
10 changes: 5 additions & 5 deletions app/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ export default class Utils {
}

static getDonationAddress(chain_name: 'main' | 'test' | 'regtest'): string {
if (chain_name !== 'main') {
return 'ztestsapling...';
if (chain_name === 'main') {
return 'u000001...';
} else {
return 'z...';
return 'utest000001...';
}
}

static getDefaultDonationAmount(): number {
return 0.1;
static getDefaultDonationAmount(): string {
return '0.01';
}

static getDefaultDonationMemo(translate: (key: string) => TranslateType): string {
Expand Down
115 changes: 79 additions & 36 deletions components/Send/Send.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* eslint-disable react-native/no-inline-styles */
import React, { useState, useEffect, useRef, useContext } from 'react';
import { View, ScrollView, Modal, Keyboard, TextInput, TouchableOpacity, Platform, Alert } from 'react-native';
import { View, ScrollView, Modal, Keyboard, TextInput, TouchableOpacity, Platform, Alert, Text } from 'react-native';
import {
faQrcode,
faCheck,
faInfoCircle,
faAddressCard,
faMagnifyingGlassPlus,
faMoneyCheckDollar,
} from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { useTheme, useIsFocused } from '@react-navigation/native';
Expand Down Expand Up @@ -1046,49 +1047,91 @@ const Send: React.FunctionComponent<SendProps> = ({
<View
style={{
flexGrow: 1,
flexDirection: 'row',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
marginVertical: 5,
}}>
<Button
testID="send.button"
accessible={true}
accessibilityLabel={'title ' + translate('send.button')}
type="Primary"
title={
validAmount === 1 &&
sendPageState.toaddr.amount &&
Number(sendPageState.toaddr.amount) === Utils.parseLocaleFloat(maxAmount.toFixed(8))
? (translate('send.button-all') as string)
: (translate('send.button') as string)
}
disabled={!sendButtonEnabled}
onPress={() => {
if (
<View
style={{
flexGrow: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 20,
}}>
<Button
testID="send.button"
accessible={true}
accessibilityLabel={'title ' + translate('send.button')}
type="Primary"
title={
validAmount === 1 &&
sendPageState.toaddr.amount &&
mode !== 'basic' &&
Number(sendPageState.toaddr.amount) === Utils.parseLocaleFloat(maxAmount.toFixed(8))
) {
addLastSnackbar({ message: `${translate('send.sendall-message') as string}`, type: 'Primary' });
}
if (!netInfo.isConnected) {
addLastSnackbar({ message: translate('loadedapp.connection-error') as string, type: 'Primary' });
return;
? (translate('send.button-all') as string)
: (translate('send.button') as string)
}
// waiting while closing the keyboard, just in case.
setTimeout(async () => {
setConfirmModalVisible(true);
}, 100);
}}
/>
<Button
type="Secondary"
style={{ marginLeft: 10 }}
title={translate('send.clear') as string}
onPress={() => clearToAddr()}
/>
disabled={!sendButtonEnabled}
onPress={() => {
if (
validAmount === 1 &&
sendPageState.toaddr.amount &&
mode !== 'basic' &&
Number(sendPageState.toaddr.amount) === Utils.parseLocaleFloat(maxAmount.toFixed(8))
) {
addLastSnackbar({ message: `${translate('send.sendall-message') as string}`, type: 'Primary' });
}
if (!netInfo.isConnected) {
addLastSnackbar({ message: translate('loadedapp.connection-error') as string, type: 'Primary' });
return;
}
// waiting while closing the keyboard, just in case.
setTimeout(async () => {
setConfirmModalVisible(true);
}, 100);
}}
/>
<Button
type="Secondary"
style={{ marginLeft: 10 }}
title={translate('send.clear') as string}
onPress={() => clearToAddr()}
/>
</View>
<TouchableOpacity
onPress={() => {
console.log(
Utils.getDonationAddress(server.chain_name),
Utils.getDefaultDonationAmount(),
null,
Utils.getDefaultDonationMemo(translate),
true,
);
// fill the fields in the screen with the donation data
updateToField(
Utils.getDonationAddress(server.chain_name),
Utils.getDefaultDonationAmount(),
null,
Utils.getDefaultDonationMemo(translate),
true,
);
}}>
<View
style={{
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
paddingHorizontal: 4,
paddingBottom: 2,
borderWidth: 1,
borderColor: colors.primary,
borderRadius: 5,
}}>
<Text style={{ fontSize: 13, color: colors.border }}>{translate('donation-button') as string}</Text>
<FontAwesomeIcon style={{ marginTop: 3 }} size={20} icon={faMoneyCheckDollar} color={colors.primary} />
</View>
</TouchableOpacity>
</View>
</View>
</ScrollView>
Expand Down

0 comments on commit 467be2e

Please sign in to comment.