Skip to content

Commit 83340db

Browse files
Add screens to routes file and display balances
1 parent abdca4f commit 83340db

File tree

7 files changed

+107
-16
lines changed

7 files changed

+107
-16
lines changed

client/src/components/home/Balances.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@ import { useAppSelector } from '../../redux/store';
44
import { getBalance } from '../../utils/balances';
55
import tokenlist from '../../data/tokenlist.json';
66

7+
type Balances = Record<string, string>;
8+
79
const Balances = () => {
10+
const [loading, setLoading] = React.useState(true);
11+
const [balances, setBalances] = React.useState<Balances>({});
812
const walletAddress = useAppSelector(({ wallet }) => wallet.address);
913

1014
const fetchData = React.useCallback(async () => {
1115
if (walletAddress) {
12-
const data = await Promise.all(
13-
tokenlist.map(async token => {
14-
return await getBalance(token.address, walletAddress);
15-
})
16-
);
16+
const balanceData: Balances = {};
17+
18+
for (const token of tokenlist) {
19+
// TODO: Use a batch call for this
20+
balanceData[token.address] = await getBalance(
21+
token.address,
22+
walletAddress
23+
);
24+
}
1725

18-
console.log(data);
26+
setBalances(balanceData);
27+
setLoading(false);
1928
}
2029
}, []);
2130

@@ -26,6 +35,7 @@ const Balances = () => {
2635
return (
2736
<View style={styles.container}>
2837
<Text>Balances</Text>
38+
<Text>{loading ? 'Loading...' : JSON.stringify(balances)}</Text>
2939
</View>
3040
);
3141
};

client/src/navigation/Routes.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Transactions from '../screens/Transactions';
1111
import New from '../screens/New';
1212
import Preferences from '../screens/Preferences';
1313
import Onboarding from '../screens/Onboarding';
14+
import SplitPayment from '../screens/SplitPayment';
15+
import Subscriptions from '../screens/Subscriptions';
1416
import { useAppSelector } from '../redux/store';
1517

1618
const AppStack = createStackNavigator<AppStackParamList>();
@@ -26,6 +28,8 @@ const Routes = () => {
2628
<AppStack.Screen name='Contacts' component={Contacts} />
2729
<AppStack.Screen name='Settings' component={Settings} />
2830
<AppStack.Screen name='SendAmount' component={SendAmount} />
31+
<AppStack.Screen name='SplitPayment' component={SplitPayment} />
32+
<AppStack.Screen name='Subscriptions' component={Subscriptions} />
2933
<AppStack.Screen name='AddContact' component={AddContact} />
3034
<AppStack.Screen name='Transactions' component={Transactions} />
3135
<AppStack.Screen name='New' component={New} />

client/src/screens/New.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { View } from 'react-native';
2+
import { SafeAreaView } from 'react-native-safe-area-context';
33
import { NavigationProp, useNavigation } from '@react-navigation/core';
44
import { AppStackParamList } from '../types/navigation';
55
import NewSection from '../components/new/NewSection';
@@ -22,13 +22,13 @@ const kinds: Kind[] = [
2222
},
2323
{
2424
title: 'Split Payment',
25-
description: 'Split a bill with one or more people.',
25+
description: 'Split payments with one or more people.',
2626
destination: 'SplitPayment'
2727
},
2828
{
29-
title: 'Subscription',
30-
description: 'Pay someone a fixed amount every fixed interval.',
31-
destination: 'Subscription'
29+
title: 'Subscriptions',
30+
description: 'Manage existing subscriptions or create new ones.',
31+
destination: 'Subscriptions'
3232
}
3333
];
3434

@@ -43,7 +43,7 @@ const New = () => {
4343
);
4444

4545
return (
46-
<View style={{ flex: 1 }}>
46+
<SafeAreaView style={{ flex: 1 }}>
4747
{kinds.map(k => (
4848
<NewSection
4949
key={k.title}
@@ -52,7 +52,7 @@ const New = () => {
5252
onPress={() => moveToDestination(k.destination)}
5353
/>
5454
))}
55-
</View>
55+
</SafeAreaView>
5656
);
5757
};
5858

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { StyleSheet } from 'react-native';
3+
import { SafeAreaView } from 'react-native-safe-area-context';
4+
5+
const Subscriptions = () => {
6+
return <SafeAreaView style={styles.container}></SafeAreaView>;
7+
};
8+
9+
const styles = StyleSheet.create({
10+
container: {
11+
flex: 1
12+
}
13+
});
14+
15+
export default Subscriptions;

client/src/types/navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type AppStackParamList = {
88
Transactions: undefined;
99
New: undefined;
1010
SplitPayment: undefined;
11-
Subscription: undefined;
11+
Subscriptions: undefined;
1212
Preferences: undefined;
1313
Onboarding: undefined;
1414
};

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"prettier --write"
1515
]
1616
},
17-
"dependencies": {},
17+
"dependencies": {
18+
"@gorhom/bottom-sheet": "^4"
19+
},
1820
"devDependencies": {
1921
"@typescript-eslint/eslint-plugin": "^4.24.0",
2022
"@typescript-eslint/parser": "^4.24.0",

yarn.lock

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@
6060
minimatch "^3.0.4"
6161
strip-json-comments "^3.1.1"
6262

63+
"@gorhom/bottom-sheet@^4":
64+
version "4.1.4"
65+
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-4.1.4.tgz#35c401ee94ea7d7440eaf3fed98c044f221184fc"
66+
integrity sha512-e8GXz96HfcSqWc+3CYzyTkb2xb3SgynK81K8Z0sd1ExXVMAC+FaLcWf8XRFL4pzJkqgQR+R3JEgHWOJSzwe4EQ==
67+
dependencies:
68+
"@gorhom/portal" "^1.0.11"
69+
invariant "^2.2.4"
70+
nanoid "^3.1.20"
71+
react-native-redash "^16.1.1"
72+
73+
"@gorhom/portal@^1.0.11":
74+
version "1.0.11"
75+
resolved "https://registry.yarnpkg.com/@gorhom/portal/-/portal-1.0.11.tgz#4224d45fea25e70d7e55af3b67249bad0ac9359b"
76+
integrity sha512-Vrh2hAVp8ZToJ1a1NbYnehNzdJTxJv1BF3vMNbz1pnJIqm0nbi2W51piVvfiqohCDAegOyCCH1j/AEhW2cJYTA==
77+
dependencies:
78+
nanoid "^3.1.23"
79+
6380
"@nodelib/fs.scandir@2.1.4":
6481
version "2.1.4"
6582
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
@@ -166,6 +183,11 @@
166183
"@typescript-eslint/types" "4.24.0"
167184
eslint-visitor-keys "^2.0.0"
168185

186+
abs-svg-path@^0.1.1:
187+
version "0.1.1"
188+
resolved "https://registry.yarnpkg.com/abs-svg-path/-/abs-svg-path-0.1.1.tgz#df601c8e8d2ba10d4a76d625e236a9a39c2723bf"
189+
integrity sha1-32Acjo0roQ1KdtYl4japo5wnI78=
190+
169191
acorn-jsx@^5.3.1:
170192
version "5.3.1"
171193
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b"
@@ -1019,6 +1041,13 @@ internal-slot@^1.0.3:
10191041
has "^1.0.3"
10201042
side-channel "^1.0.4"
10211043

1044+
invariant@^2.2.4:
1045+
version "2.2.4"
1046+
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
1047+
integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==
1048+
dependencies:
1049+
loose-envify "^1.0.0"
1050+
10221051
is-arrayish@^0.2.1:
10231052
version "0.2.1"
10241053
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
@@ -1300,7 +1329,7 @@ log-update@^4.0.0:
13001329
slice-ansi "^4.0.0"
13011330
wrap-ansi "^6.2.0"
13021331

1303-
loose-envify@^1.4.0:
1332+
loose-envify@^1.0.0, loose-envify@^1.4.0:
13041333
version "1.4.0"
13051334
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
13061335
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
@@ -1364,6 +1393,11 @@ ms@^2.1.1:
13641393
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
13651394
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
13661395

1396+
nanoid@^3.1.20, nanoid@^3.1.23:
1397+
version "3.1.30"
1398+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.30.tgz#63f93cc548d2a113dc5dfbc63bfa09e2b9b64362"
1399+
integrity sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==
1400+
13671401
natural-compare@^1.4.0:
13681402
version "1.4.0"
13691403
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@@ -1384,6 +1418,13 @@ normalize-path@^3.0.0:
13841418
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
13851419
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
13861420

1421+
normalize-svg-path@^1.0.1:
1422+
version "1.1.0"
1423+
resolved "https://registry.yarnpkg.com/normalize-svg-path/-/normalize-svg-path-1.1.0.tgz#0e614eca23c39f0cffe821d6be6cd17e569a766c"
1424+
integrity sha512-r9KHKG2UUeB5LoTouwDzBy2VxXlHsiM6fyLQvnJa0S5hrhzqElH/CH7TUGhT1fVvIYBIKf3OpY4YJ4CK+iaqHg==
1425+
dependencies:
1426+
svg-arc-to-cubic-bezier "^3.0.0"
1427+
13871428
npm-run-path@^4.0.1:
13881429
version "4.0.1"
13891430
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea"
@@ -1523,6 +1564,11 @@ parse-json@^5.0.0:
15231564
json-parse-even-better-errors "^2.3.0"
15241565
lines-and-columns "^1.1.6"
15251566

1567+
parse-svg-path@^0.1.2:
1568+
version "0.1.2"
1569+
resolved "https://registry.yarnpkg.com/parse-svg-path/-/parse-svg-path-0.1.2.tgz#7a7ec0d1eb06fa5325c7d3e009b859a09b5d49eb"
1570+
integrity sha1-en7A0esG+lMlx9PgCbhZoJtdSes=
1571+
15261572
path-exists@^3.0.0:
15271573
version "3.0.0"
15281574
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
@@ -1625,6 +1671,15 @@ react-is@^16.8.1:
16251671
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
16261672
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
16271673

1674+
react-native-redash@^16.1.1:
1675+
version "16.2.3"
1676+
resolved "https://registry.yarnpkg.com/react-native-redash/-/react-native-redash-16.2.3.tgz#ee63e100c60f83275116e57d4e8bc79f26349db9"
1677+
integrity sha512-vSjHA6/mBY3IpDYPish3DlG06PKNLkb/b89hw7nsDM3yxAJ7Db+yMnEL3pp2YsoYblDc3s+0+wBRlvxay4X4vQ==
1678+
dependencies:
1679+
abs-svg-path "^0.1.1"
1680+
normalize-svg-path "^1.0.1"
1681+
parse-svg-path "^0.1.2"
1682+
16281683
read-pkg-up@^3.0.0:
16291684
version "3.0.0"
16301685
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07"
@@ -1905,6 +1960,11 @@ supports-color@^7.1.0:
19051960
dependencies:
19061961
has-flag "^4.0.0"
19071962

1963+
svg-arc-to-cubic-bezier@^3.0.0:
1964+
version "3.2.0"
1965+
resolved "https://registry.yarnpkg.com/svg-arc-to-cubic-bezier/-/svg-arc-to-cubic-bezier-3.2.0.tgz#390c450035ae1c4a0104d90650304c3bc814abe6"
1966+
integrity sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g==
1967+
19081968
table@^6.0.9:
19091969
version "6.7.1"
19101970
resolved "https://registry.yarnpkg.com/table/-/table-6.7.1.tgz#ee05592b7143831a8c94f3cee6aae4c1ccef33e2"

0 commit comments

Comments
 (0)