Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tor icon: move out of BalancePane and into WalletHeader #1356

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion components/WalletHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { Row } from '../components/layout/Row';

const Contact = require('../assets/images/Mascot.png');

const TorIcon = require('../assets/images/tor.png');

const protectedNavigation = async (
navigation: any,
route: string,
Expand Down Expand Up @@ -196,6 +198,7 @@ export default class WalletHeader extends React.Component<
);

const displayName = selectedNode && selectedNode.nickname;
const nodeAddress = SettingsStore.host || SettingsStore.url;

let infoValue: string;
if (NodeInfoStore.nodeInfo.isTestNet) {
Expand All @@ -219,6 +222,26 @@ export default class WalletHeader extends React.Component<
) : null;
};

const TorBadge = () => (
<>
{nodeAddress && nodeAddress.includes('.onion') ? (
<TouchableOpacity
onPress={() => navigation.navigate('NodeInfo')}
>
<Image
style={{
marginLeft: 5,
marginRight: 5,
width: 25,
height: 25
}}
source={TorIcon}
/>
</TouchableOpacity>
) : null}
</>
);

return (
<Header
leftComponent={loading ? undefined : <SettingsButton />}
Expand All @@ -232,10 +255,14 @@ export default class WalletHeader extends React.Component<
<Row>
<Body>{displayName}</Body>
<NetworkBadge />
<TorBadge />
</Row>
</View>
) : (
<NetworkBadge />
<Row>
<NetworkBadge />
<TorBadge />
</Row>
)
}
rightComponent={
Expand Down
28 changes: 1 addition & 27 deletions views/Wallet/BalancePane.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Image, Text, View, StyleSheet, TouchableOpacity } from 'react-native';
import { Text, View, StyleSheet } from 'react-native';
import { inject, observer } from 'mobx-react';
import Button from '../../components/Button';
import WalletHeader from '../../components/WalletHeader';
Expand All @@ -14,8 +14,6 @@ import SettingsStore from './../../stores/SettingsStore';

import { version, playStore } from './../../package.json';

const TorIcon = require('./../../assets/images/tor.png');

interface BalancePaneProps {
navigation: any;
BalanceStore: BalanceStore;
Expand All @@ -39,7 +37,6 @@ export default class BalancePane extends React.PureComponent<
pendingOpenBalance
} = BalanceStore;
const { implementation } = SettingsStore;
const nodeAddress = SettingsStore.host || SettingsStore.url;

const pendingUnconfirmedBalance =
Number(pendingOpenBalance) + Number(unconfirmedBlockchainBalance);
Expand Down Expand Up @@ -113,21 +110,6 @@ export default class BalancePane extends React.PureComponent<
</View>
);

const NetworkBadge = () => (
<>
{nodeAddress && nodeAddress.includes('.onion') ? (
<TouchableOpacity
onPress={() => navigation.navigate('NodeInfo')}
>
<Image
style={{ width: 25, height: 25 }}
source={TorIcon}
/>
</TouchableOpacity>
) : null}
</>
);

let balancePane;
const error = NodeInfoStore.error || SettingsStore.error;

Expand All @@ -150,14 +132,6 @@ export default class BalancePane extends React.PureComponent<
) : (
<BalanceViewCombined />
)}
<View
style={{
marginTop: 5,
alignItems: 'center'
}}
>
<NetworkBadge />
</View>
</View>
</View>
);
Expand Down