Skip to content

Commit

Permalink
Setup wallet if there are no keys (#131)
Browse files Browse the repository at this point in the history
* Move the MenuIcon into the icons folder and expand it to allow different colors and sizes.

* Change the default screen if there are no keys

- Hide header and footer if there are no keys
- Pass hasKeys to RootNavigation
- Move loading wheel until after the keys have loaded.
  • Loading branch information
jessgusclark authored Jan 31, 2022
1 parent 2be5ef5 commit bb0ca5d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
12 changes: 8 additions & 4 deletions src/RootNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type ScreenProps<T extends keyof RootStackParamList> = StackScreenProps<

export const RootNavigation: React.FC<{
currentScreen: string
hasKeys: boolean
rifWalletServicesSocket: IRifWalletServicesSocket
keyManagementProps: CreateKeysProps
balancesScreenProps: BalancesScreenProps
Expand All @@ -89,6 +90,7 @@ export const RootNavigation: React.FC<{
dappsScreenProps: DappsScreenScreenProps
}> = ({
currentScreen,
hasKeys,
keyManagementProps,
balancesScreenProps,
activityScreenProps,
Expand All @@ -100,8 +102,8 @@ export const RootNavigation: React.FC<{
}) => {
return (
<View style={styles.parent}>
<AppHeader />
<RootStack.Navigator>
{hasKeys && <AppHeader />}
<RootStack.Navigator initialRouteName={hasKeys ? 'Home' : 'CreateKeysUX'}>
<RootStack.Screen
name="Home"
component={Screens.HomeScreen}
Expand All @@ -127,7 +129,9 @@ export const RootNavigation: React.FC<{
options={{ ...sharedOptions, headerShown: false }}
/>

<RootStack.Screen name="CreateKeysUX" options={sharedOptions}>
<RootStack.Screen
name="CreateKeysUX"
options={{ ...sharedOptions, headerShown: false }}>
{props => <CreateKeysNavigation {...props} {...keyManagementProps} />}
</RootStack.Screen>
<RootStack.Screen
Expand Down Expand Up @@ -236,7 +240,7 @@ export const RootNavigation: React.FC<{
)}
</RootStack.Screen>
</RootStack.Navigator>
<AppFooterMenu currentScreen={currentScreen} />
{hasKeys && <AppFooterMenu currentScreen={currentScreen} />}
</View>
)
}
Expand Down
39 changes: 39 additions & 0 deletions src/components/icons/MenuIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as React from 'react'
import Svg, { Line } from 'react-native-svg'
import { SVGIconInterface } from '.'

export const MenuIcon: React.FC<SVGIconInterface> = ({
width,
height,
color,
}) => (
<Svg
width={width || '18.727'}
height={height || 18.735}
viewBox="0 0 18.727 18.735">
<Line
x1="0"
y1="0.5"
x2="17"
y2="0.5"
stroke={color || '#707070'}
strokeWidth="2"
/>
<Line
x1="0"
y1="12.5"
x2="17"
y2="12.5"
stroke={color || '#707070'}
strokeWidth="2"
/>
<Line
x1="0"
y1="6.5"
x2="17"
y2="6.5"
stroke={color || '#707070'}
strokeWidth="2"
/>
</Svg>
)
6 changes: 5 additions & 1 deletion src/core/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,13 @@ export const Core = () => {
})
}, [])

if (state.loading) {
return <LoadingScreen reason="Getting things setup" />
}

return (
<SafeAreaView>
<StatusBar />
{state.loading && <LoadingScreen reason="Please wait..." />}
{!active && <Cover />}
{state.hasKeys && !unlocked && <RequestPIN unlock={unlockApp} />}
<AppContext.Provider
Expand All @@ -173,6 +176,7 @@ export const Core = () => {
abiEnhancer={abiEnhancer}>
<RootNavigation
currentScreen={currentScreen}
hasKeys={state.hasKeys}
rifWalletServicesSocket={rifWalletServicesSocket}
keyManagementProps={{
generateMnemonic: () => KeyManagementSystem.create().mnemonic,
Expand Down
10 changes: 0 additions & 10 deletions src/ux/appHeader/MenuIcon.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/ux/appHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native'
import { AddressCopyComponent } from '../../components/copy/AddressCopyComponent'
import { useSelectedWallet } from '../../Context'
import MenuIcon from './MenuIcon'
import { Network } from '@ethersproject/networks'
import { MenuIcon } from '../../components/icons/MenuIcon'

export const networks: Record<number, Network> = {
30: {
Expand Down

0 comments on commit bb0ca5d

Please sign in to comment.