BlueWallet/screen/settings/about.js

268 lines
8.3 KiB
JavaScript
Raw Normal View History

2023-10-21 18:51:33 -04:00
import React, { useContext } from 'react';
import { TouchableOpacity, ScrollView, Linking, Image, View, Text, StyleSheet, useWindowDimensions, Platform, Alert } from 'react-native';
2020-07-15 13:32:59 -04:00
import { useNavigation, useTheme } from '@react-navigation/native';
2020-12-19 18:32:47 +00:00
import { Icon } from 'react-native-elements';
2023-10-21 18:51:33 -04:00
import { getApplicationName, getVersion, getBundleId, getBuildNumber, getUniqueIdSync, hasGmsSync } from 'react-native-device-info';
2019-01-10 21:24:49 -05:00
import Rate, { AndroidMarket } from 'react-native-rate';
2021-05-18 12:54:18 +01:00
import { BlueButton, BlueCard, BlueListItem, BlueSpacing20, BlueTextCentered } from '../../BlueComponents';
2020-12-25 19:09:53 +03:00
import navigationStyle from '../../components/navigationStyle';
2021-08-01 15:05:21 -04:00
import loc, { formatStringAddTwoWhiteSpaces } from '../../loc';
2021-05-18 12:54:18 +01:00
import Clipboard from '@react-native-clipboard/clipboard';
2021-08-28 03:08:58 -04:00
import { BlueStorageContext } from '../../blue_modules/storage-context';
import alert from '../../components/Alert';
import { HDSegwitBech32Wallet } from '../../class';
2020-07-20 16:38:46 +03:00
2021-09-13 14:08:49 +01:00
const A = require('../../blue_modules/analytics');
const branch = require('../../current-branch.json');
2021-09-13 14:08:49 +01:00
2019-12-25 10:46:51 -06:00
const About = () => {
const { navigate } = useNavigation();
2020-07-15 13:32:59 -04:00
const { colors } = useTheme();
2020-10-07 08:24:36 -04:00
const { width, height } = useWindowDimensions();
2021-08-28 03:08:58 -04:00
const { isElectrumDisabled } = useContext(BlueStorageContext);
2020-07-15 13:32:59 -04:00
const styles = StyleSheet.create({
2021-04-15 13:20:07 +01:00
copyToClipboard: {
justifyContent: 'center',
alignItems: 'center',
},
2021-05-18 12:54:18 +01:00
copyToClipboardText: {
fontSize: 13,
fontWeight: '400',
color: '#68bbe1',
},
2020-07-15 13:32:59 -04:00
center: {
justifyContent: 'center',
alignItems: 'center',
marginTop: 54,
},
logo: {
width: 102,
height: 124,
},
textFree: {
maxWidth: 260,
marginVertical: 24,
color: '#9AA0AA',
fontSize: 15,
textAlign: 'center',
fontWeight: '500',
},
textBackup: {
maxWidth: 260,
marginBottom: 40,
color: colors.foregroundColor,
fontSize: 15,
textAlign: 'center',
fontWeight: '500',
},
buildWith: {
backgroundColor: colors.inputBackgroundColor,
padding: 16,
paddingTop: 0,
borderRadius: 8,
},
2020-12-21 15:34:51 -05:00
buttonLink: {
2020-12-19 18:32:47 +00:00
backgroundColor: colors.lightButton,
borderRadius: 12,
2020-12-21 15:34:51 -05:00
justifyContent: 'center',
2020-12-19 18:32:47 +00:00
padding: 8,
2020-12-21 15:34:51 -05:00
flexDirection: 'row',
2020-12-19 18:32:47 +00:00
},
2020-12-21 15:34:51 -05:00
textLink: {
2020-12-19 18:32:47 +00:00
color: colors.foregroundColor,
marginLeft: 8,
fontWeight: '600',
},
2020-07-15 13:32:59 -04:00
});
2019-12-25 10:46:51 -06:00
const handleOnReleaseNotesPress = () => {
navigate('ReleaseNotes');
};
const handleOnSelfTestPress = () => {
2021-08-28 03:08:58 -04:00
if (isElectrumDisabled) {
alert(loc.settings.about_selftest_electrum_disabled);
} else {
navigate('Selftest');
}
2019-12-25 10:46:51 -06:00
};
2020-03-31 21:13:48 +02:00
const handleOnLicensingPress = () => {
navigate('Licensing');
};
2019-12-25 10:46:51 -06:00
const handleOnTwitterPress = () => {
Linking.openURL('https://twitter.com/bluewalletio');
};
const handleOnDiscordPress = () => {
Linking.openURL('https://discord.gg/btWq2Aby2z');
2019-12-25 10:46:51 -06:00
};
2018-03-31 14:43:08 +01:00
2019-12-25 10:46:51 -06:00
const handleOnTelegramPress = () => {
Linking.openURL('https://t.me/bluewallethat');
2019-12-25 10:46:51 -06:00
};
2020-12-19 18:32:47 +00:00
const handleOnGithubPress = () => {
Linking.openURL('https://github.com/BlueWallet/BlueWallet');
2019-12-25 10:46:51 -06:00
};
const handleOnRatePress = () => {
const options = {
AppleAppID: '1376878040',
GooglePackageName: 'io.bluewallet.bluewallet',
preferredAndroidMarket: AndroidMarket.Google,
preferInApp: Platform.OS !== 'android',
2019-12-25 10:46:51 -06:00
openAppStoreIfInAppFails: true,
fallbackPlatformURL: 'https://bluewallet.io',
};
Rate.rate(options, success => {
if (success) {
console.log('User Rated.');
}
2018-03-31 14:43:08 +01:00
});
2019-12-25 10:46:51 -06:00
};
2020-10-07 08:24:36 -04:00
return (
<ScrollView testID="AboutScrollView" contentInsetAdjustmentBehavior="automatic">
<BlueCard>
<View style={styles.center}>
<Image style={styles.logo} source={require('../../img/bluebeast.png')} />
<Text style={styles.textFree}>{loc.settings.about_free}</Text>
2021-08-01 15:05:21 -04:00
<Text style={styles.textBackup}>{formatStringAddTwoWhiteSpaces(loc.settings.about_backup)}</Text>
{((Platform.OS === 'android' && hasGmsSync()) || Platform.OS !== 'android') && (
<BlueButton onPress={handleOnRatePress} title={loc.settings.about_review + ' ⭐🙏'} />
)}
</View>
</BlueCard>
<BlueListItem
leftIcon={{
name: 'twitter',
type: 'font-awesome',
color: '#1da1f2',
}}
onPress={handleOnTwitterPress}
title={loc.settings.about_sm_twitter}
/>
<BlueListItem
leftIcon={{
name: 'telegram',
type: 'font-awesome',
color: '#0088cc',
}}
onPress={handleOnTelegramPress}
title={loc.settings.about_sm_telegram}
/>
<BlueListItem
leftIcon={{
name: 'discord',
type: 'font-awesome-5',
color: '#7289da',
}}
onPress={handleOnDiscordPress}
title={loc.settings.about_sm_discord}
/>
<BlueCard>
<View style={styles.buildWith}>
<BlueSpacing20 />
2019-12-25 10:46:51 -06:00
<BlueTextCentered>{loc.settings.about_awesome} 👍</BlueTextCentered>
<BlueSpacing20 />
<BlueTextCentered>React Native</BlueTextCentered>
<BlueTextCentered>bitcoinjs-lib</BlueTextCentered>
<BlueTextCentered>Nodejs</BlueTextCentered>
<BlueTextCentered>Electrum server</BlueTextCentered>
<BlueSpacing20 />
2020-12-19 18:32:47 +00:00
<TouchableOpacity accessibilityRole="button" onPress={handleOnGithubPress} style={styles.buttonLink}>
<Icon size={22} name="github" type="font-awesome-5" color={colors.foregroundColor} />
2021-08-01 15:05:21 -04:00
<Text style={styles.textLink}>{formatStringAddTwoWhiteSpaces(loc.settings.about_sm_github)}</Text>
</TouchableOpacity>
2021-04-15 13:20:07 +01:00
</View>
</BlueCard>
<BlueListItem
leftIcon={{
name: 'book',
type: 'font-awesome',
color: '#9AA0AA',
}}
chevron
onPress={handleOnReleaseNotesPress}
title={loc.settings.about_release_notes}
/>
<BlueListItem
leftIcon={{
2022-06-21 21:05:34 +01:00
name: 'balance-scale',
type: 'font-awesome',
color: colors.foregroundColor,
}}
chevron
onPress={handleOnLicensingPress}
title={loc.settings.about_license}
/>
<BlueListItem
leftIcon={{
name: 'flask',
type: 'font-awesome',
color: '#FC0D44',
}}
chevron
onPress={handleOnSelfTestPress}
testID="RunSelfTestButton"
title={loc.settings.about_selftest}
/>
<BlueListItem
leftIcon={{
name: 'flask',
type: 'font-awesome',
color: '#FC0D44',
}}
chevron
onPress={async () => {
const secret = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
const w = new HDSegwitBech32Wallet();
w.setSecret(secret);
const start = Date.now();
let num;
for (num = 0; num < 1000; num++) {
w._getExternalAddressByIndex(num);
if (Date.now() - start > 10 * 1000) {
break;
}
}
Alert.alert(loc.formatString(loc.settings.performance_score, { num }));
}}
title={loc.settings.run_performance_test}
/>
<BlueSpacing20 />
<BlueSpacing20 />
<BlueTextCentered>
{getApplicationName()} ver {getVersion()} (build {getBuildNumber() + ' ' + branch})
</BlueTextCentered>
<BlueTextCentered>{new Date(getBuildNumber() * 1000).toGMTString()}</BlueTextCentered>
<BlueTextCentered>{getBundleId()}</BlueTextCentered>
<BlueTextCentered>
w, h = {width}, {height}
</BlueTextCentered>
2023-10-21 18:51:33 -04:00
<BlueTextCentered>Unique ID: {getUniqueIdSync()}</BlueTextCentered>
<View style={styles.copyToClipboard}>
2021-05-18 12:54:18 +01:00
<TouchableOpacity
accessibilityRole="button"
2021-05-18 12:54:18 +01:00
onPress={() => {
2023-10-21 18:51:33 -04:00
const stringToCopy = 'userId:' + getUniqueIdSync();
2021-09-13 14:08:49 +01:00
A.logError('copied unique id');
2021-05-18 12:54:18 +01:00
Clipboard.setString(stringToCopy);
}}
>
<Text style={styles.copyToClipboardText}>{loc.transactions.details_copy}</Text>
</TouchableOpacity>
</View>
<BlueSpacing20 />
<BlueSpacing20 />
</ScrollView>
2019-12-25 10:46:51 -06:00
);
2018-03-31 14:43:08 +01:00
};
2019-12-25 10:46:51 -06:00
2021-02-15 11:03:54 +03:00
About.navigationOptions = navigationStyle({}, opts => ({ ...opts, title: loc.settings.about }));
2019-12-25 10:46:51 -06:00
export default About;