Skip to content

Commit

Permalink
Us 711/accounts scr (#236)
Browse files Browse the repository at this point in the history
* Added settings screen per US 707 design
Added 3 provisional icons until we get the correct icons approved by UX.

* Added todos

* Added accounts screen

* Added edit material icon

* Added key to arr

* Fixed RootNavigation.tsx issue by adding screensettingsprops and removing unused props

* Fixed ESLINT issue in SettingsScreen.tsx

* Updated secondary button and active button with requested changes fro… (#238)

* Updated secondary button and active button with requested changes from UX
Text will be blue-ish

* It's actually lightSteelBlue which has to be added to the guidelines :)

* Increased paddingVertical to match UI/UX design

Co-authored-by: Francis Rodriguez <[email protected]>

* Added settings screen per US 707 design (#229)

* Added settings screen per US 707 design
Added 3 provisional icons until we get the correct icons approved by UX.

* Added todos

* Reduced icons size

Co-authored-by: Francis Rodriguez <[email protected]>

* Change android workflow to only creat the build on merge, not on PR. (#239)

* Add loading screen while the app is being setup (#234)

* Update the style of the loading screen.

* Change the loading screen to a modal show it will cover 100%.

* Move loading screen out of core and into /components.

* Have two loading stages, one for loading keys from storage and a second loading balances from the service.

* Add reset action to state and call it when the user changes selected wallet.

* Added accounts screen

* Fixed ESLINT issue in SettingsScreen.tsx

* Fixed ESLINT issue in SettingsScreen.tsx

* Added accounts screen back

* Made the requested changes for the account screen.

* Add new account logic added
Removed ManageWalletsScreen.tsx
Added props and types for account screen
Modified styles to match the design

* Removed edit icon from account box
Changed from scrollview to flatlist
Fixed an issue that the state was not being udpated -> object assign should not be used. Spread operator should.
Removed a few things that should not be used in root navigator.

* Added viewbox to copy icon
copy field will now have an optional viewbox prop
used viewbox in account box to reduce icon size and align it perfectly with the font size

* Merged branch develop and resolved conflicts

Co-authored-by: Francis Rodriguez <[email protected]>
Co-authored-by: Jesse Clark <[email protected]>
  • Loading branch information
3 people authored Jul 6, 2022
1 parent b62c9d8 commit 83c6244
Show file tree
Hide file tree
Showing 12 changed files with 247 additions and 100 deletions.
30 changes: 14 additions & 16 deletions src/RootNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { AppFooterMenu } from './ux/appFooter'
import { EditContactScreenProps } from './screens/contacts/EditContactScreen'
import { DappsScreenScreenProps } from './screens/dapps'
import { IRifWalletServicesSocket } from './lib/rifWalletServices/RifWalletServicesSocket'
import { ManagerWalletScreenProps } from './screens/settings/ManageWalletsScreen'
import { colors } from './styles/colors'
import { colors } from './styles'
import { AccountsScreenType } from './screens/accounts/AccountsScreen'
import { SecurityScreenProps } from './screens/security/SecurityConfigurationScreen'

const InjectedScreens = {
Expand All @@ -47,7 +47,7 @@ const InjectedScreens = {
RegisterDomainScreen: InjectSelectedWallet(Screens.RegisterDomainScreen),
HomeScreen: InjectSelectedWallet(Screens.HomeScreen),
DappsScreen: InjectSelectedWallet(Screens.DappsScreen),
ManageWalletsScreen: InjectSelectedWallet(Screens.ManageWalletsScreen),
AccountsScreen: InjectSelectedWallet(Screens.AccountsScreen),
}

type RootStackParamList = {
Expand Down Expand Up @@ -81,8 +81,8 @@ type RootStackParamList = {
RegisterDomain: { selectedDomain: string; years: number }
Contacts: undefined
Settings: undefined
ManageWallets: undefined
EventsScreen: undefined
AccountsScreen: undefined
SecurityConfigurationScreen: undefined
ChangePinScreen: undefined
}
Expand Down Expand Up @@ -118,7 +118,7 @@ export const RootNavigation: React.FC<{
injectedBrowserUXScreenProps: InjectedBrowserUXScreenProps
contactsNavigationScreenProps: EditContactScreenProps
dappsScreenProps: DappsScreenScreenProps
manageWalletScreenProps: ManagerWalletScreenProps
accountsScreenType: AccountsScreenType
securityConfigurationScreenProps: SecurityScreenProps
}> = ({
currentScreen,
Expand All @@ -135,7 +135,7 @@ export const RootNavigation: React.FC<{
injectedBrowserUXScreenProps,
contactsNavigationScreenProps,
dappsScreenProps,
manageWalletScreenProps,
accountsScreenType,
securityConfigurationScreenProps,
}) => {
let initialRoute: any = 'CreateKeysUX'
Expand Down Expand Up @@ -195,16 +195,6 @@ export const RootNavigation: React.FC<{
<RootStack.Screen name="Settings" options={sharedOptions}>
{props => <Screens.SettingsScreen {...props} />}
</RootStack.Screen>

<RootStack.Screen name="ManageWallets" options={sharedOptions}>
{props => (
<InjectedScreens.ManageWalletsScreen
{...props}
{...manageWalletScreenProps}
/>
)}
</RootStack.Screen>

<RootStack.Screen name="CreateKeysUX" options={sharedOptions}>
{props => (
<CreateKeysNavigation
Expand Down Expand Up @@ -267,6 +257,14 @@ export const RootNavigation: React.FC<{
component={InjectedScreens.ManuallyDeployScreen}
options={sharedOptions}
/>
<RootStack.Screen name="AccountsScreen" options={sharedOptions}>
{props => (
<InjectedScreens.AccountsScreen
{...props}
{...accountsScreenType}
/>
)}
</RootStack.Screen>
<RootStack.Screen name="KeysInfo" options={sharedOptions}>
{props => (
<Screens.KeysInfoScreen {...props} {...keysInfoScreenProps} />
Expand Down
107 changes: 107 additions & 0 deletions src/components/accounts/AccountBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React, { useState, useEffect } from 'react'
import { StyleSheet, View } from 'react-native'
import { MediumText } from '../typography'
import CopyField from '../activity/CopyField'
import { colors } from '../../styles'
import { SmartWalletFactory } from '../../lib/core/SmartWalletFactory'
// import EditMaterialIcon from '../icons/EditMaterialIcon'

type AccountBoxProps = {
address: string
addressShort: string
smartWalletAddress: string
smartWalletAddressShort: string
smartWalletFactory: SmartWalletFactory
id?: number
}

const MediumTextStyleOverride: React.FC<{ children: React.ReactNode }> = ({
children,
}) => <MediumText style={styles.mediumTextOverride}>{children}</MediumText>

const AccountBox: React.FC<AccountBoxProps> = ({
address,
addressShort,
smartWalletAddress,
smartWalletAddressShort,
smartWalletFactory,
id = 0,
}) => {
const [isDeployed, setIsDeployed] = useState(false)
useEffect(() => {
smartWalletFactory.isDeployed().then(result => setIsDeployed(result))
}, [])
return (
<View style={styles.accountsContainer}>
<View style={styles.textContainer}>
{/* @TODO implement account naming - will use id for now */}
<MediumText style={styles.text}>account {id + 1}</MediumText>
{/*<EditMaterialIcon style={styles.icon} size={11} />*/}
</View>
<View style={styles.infoSection}>
<MediumText style={styles.titleFontSize}>Status</MediumText>
<MediumText style={styles.titleFontSize}>
{isDeployed ? 'Deployed' : 'Not Deployed'}
</MediumText>
</View>
<View style={styles.infoSection}>
<MediumText style={styles.addressText}>EOA Address</MediumText>
<CopyField
text={addressShort}
textToCopy={address}
TextComp={MediumTextStyleOverride}
iconSize={20}
iconViewBox="0 0 25 25"
/>
</View>
<View>
<MediumText style={styles.addressText}>Smart Wallet Address</MediumText>
<CopyField
text={smartWalletAddressShort}
textToCopy={smartWalletAddress}
TextComp={MediumTextStyleOverride}
iconSize={20}
iconViewBox="0 0 25 25"
/>
</View>
</View>
)
}

const styles = StyleSheet.create({
accountsContainer: {
backgroundColor: colors.background.light,
paddingHorizontal: 24,
paddingVertical: 38,
borderRadius: 30,
},
textContainer: {
justifyContent: 'flex-end',
alignItems: 'center',
flexDirection: 'row',
},
text: {
fontSize: 20,
},
icon: {
marginLeft: 10,
borderWidth: 1,
borderRadius: 1,
},
infoSection: {
marginBottom: 20,
},
addressText: {
marginBottom: 3,
fontSize: 13,
},
titleFontSize: {
fontSize: 13,
},
mediumTextOverride: {
fontSize: 13,
flex: 90,
},
})

export default AccountBox
27 changes: 27 additions & 0 deletions src/components/accounts/AddAccountBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { StyleSheet, TouchableOpacity } from 'react-native'
import { RegularText } from '../typography'
import { colors } from '../../styles'

const AddAccountBox: React.FC<{ addNewWallet: any }> = ({ addNewWallet }) => {
return (
<TouchableOpacity style={styles.accountBoxContainer} onPress={addNewWallet}>
<RegularText style={styles.accountText}>+</RegularText>
</TouchableOpacity>
)
}

const styles = StyleSheet.create({
accountBoxContainer: {
backgroundColor: colors.background.purple,
height: 160,
borderRadius: 30,
justifyContent: 'center',
alignItems: 'center',
},
accountText: {
color: 'white',
fontSize: 60,
},
})
export default AddAccountBox
11 changes: 10 additions & 1 deletion src/components/activity/CopyField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ type ICopyField = {
text: string
textToCopy?: string | undefined
TextComp?: any
iconSize?: number
iconViewBox?: string
}

const CopyField: React.FC<ICopyField> = ({
text,
textToCopy = undefined,
TextComp = Text,
iconSize = 25,
iconViewBox = undefined,
}) => {
const onCopy = (): null => {
Clipboard.setString(textToCopy || text)
Expand All @@ -23,7 +27,12 @@ const CopyField: React.FC<ICopyField> = ({
<View style={styles.container}>
<TextComp style={styles.text}>{text}</TextComp>
<View style={styles.iconView}>
<CopyIcon width={25} height={25} color="black" />
<CopyIcon
width={iconSize}
height={iconSize}
color="black"
viewBox={iconViewBox}
/>
</View>
</View>
</TouchableOpacity>
Expand Down
5 changes: 3 additions & 2 deletions src/components/icons/CopyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import React from 'react'
import Svg, { Path } from 'react-native-svg'
import { SVGIconInterface } from '.'

export const CopyIcon: React.FC<SVGIconInterface> = ({
export const CopyIcon: React.FC<SVGIconInterface & { viewBox?: string }> = ({
width,
height,
color,
viewBox = undefined,
}) => (
<Svg width={width || '25'} height={height || '25'}>
<Svg width={width || '25'} height={height || '25'} viewBox={viewBox}>
<Path
d="M7.8 3.1H7C5.4 3 4 4.3 4 5.9v6.9c0 1.6 1.4 2.9 3 2.8h7.5c1.6.1 3-1.2 3.1-2.8V5.9c-.1-1.6-1.4-2.9-3.1-2.8H7.8"
transform="translate(-244.719 -550.704) translate(244.719 550.704)"
Expand Down
9 changes: 9 additions & 0 deletions src/components/icons/EditMaterialIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
import React from 'react'
import { MaterialIconInterface } from '.'

const EditMaterialIcon = (props?: MaterialIconInterface) => (
<MaterialIcon name="edit" {...props} />
)

export default EditMaterialIcon
20 changes: 11 additions & 9 deletions src/core/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { RequestPIN } from './components/RequestPIN'
import { WalletConnectProviderElement } from '../screens/walletConnect/WalletConnectContext'
import { RIFSocketsProvider } from '../subscriptions/RIFSockets'
import { NavigationContainer, NavigationState } from '@react-navigation/native'
import { colors } from '../styles/colors'
import { colors } from '../styles'
import { deletePin, savePin } from '../storage/PinStore'
import { deleteContacts } from '../storage/ContactsStore'
import { deleteDomains } from '../storage/DomainsStore'
Expand Down Expand Up @@ -151,15 +151,17 @@ const useKeyManagementSystem = (onRequest: OnRequest) => {
}

return addNextWallet(state.kms, createRIFWallet, networkId).then(response =>
setState({
...state,
wallets: Object.assign(state.wallets, {
setState(oldState => ({
...oldState,
wallets: {
...oldState.wallets,
[response.rifWallet.address]: response.rifWallet,
}),
walletsIsDeployed: Object.assign(state.walletsIsDeployed, {
},
walletsIsDeployed: {
...oldState.walletsIsDeployed,
[response.rifWallet.address]: response.isDeloyed,
}),
}),
},
})),
)
}

Expand Down Expand Up @@ -327,7 +329,7 @@ export const Core = () => {
}}
contactsNavigationScreenProps={{ rnsResolver }}
dappsScreenProps={{ fetcher: rifWalletServicesFetcher }}
manageWalletScreenProps={{
accountsScreenType={{
addNewWallet,
switchActiveWallet,
}}
Expand Down
55 changes: 55 additions & 0 deletions src/screens/accounts/AccountsScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useContext } from 'react'
import { StyleSheet, View, FlatList } from 'react-native'
import { colors } from '../../styles'
import { AppContext } from '../../Context'
import { shortAddress } from '../../lib/utils'
import AddAccountBox from '../../components/accounts/AddAccountBox'
import AccountBox from '../../components/accounts/AccountBox'

export type AccountsScreenType = {
addNewWallet: any
switchActiveWallet?: any
}

const AccountsScreen: React.FC<AccountsScreenType> = ({ addNewWallet }) => {
const { wallets } = useContext(AppContext)
const walletsArr = React.useMemo(() => {
return Object.keys(wallets).map((key, id) => ({
...wallets[key],
address: key,
addressShort: shortAddress(key, 8),
smartWalletAddress: wallets[key].smartWalletAddress,
smartWalletAddressShort: shortAddress(wallets[key].smartWalletAddress, 8),
id,
}))
}, [wallets])
return (
<FlatList
data={walletsArr}
initialNumToRender={10}
keyExtractor={item => item.id.toString()}
renderItem={({ item }) => <AccountBox {...item} />}
style={styles.container}
ListFooterComponent={() => <AddAccountBox addNewWallet={addNewWallet} />}
ItemSeparatorComponent={() => <View style={styles.walletView} />}
ListFooterComponentStyle={styles.viewBottomFix}
/>
)
}

const styles = StyleSheet.create({
container: {
backgroundColor: colors.background.blue,
paddingHorizontal: 40,
paddingTop: '8%',
},
viewBottomFix: {
marginTop: 40,
marginBottom: 150,
},
walletView: {
marginBottom: 40,
},
})

export default AccountsScreen
2 changes: 1 addition & 1 deletion src/screens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export { HomeScreen } from './home/index'
export { DappsScreen } from './dapps/index'
export { ContactsNavigationScreen } from './contacts/index'
export { SettingsScreen } from './settings/SettingsScreen'
export { ManageWalletsScreen } from './settings/ManageWalletsScreen'
export { EventsScreenHOC as EventsScreen } from './events'
export { default as SecurityConfigurationScreen } from './security/SecurityConfigurationScreen'
export { default as ChangePinScreen } from './changePin/ChangePinScreen'
export { default as AccountsScreen } from './accounts/AccountsScreen'
Loading

0 comments on commit 83c6244

Please sign in to comment.