Commit c9b2f25c authored by Thibaut Sardan's avatar Thibaut Sardan Committed by Maciej Hirsz
Browse files

Tbaut remove tab navigation (#226)

* fix(): remove tabs

* fix(): remove account details overview in signed transactions

* fix(): Get back to account list after signing a tx

* fix(): remove account details overview in signed transactions bis

* fix(): prevent navigating back to pin

* fix(): remove new line and comments
parent 4cd616bd
Pipeline #31656 failed with stage
in 2 minutes and 53 seconds
This diff is collapsed.
......@@ -15,7 +15,7 @@
"start": "yarn run ios",
"test": "jest",
"lint": "",
"commit": ""
"commit": "commit-wizard"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
......@@ -62,5 +62,18 @@
"setupFiles": [
"<rootDir>/jest-setup.js"
]
},
"release": {
"analyzeCommits": "simple-commit-message"
},
"config": {
"pre-git": {
"commit-msg": "simple",
"pre-commit": [],
"pre-push": [],
"post-commit": [],
"post-checkout": [],
"post-merge": []
}
}
}
......@@ -20,7 +20,6 @@
import React, { Component } from 'react';
import { StatusBar } from 'react-native';
import {
createBottomTabNavigator,
createStackNavigator,
HeaderBackButton,
withNavigation
......@@ -31,7 +30,6 @@ import colors from './colors';
import Background from './components/Background';
import HeaderLeftHome from './components/HeaderLeftHome';
import SecurityHeader from './components/SecurityHeader';
import TabBarBottom from './components/TabBarBottom';
import About from './screens/About';
import AccountAdd from './screens/AccountAdd';
import AccountBackup from './screens/AccountBackup';
......@@ -152,6 +150,12 @@ const Screens = createStackNavigator(
Welcome: {
screen: createStackNavigator(
{
AccountList: {
screen: AccountList,
navigationOptions: {
headerLeft: <HeaderLeftHome />
}
},
AccountAdd: {
screen: AccountAdd,
navigationOptions: {
......@@ -172,6 +176,36 @@ const Screens = createStackNavigator(
},
AccountPin: {
screen: AccountPin
},
QrScanner: {
screen: QrScanner,
},
TxDetails: {
screen: TxDetails
},
AccountUnlockAndSign: {
screen: AccountUnlockAndSign
},
SignedTx: {
screen: SignedTx
},
SignedMessage: {
screen: SignedMessage
},
MessageDetails: {
screen: MessageDetails
},
About: {
screen: About
},
AccountDetails: {
screen: AccountDetails
},
AccountUnlock: {
screen: AccountUnlock
},
AccountEdit: {
screen: AccountEdit
}
},
{
......@@ -182,107 +216,9 @@ const Screens = createStackNavigator(
}
)
},
Tabs: {
screen: createBottomTabNavigator(
{
Scanner: {
screen: createStackNavigator(
{
QrScanner: {
screen: QrScanner,
navigationOptions: {
headerLeft: <HeaderLeftHome />
}
},
TxDetails: {
screen: TxDetails
},
AccountUnlockAndSign: {
screen: AccountUnlockAndSign
},
SignedTx: {
screen: SignedTx
},
SignedMessage: {
screen: SignedMessage
},
MessageDetails: {
screen: MessageDetails
}
},
{
navigationOptions: globalStackNavigationOptions
}
)
},
Accounts: {
screen: createStackNavigator(
{
AccountList: {
screen: AccountList,
navigationOptions: {
headerLeft: <HeaderLeftHome />
}
},
AccountNew: {
screen: AccountNew
},
AccountAdd: {
screen: AccountAdd
},
About: {
screen: About
},
AccountNetworkChooser: {
screen: AccountNetworkChooser
},
AccountRecover: {
screen: AccountRecover
},
AccountBackup: {
screen: AccountBackup
},
AccountPin: {
screen: AccountPin
},
AccountDetails: {
screen: AccountDetails
},
AccountUnlock: {
screen: AccountUnlock
},
AccountEdit: {
screen: AccountEdit
}
},
{
mode: 'card',
// cardStyle: { backgroundColor: 'transparent' },
// transitionConfig: () => ({
// containerStyle: {
// backgroundColor: 'transparent'
// }
// }),
navigationOptions: globalStackNavigationOptions
}
)
}
},
{
tabBarComponent: props => <TabBarBottom {...props} />,
tabBarPosition: 'bottom'
}
)
}
},
{
headerMode: 'none',
mode: 'card'
// transitionConfig: (): Object => ({
// containerStyle: {
// backgroundColor: 'transparent'
// }
// }),
// cardStyle: { backgroundColor: 'transparent' }
}
);
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
/* @flow */
import React from 'react';
import { Platform, SafeAreaView, StyleSheet, Text, TouchableWithoutFeedback, View } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import colors from '../colors';
import withDimensions from './utils/withDimensions';
type Props = TabBarOptions & {
navigation: any
};
const majorVersion = parseInt(Platform.Version, 10);
const isIos = Platform.OS === 'ios';
const isIOS11 = majorVersion >= 11 && isIos;
class TabBarBottom extends React.PureComponent<Props> {
static defaultProps = {
activeTintColor: '#3478f6', // Default active tint color in iOS 10
activeBackgroundColor: colors.bg,
inactiveTintColor: '#929292', // Default inactive tint color in iOS 10
inactiveBackgroundColor: colors.bg,
showLabel: true,
showIcon: true,
allowFontScaling: true,
adaptive: isIOS11
};
render() {
const {
navigation,
activeBackgroundColor,
inactiveBackgroundColor,
onTabPress,
jumpTo,
style,
tabStyle
} = this.props;
const { routes } = navigation.state;
const tabBarStyle = styles.tabBar;
return (
<SafeAreaView
style={tabBarStyle}
forceInset={{ bottom: 'always', top: 'never' }}
>
{routes.map((route, index) => {
const focused = index === navigation.state.index;
const backgroundColor = focused ? colors.card_bg : colors.bg;
const color = focused ? colors.bg : colors.card_bg;
return (
<TouchableWithoutFeedback
key={route.key}
onPress={() => {
if (focused) {
if (route.routes.length > 1) {
// In case of we are not in the "home" route and route is "focused" we want to go home
navigation.popToTop();
} else {
// In case we are on the "home" route we want to go to the first item in the list
if (route.key === 'Accounts') {
navigation.navigate('AccountList', { index: 0 });
}
}
} else {
navigation.navigate(route.key);
}
}}
>
<View style={[styles.tab, { backgroundColor }]}>
<Icon
style={[styles.labelIcon, { color }]}
name={route.key === 'Scanner' ? 'qrcode' : 'briefcase'}
/>
<Text style={[styles.labelText, { color }]}>
{route.key === 'Scanner' ? 'Scanner' : 'Accounts'}
</Text>
</View>
</TouchableWithoutFeedback>
);
})}
</SafeAreaView>
);
}
}
const DEFAULT_HEIGHT = 65;
const styles = StyleSheet.create({
tabBar: {
height: DEFAULT_HEIGHT,
backgroundColor: colors.bg,
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: colors.bg_text_sec,
flexDirection: 'row'
},
tabBarRegular: {
height: DEFAULT_HEIGHT
},
tab: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center'
},
labelText: {
fontSize: 22,
fontFamily: 'Manifold CF',
fontWeight: 'bold',
color: colors.card_bg,
color: 'white'
},
labelIcon: {
fontSize: 30,
paddingRight: 10
}
});
export default withDimensions(TabBarBottom);
......@@ -118,9 +118,12 @@ class AccountListView extends React.PureComponent {
<Button
buttonStyles={{ height: 60 }}
title="Add Account"
onPress={() => {
this.props.navigation.navigate('AccountAdd');
}}
onPress={() => this.props.navigation.navigate('AccountAdd')}
/>
<Button
buttonStyles={{ height: 60, marginTop: 20 }}
title="Scan"
onPress={() => this.props.navigation.navigate('QrScanner')}
/>
</View>
</View>
......@@ -147,7 +150,6 @@ const styles = StyleSheet.create({
},
bottom: {
marginTop: 20,
flexBasis: 60
},
introContainer: {
padding: 30,
......
......@@ -53,14 +53,14 @@ class AccountPinView extends React.PureComponent {
async submit() {
const { accounts, type, navigation } = this.props;
const isNew = navigation.getParam('isNew');
const accountCreation = navigation.getParam('isNew');
const { pin } = this.state;
if (
this.state.pin.length >= 6 &&
this.state.pin === this.state.confirmation
) {
let account = null;
if (isNew) {
if (accountCreation) {
account = accounts.getNew();
await accounts.submitNew(pin);
await accounts.select(account);
......@@ -69,19 +69,10 @@ class AccountPinView extends React.PureComponent {
await accounts.save(account, pin);
}
accounts.refreshList();
if (navigation.getParam('isWelcome')) {
navigation.navigate('Tabs');
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'QrScanner' })]
});
navigation.dispatch(resetAction);
} else {
navigation.popToTop();
navigation.navigate('AccountList', {
accountId: accountId(account)
});
}
navigation.popToTop();
navigation.navigate('AccountList', {
accountId: accountId(account)
});
} else {
if (this.state.pin.length < 6) {
this.setState({ pinTooShort: true });
......
......@@ -49,10 +49,9 @@ export class AccountUnlockAndSign extends React.PureComponent {
}}
navigate={() => {
const resetAction = StackActions.reset({
index: 2,
index: 1,
actions: [
NavigationActions.navigate({ routeName: 'QrScanner' }),
NavigationActions.navigate({ routeName: 'TxDetails' }),
NavigationActions.navigate({ routeName: 'AccountList' }),
NavigationActions.navigate({ routeName: next })
]
});
......
......@@ -43,9 +43,7 @@ export default class Loading extends React.PureComponent {
accounts = await loadAccounts();
}
const firstScreen = accounts.filter(a => !a.archived).length
? 'Tabs'
: 'Welcome';
const firstScreen = 'Welcome';
const firstScreenActions = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: firstScreen })],
......
......@@ -35,10 +35,6 @@ export default class SignedMessage extends React.PureComponent {
<SignedMessageView
data={scanner.getSignedTxData()}
message={scanner.getMessage()}
onPressAccount={async account => {
await accounts.select(account);
this.props.navigation.navigate('AccountDetails');
}}
/>
);
}}
......
......@@ -36,10 +36,6 @@ export default class SignedTx extends React.PureComponent {
<SignedTxView
{...scanner.getTx()}
data={scanner.getSignedTxData()}
onPressAccount={async account => {
await accounts.select(account);
this.props.navigation.navigate('AccountDetails');
}}
recipient={scanner.getRecipient()}
/>
);
......@@ -79,9 +75,6 @@ export class SignedTxView extends React.PureComponent {
title={this.props.recipient.name}
address={this.props.recipient.address}
chainId={this.props.recipient.chainId || ''}
onPress={() => {
this.props.onPressAccount(this.props.recipient);
}}
/>
</ScrollView>
);
......
......@@ -28,8 +28,6 @@ import TxDetailsCard from '../components/TxDetailsCard';
import AccountsStore from '../stores/AccountsStore';
import ScannerStore from '../stores/ScannerStore';
const orUnknown = (value = 'Unknown') => value;
export default class TxDetails extends React.PureComponent {
static navigationOptions = {
title: 'Transaction Details',
......@@ -38,7 +36,7 @@ export default class TxDetails extends React.PureComponent {
render() {
return (
<Subscribe to={[ScannerStore, AccountsStore]}>
{(scannerStore, accounts) => {
{(scannerStore) => {
const txRequest = scannerStore.getTXRequest();
if (txRequest) {
const tx = scannerStore.getTx();
......@@ -49,10 +47,6 @@ export default class TxDetails extends React.PureComponent {
sender={scannerStore.getSender()}
recipient={scannerStore.getRecipient()}
dataToSign={scannerStore.getDataToSign()}
onPressAccount={async account => {
await accounts.select(account);
this.props.navigation.navigate('AccountDetails');
}}
onNext={async () => {
try {
this.props.navigation.navigate('AccountUnlockAndSign');
......@@ -96,9 +90,6 @@ export class TxDetailsView extends React.PureComponent {
title={this.props.sender.name}
address={this.props.sender.address}
chainId={this.props.sender.chainId}
onPress={() => {
this.props.onPressAccount(this.props.sender);
}}
/>
<Text style={styles.title}>TRANSACTION DETAILS</Text>
<TxDetailsCard
......@@ -113,9 +104,6 @@ export class TxDetailsView extends React.PureComponent {
title={this.props.recipient.name}
address={this.props.recipient.address}
chainId={this.props.recipient.chainId || ''}
onPress={() => {
this.props.onPressAccount(this.props.recipient);
}}
/>
<Button
buttonStyles={{ backgroundColor: colors.bg_positive, height: 60 }}
......
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