Commit c54069f5 authored by Thibaut Sardan's avatar Thibaut Sardan
Browse files

revert conflicts

parent c31f5550
......@@ -173,11 +173,11 @@ const Screens = createStackNavigator(
Welcome: {
screen: createStackNavigator(
{
AccountNetworkChooser: {
AccountList: {
navigationOptions: {
headerLeft: <HeaderLeftHome />
},
screen: AccountNetworkChooser
screen: LegacyAccountList
},
AccountPin: {
screen: AccountPin
......@@ -194,6 +194,9 @@ const Screens = createStackNavigator(
AccountEdit: {
screen: AccountEdit
},
AccountNetworkChooser: {
screen: AccountNetworkChooser
},
AccountNew: {
screen: AccountNew
},
......@@ -206,9 +209,6 @@ const Screens = createStackNavigator(
LegacyAccountBackup: {
screen: LegacyAccountBackup
},
LegacyAccountList: {
screen: LegacyAccountList
},
IdentityBackup: {
screen: IdentityBackup
},
......
......@@ -220,7 +220,44 @@ function IdentitiesSwitch({ navigation, accounts }) {
style={{ paddingLeft: 8 * 4 }}
/>
<Separator />
{renderSettings()}
<ButtonIcon
title="Settings"
onPress={() => {
setVisible(false);
// go to Settings;
}}
iconName="ios-cog"
iconType="ionicon"
iconSize={24}
textStyle={fontStyles.t_big}
style={{ paddingLeft: 8 * 4 }}
/>
<ButtonIcon
title="Terms and Conditions"
onPress={() => {
setVisible(false);
navigation.navigate('TermsAndConditions');
}}
iconBgStyle={styles.i_arrowBg}
iconName="ios-arrow-round-forward"
iconType="ionicon"
iconSize={24}
textStyle={fontStyles.t_regular}
style={styles.i_arrowStyle}
/>
<ButtonIcon
title="Privacy Policy"
onPress={() => {
setVisible(false);
navigation.navigate('PrivacyPolicy');
}}
iconBgStyle={styles.i_arrowBg}
iconName="ios-arrow-round-forward"
iconType="ionicon"
iconSize={24}
textStyle={fontStyles.t_regular}
style={styles.i_arrowStyle}
/>
</View>
</View>
</Modal>
......
......@@ -17,7 +17,7 @@
'use strict';
import React, { useState } from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import { ScrollView, StyleSheet, Text } from 'react-native';
import { withNavigation } from 'react-navigation';
import colors from '../colors';
......@@ -43,36 +43,10 @@ function AccountNetworkChooser({ navigation, accounts }) {
excludedNetworks.push(SubstrateNetworkKeys.SUBSTRATE_DEV);
excludedNetworks.push(SubstrateNetworkKeys.KUSAMA_DEV);
}
const { identities, currentIdentity, loaded } = accounts.state;
const hasNoAccount =
accounts.getAccounts().size === 0 && identities.length === 0;
const showOnboardingMessage = () => {
const createLink = (text, isRecover) => (
<Text
style={styles.link}
onPress={() => navigation.navigate('IdentityNew', { isRecover })}
>
{text}
</Text>
);
return (
<ScrollView style={styles.body}>
<View style={styles.onboardingWrapper}>
<Text style={styles.onboardingText}>
No Identity yet?{'\n'}
{createLink('Create', false)} or {createLink('Recover', true)} an
account to get started.
</Text>
</View>
</ScrollView>
);
};
const getNetworkKeys = ([networkKey]) => {
const availableNetworks = getAvailableNetworkKeys(
currentIdentity || identities[0]
accounts.state.currentIdentity
);
if (excludedNetworks.includes(networkKey)) return false;
if (isNew) return true;
......@@ -107,10 +81,6 @@ function AccountNetworkChooser({ navigation, accounts }) {
}
};
if (!loaded) return <ScrollView style={styles.body} />;
if (hasNoAccount) return showOnboardingMessage();
return (
<ScrollView style={styles.body}>
<Text style={styles.title}>
......@@ -171,16 +141,6 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'center'
},
onboardingText: {
color: colors.bg_text_sec,
fontFamily: fonts.regular,
fontSize: 20
},
onboardingWrapper: {
alignItems: 'flex-end',
flex: 1,
flexDirection: 'row'
},
title: {
color: colors.bg_text_sec,
flexDirection: 'column',
......
......@@ -63,7 +63,7 @@ class AccountPinView extends React.PureComponent {
await accounts.save(accounts.getSelectedKey(), account, pin);
const resetAction = StackActions.reset({
actions: [
NavigationActions.navigate({ routeName: 'LegacyAccountList' }),
NavigationActions.navigate({ routeName: 'AccountList' }),
NavigationActions.navigate({ routeName: 'AccountDetails' })
],
index: 1, // FIXME workaround for now, use SwitchNavigator later: https://github.com/react-navigation/react-navigation/issues/1127#issuecomment-295841343
......
......@@ -50,9 +50,7 @@ export class AccountUnlockAndSign extends React.PureComponent {
navigate={() => {
const resetAction = StackActions.reset({
actions: [
NavigationActions.navigate({
routeName: 'LegacyAccountList'
}),
NavigationActions.navigate({ routeName: 'AccountList' }),
NavigationActions.navigate({ routeName: next })
],
index: 1, // FIXME workaround for now, use SwitchNavigator later: https://github.com/react-navigation/react-navigation/issues/1127#issuecomment-295841343
......@@ -70,7 +68,7 @@ export class AccountUnlockAndSign extends React.PureComponent {
export class AccountUnlock extends React.Component {
render() {
const { navigation } = this.props;
const next = navigation.getParam('next', 'LegacyAccountList');
const next = navigation.getParam('next', 'AccountList');
return (
<Subscribe to={[AccountsStore]}>
......@@ -90,9 +88,7 @@ export class AccountUnlock extends React.Component {
} else {
const resetAction = StackActions.reset({
actions: [
NavigationActions.navigate({
routeName: 'LegacyAccountList'
}),
NavigationActions.navigate({ routeName: 'AccountList' }),
NavigationActions.navigate({ routeName: 'AccountDetails' }),
NavigationActions.navigate({ routeName: next })
],
......
......@@ -33,8 +33,7 @@ import {
import { alertIdentityCreationError } from '../util/alertUtils';
function IdentityNew({ accounts, navigation }) {
const isRecoverDefaultValue = navigation.getParam('isRecover', false);
const [isRecover, setIsRecover] = useState(isRecoverDefaultValue);
const [isRecover, setIsRecover] = useState(false);
const [seedPhrase, setSeedPhrase] = useState('');
useEffect(() => {
......
......@@ -51,7 +51,7 @@ function IdentityPin({ navigation, accounts }) {
// await accounts.save(accounts.getSelectedKey(), account, pin);
// const resetAction = StackActions.reset({
// actions: [
// NavigationActions.navigate({ routeName: 'LegacyAccountList' }),
// NavigationActions.navigate({ routeName: 'AccountList' }),
// NavigationActions.navigate({ routeName: 'AccountDetails' })
// ],
// index: 1, // FIXME workaround for now, use SwitchNavigator later: https://github.com/react-navigation/react-navigation/issues/1127#issuecomment-295841343
......
......@@ -18,7 +18,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import { FlatList, StyleSheet, View } from 'react-native';
import { FlatList, StyleSheet, Text, View } from 'react-native';
import { Subscribe } from 'unstated';
import colors from '../colors';
......@@ -37,7 +37,7 @@ export default class LegacyAccountList extends React.PureComponent {
return (
<AccountListView
{...this.props}
accounts={accounts.getAccounts()}
accounts={accounts.getLegacySubstrateAccounts()}
onAccountSelected={key => {
accounts.select(key);
this.props.navigation.navigate('AccountDetails');
......@@ -60,19 +60,40 @@ class AccountListView extends React.PureComponent {
super(props);
}
showOnboardingMessage = () => {
const { navigate } = this.props.navigation;
const createLink = (text, navigation) => (
<Text style={styles.link} onPress={() => navigate(navigation)}>
{text}
</Text>
);
return (
<View style={styles.onboardingWrapper}>
<Text style={styles.onboardingText}>
No account yet?{'\n'}
{createLink('Create', 'AccountNew')} or{' '}
{createLink('recover', 'AccountRecover')} an account to get started.
</Text>
</View>
);
};
render() {
const { accounts, navigation, onAccountSelected } = this.props;
const hasNoAccount = accounts.length < 1;
const { navigate } = navigation;
return (
<View style={styles.body} testID={testIDs.AccountListScreen.accountList}>
<Background />
{hasNoAccount && this.showOnboardingMessage()}
<FlatList
ref={list => {
this.list = list;
}}
style={styles.content}
data={Array.from(accounts.entries())}
data={accounts}
keyExtractor={([key]) => key}
renderItem={({ item: [accountKey, account] }) => {
return (
......@@ -89,13 +110,15 @@ class AccountListView extends React.PureComponent {
}}
enableEmptySections
/>
<View style={styles.bottom}>
<Button
buttonStyles={{ height: 60 }}
title="Scan"
onPress={() => navigate('QrScanner')}
/>
</View>
{!hasNoAccount && (
<View style={styles.bottom}>
<Button
buttonStyles={{ height: 60 }}
title="Scan"
onPress={() => navigate('QrScanner')}
/>
</View>
)}
</View>
);
}
......@@ -125,6 +148,16 @@ const styles = StyleSheet.create({
alignItems: 'flex-end',
flex: 1
},
onboardingText: {
color: colors.bg_text_sec,
fontFamily: fonts.regular,
fontSize: 20
},
onboardingWrapper: {
alignItems: 'flex-end',
flex: 1,
flexDirection: 'row'
},
title: {
color: colors.bg_text_sec,
flexDirection: 'column',
......
......@@ -51,7 +51,6 @@ export default class AccountsStore extends Container<AccountsStoreState> {
accounts: new Map(),
currentIdentity: null,
identities: [],
loaded: false,
newAccount: emptyAccount(),
newIdentity: emptyIdentity(),
selectedKey: ''
......@@ -135,9 +134,7 @@ export default class AccountsStore extends Container<AccountsStoreState> {
async refreshList() {
const accounts = await loadAccounts();
const identities = await loadIdentities();
let { currentIdentity } = this.state;
if (identities.length > 0) currentIdentity = identities[0];
this.setState({ accounts, currentIdentity, identities, loaded: true });
this.setState({ accounts, identities });
}
async encryptSeedPhraseAndLockAccount(account, pin = null) {
......
......@@ -44,7 +44,7 @@ export const navigateToNewIdentityNetwork = navigation => {
export const navigateToLegacyAccountList = navigation => {
const resetAction = StackActions.reset({
actions: [NavigationActions.navigate({ routeName: 'LegacyAccountList' })],
actions: [NavigationActions.navigate({ routeName: 'AccountList' })],
index: 0, // FIXME workaround for now, use SwitchNavigator later: https://github.com/react-navigation/react-navigation/issues/1127#issuecomment-295841343
key: undefined
});
......
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