Unverified Commit df1b3ff1 authored by Hanwen Cheng's avatar Hanwen Cheng Committed by GitHub
Browse files

style: move scan button to top bar (#499)

parent 0e863270
Pipeline #71632 failed with stages
in 5 minutes and 3 seconds
......@@ -40,6 +40,7 @@ const {
PathDerivation,
PathDetail,
PathsList,
SecurityHeader,
SignedTx,
TxDetails
} = testIDs;
......@@ -123,7 +124,7 @@ describe('Load test', async () => {
it('should sign the transaction', async () => {
await tapBack();
await testTap(AccountNetworkChooser.scanButton);
await testTap(SecurityHeader.scanButton);
await testScrollAndTap(TxDetails.signButton, TxDetails.scrollScreen);
await testUnlockPin(pinCode);
await testVisible(SignedTx.qrView);
......
......@@ -27,7 +27,6 @@ const testIDs = {
networkButton: 'anc_network_button',
noAccountScreen: 'anc_no_account_screen',
recoverButton: 'anc_recover_button',
scanButton: 'anc_scan_button',
showExistedButton: 'anc_show_existed'
},
Header: {
......@@ -72,8 +71,10 @@ const testIDs = {
},
PathsList: {
deriveButton: 'path_list_derive_button',
pathCard: 'path_list_path_card',
scanButton: 'path_list_scan_button'
pathCard: 'path_list_path_card'
},
SecurityHeader: {
scanButton: 'security_header_scan_button'
},
SignedMessage: {},
SignedTx: {
......
......@@ -18,12 +18,13 @@
import NetInfo from '@react-native-community/netinfo';
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import { StyleSheet, View } from 'react-native';
import { withNavigation } from 'react-navigation';
import colors from '../colors';
import IdentitiesSwitch from '../components/IdentitiesSwitch';
import ButtonIcon from './ButtonIcon';
import testIDs from '../../e2e/testIDs';
function SecurityHeader({ navigation }) {
const [isConnected, setIsConnected] = useState(false);
......@@ -37,25 +38,36 @@ function SecurityHeader({ navigation }) {
);
return (
<View
style={{
alignItems: 'center',
flexDirection: 'row',
paddingRight: 16
}}
>
<View style={styles.body}>
{isConnected && (
<ButtonIcon
onPress={() => navigation.navigate('Security')}
iconName="shield-off"
iconType="feather"
iconColor={colors.bg_alert}
iconBgStyle={{ backgroundColor: 'transparent', marginTop: -3 }}
iconBgStyle={styles.securityIconBgStyle}
/>
)}
<ButtonIcon
onPress={() => navigation.navigate('QrScanner')}
iconName="qrcode-scan"
iconType="material-community"
iconBgStyle={styles.scannerIconBgStyle}
testID={testIDs.SecurityHeader.scanButton}
/>
<IdentitiesSwitch />
</View>
);
}
const styles = StyleSheet.create({
body: {
alignItems: 'center',
flexDirection: 'row',
paddingRight: 16
},
scannerIconBgStyle: { backgroundColor: 'transparent' },
securityIconBgStyle: { backgroundColor: 'transparent', marginTop: -3 }
});
export default withNavigation(SecurityHeader);
......@@ -39,7 +39,6 @@ import {
getPathsWithSubstrateNetwork
} from '../util/identitiesUtils';
import testIDs from '../../e2e/testIDs';
import ButtonMainAction from '../components/ButtonMainAction';
import ScreenHeading from '../components/ScreenHeading';
import Separator from '../components/Separator';
import fontStyles from '../fontStyles';
......@@ -178,18 +177,6 @@ function AccountNetworkChooser({ navigation, accounts }) {
}
};
const renderScanButton = () => {
if (isNew) return;
else if (shouldShowMoreNetworks) return;
return (
<ButtonMainAction
testID={testIDs.AccountNetworkChooser.scanButton}
title={'Scan'}
onPress={() => navigation.navigate('QrScanner')}
/>
);
};
const onNetworkChosen = async (networkKey, networkParams) => {
if (isNew) {
if (networkParams.protocol === NetworkProtocols.SUBSTRATE) {
......@@ -240,7 +227,6 @@ function AccountNetworkChooser({ navigation, accounts }) {
))}
{renderShowMoreButton()}
</ScrollView>
{renderScanButton()}
</View>
);
}
......
......@@ -24,7 +24,6 @@ import colors from '../colors';
import AccountCard from '../components/AccountCard';
import Background from '../components/Background';
import testIDs from '../../e2e/testIDs';
import ButtonMainAction from '../components/ButtonMainAction';
import { withAccountStore } from '../util/HOC';
function LegacyAccountList({ navigation, accounts }) {
......@@ -55,10 +54,6 @@ function LegacyAccountList({ navigation, accounts }) {
}}
enableEmptySections
/>
<ButtonMainAction
title={'Scan'}
onPress={() => navigation.navigate('QrScanner')}
/>
</View>
);
}
......
......@@ -39,7 +39,6 @@ import testIDs from '../../e2e/testIDs';
import Separator from '../components/Separator';
import fontStyles from '../fontStyles';
import colors from '../colors';
import ButtonMainAction from '../components/ButtonMainAction';
import ScreenHeading from '../components/ScreenHeading';
function PathsList({ accounts, navigation }) {
......@@ -175,10 +174,6 @@ function PathsList({ accounts, navigation }) {
/>
)}
</ScrollView>
<ButtonMainAction
title={'Scan'}
onPress={() => navigation.navigate('QrScanner')}
/>
</View>
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment