BlueWallet/screen/settings/about.js

210 lines
5.7 KiB
JavaScript
Raw Normal View History

2019-12-25 17:46:51 +01:00
import React, { useEffect, useState } from 'react';
import { ScrollView, Linking, Dimensions, Image, View, Text, StyleSheet } from 'react-native';
2020-07-15 19:32:59 +02:00
import { useNavigation, useTheme } from '@react-navigation/native';
2018-07-18 00:43:23 +02:00
import {
BlueTextCentered,
BlueSpacing20,
BlueButton,
SafeBlueArea,
BlueCard,
2020-07-15 19:32:59 +02:00
BlueListItemHooks,
BlueNavigationStyle,
2020-07-15 19:32:59 +02:00
BlueLoadingHook,
} from '../../BlueComponents';
2019-10-22 17:17:08 +02:00
import { getApplicationName, getVersion, getBundleId, getBuildNumber } from 'react-native-device-info';
2019-01-11 03:24:49 +01:00
import Rate, { AndroidMarket } from 'react-native-rate';
2020-07-20 15:38:46 +02:00
import loc from '../../loc';
2018-07-18 00:43:23 +02:00
const { width, height } = Dimensions.get('window');
2018-03-31 15:43:08 +02:00
2019-12-25 17:46:51 +01:00
const About = () => {
const [isLoading, setIsLoading] = useState(true);
const { navigate } = useNavigation();
2020-07-15 19:32:59 +02:00
const { colors } = useTheme();
const styles = StyleSheet.create({
root: {
flex: 1,
},
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,
},
});
2019-12-25 17:46:51 +01:00
useEffect(() => {
setIsLoading(false);
2020-03-18 12:56:59 +01:00
}, []);
2018-03-31 15:43:08 +02:00
2019-12-25 17:46:51 +01:00
const handleOnReleaseNotesPress = () => {
navigate('ReleaseNotes');
};
const handleOnSelfTestPress = () => {
navigate('Selftest');
};
2020-03-31 21:13:48 +02:00
const handleOnLicensingPress = () => {
navigate('Licensing');
};
2019-12-25 17:46:51 +01:00
const handleOnTwitterPress = () => {
Linking.openURL('https://twitter.com/bluewalletio');
};
const handleOnGithubPress = () => {
Linking.openURL('https://github.com/BlueWallet/BlueWallet');
};
2018-03-31 15:43:08 +02:00
2019-12-25 17:46:51 +01:00
const handleOnTelegramPress = () => {
Linking.openURL('https://t.me/bluewallet');
};
const handleOnRatePress = () => {
const options = {
AppleAppID: '1376878040',
GooglePackageName: 'io.bluewallet.bluewallet',
preferredAndroidMarket: AndroidMarket.Google,
preferInApp: true,
openAppStoreIfInAppFails: true,
fallbackPlatformURL: 'https://bluewallet.io',
};
Rate.rate(options, success => {
if (success) {
console.log('User Rated.');
}
2018-03-31 15:43:08 +02:00
});
2019-12-25 17:46:51 +01:00
};
return isLoading ? (
2020-07-15 19:32:59 +02:00
<BlueLoadingHook />
2019-12-25 17:46:51 +01:00
) : (
<SafeBlueArea style={styles.root}>
2020-03-19 16:51:35 +01:00
<ScrollView testID="AboutScrollView">
2019-12-25 17:46:51 +01:00
<BlueCard>
<View style={styles.center}>
<Image style={styles.logo} source={require('../../img/bluebeast.png')} />
2020-07-20 15:38:46 +02:00
<Text style={styles.textFree}>{loc.settings.about_free}</Text>
<Text style={styles.textBackup}>{loc.settings.about_backup}</Text>
<BlueButton onPress={handleOnRatePress} title={loc.settings.about_review + ' ⭐🙏'} />
2020-03-31 20:10:49 +02:00
</View>
</BlueCard>
2020-07-15 19:32:59 +02:00
<BlueListItemHooks
2020-03-31 20:10:49 +02:00
leftIcon={{
name: 'twitter',
type: 'font-awesome',
2020-03-31 20:16:22 +02:00
color: '#1da1f2',
2020-03-31 20:10:49 +02:00
}}
onPress={handleOnTwitterPress}
2020-07-20 15:38:46 +02:00
title={loc.settings.about_sm_twitter}
2020-03-31 20:10:49 +02:00
/>
2020-07-15 19:32:59 +02:00
<BlueListItemHooks
2020-03-31 20:10:49 +02:00
leftIcon={{
name: 'telegram',
type: 'font-awesome',
2020-03-31 20:16:22 +02:00
color: '#0088cc',
2020-03-31 20:10:49 +02:00
}}
onPress={handleOnTelegramPress}
2020-07-20 15:38:46 +02:00
title={loc.settings.about_sm_telegram}
2020-03-31 20:10:49 +02:00
/>
2020-07-15 19:32:59 +02:00
<BlueListItemHooks
2020-03-31 20:10:49 +02:00
leftIcon={{
name: 'github',
type: 'font-awesome',
2020-07-15 19:32:59 +02:00
color: colors.foregroundColor,
2020-03-31 20:10:49 +02:00
}}
onPress={handleOnGithubPress}
2020-07-20 15:38:46 +02:00
title={loc.settings.about_sm_github}
2020-03-31 20:10:49 +02:00
/>
<BlueCard>
<View style={styles.buildWith}>
2020-03-31 20:16:22 +02:00
<BlueSpacing20 />
2019-12-25 17:46:51 +01:00
2020-07-20 15:38:46 +02:00
<BlueTextCentered>{loc.settings.about_awesome} 👍</BlueTextCentered>
2020-03-31 20:16:22 +02:00
<BlueSpacing20 />
<BlueTextCentered>React Native</BlueTextCentered>
<BlueTextCentered>bitcoinjs-lib</BlueTextCentered>
<BlueTextCentered>Nodejs</BlueTextCentered>
<BlueTextCentered>Electrum server</BlueTextCentered>
2020-03-31 20:10:49 +02:00
</View>
2019-12-25 17:46:51 +01:00
</BlueCard>
2020-07-15 19:32:59 +02:00
<BlueListItemHooks
2020-03-31 20:10:49 +02:00
leftIcon={{
name: 'book',
type: 'font-awesome',
2020-03-31 20:16:22 +02:00
color: '#9AA0AA',
2020-03-31 20:10:49 +02:00
}}
2020-05-03 20:17:49 +02:00
chevron
2020-03-31 20:10:49 +02:00
onPress={handleOnReleaseNotesPress}
2020-07-20 15:38:46 +02:00
title={loc.settings.about_release_notes}
2020-03-31 20:10:49 +02:00
/>
2020-07-15 19:32:59 +02:00
<BlueListItemHooks
2020-03-31 21:13:48 +02:00
leftIcon={{
name: 'law',
type: 'octicon',
2020-07-15 19:32:59 +02:00
color: colors.foregroundColor,
2020-03-31 21:13:48 +02:00
}}
2020-05-03 20:17:49 +02:00
chevron
2020-03-31 21:13:48 +02:00
onPress={handleOnLicensingPress}
title="MIT License"
/>
2020-07-15 19:32:59 +02:00
<BlueListItemHooks
2020-03-31 20:10:49 +02:00
leftIcon={{
name: 'flask',
type: 'font-awesome',
2020-03-31 20:16:22 +02:00
color: '#FC0D44',
2020-03-31 20:10:49 +02:00
}}
2020-05-03 20:17:49 +02:00
chevron
2020-03-31 20:10:49 +02:00
onPress={handleOnSelfTestPress}
testID="RunSelfTestButton"
2020-07-20 15:38:46 +02:00
title={loc.settings.about_selftest}
2020-03-31 20:10:49 +02:00
/>
<BlueSpacing20 />
<BlueSpacing20 />
<BlueTextCentered>
{getApplicationName()} ver {getVersion()} (build {getBuildNumber()})
</BlueTextCentered>
<BlueTextCentered>{new Date(getBuildNumber() * 1000).toGMTString()}</BlueTextCentered>
<BlueTextCentered>{getBundleId()}</BlueTextCentered>
<BlueTextCentered>
w, h = {width}, {height}
</BlueTextCentered>
2020-03-31 20:32:34 +02:00
<BlueSpacing20 />
<BlueSpacing20 />
2019-12-25 17:46:51 +01:00
</ScrollView>
</SafeBlueArea>
);
2018-03-31 15:43:08 +02:00
};
2019-12-25 17:46:51 +01:00
About.navigationOptions = () => ({
...BlueNavigationStyle(),
2020-07-15 19:32:59 +02:00
headerTitle: loc.settings.about,
2019-12-25 17:46:51 +01:00
});
export default About;