Skip to content

Commit 2594424

Browse files
authored
Native: earn screens (#1617)
1 parent 18d55ee commit 2594424

File tree

9 files changed

+64
-21
lines changed

9 files changed

+64
-21
lines changed

apps/expo/app/earn/[asset]/balance.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { Stack } from 'expo-router/build/layouts/Stack'
2+
import { SendEarnProvider } from 'app/features/earn/providers/SendEarnProvider'
3+
import { EarningsBalance } from 'app/features/earn/earnings/screen'
24
import { ScreenContainer } from 'apps-expo/components/layout/ScreenContainer'
3-
import { Paragraph } from '@my/ui'
45

56
export default function BalanceAssetSavingsScreen() {
67
return (
78
<>
89
<Stack.Screen
910
options={{
10-
title: 'Savings Balance',
11+
title: 'Balance',
1112
}}
1213
/>
1314
<ScreenContainer>
14-
<Paragraph>BalanceAssetSavingsScreen</Paragraph>
15+
<SendEarnProvider>
16+
<EarningsBalance />
17+
</SendEarnProvider>
1518
</ScreenContainer>
1619
</>
1720
)

apps/expo/app/earn/[asset]/deposit.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { Stack } from 'expo-router/build/layouts/Stack'
22
import { ScreenContainer } from 'apps-expo/components/layout/ScreenContainer'
3-
import { Paragraph } from '@my/ui'
3+
import { DepositScreen } from 'app/features/earn/deposit/screen'
4+
import { SendEarnProvider } from 'app/features/earn/providers/SendEarnProvider'
45

56
export default function DepositAssetSavingsScreen() {
67
return (
78
<>
89
<Stack.Screen
910
options={{
10-
title: 'Start Saving',
11+
title: 'Deposit',
1112
}}
1213
/>
1314
<ScreenContainer>
14-
<Paragraph>DepositAssetSavingsScreen</Paragraph>
15+
<SendEarnProvider>
16+
<DepositScreen />
17+
</SendEarnProvider>
1518
</ScreenContainer>
1619
</>
1720
)

apps/expo/app/earn/[asset]/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { ScreenContainer } from 'apps-expo/components/layout/ScreenContainer'
22
import { Stack } from 'expo-router'
3-
import { Link, Paragraph } from '@my/ui'
3+
import { SendEarnProvider } from 'app/features/earn/providers/SendEarnProvider'
4+
import { ActiveEarningsScreen } from 'app/features/earn/active/screen'
45

56
export default function SavingsAssetScreen() {
67
return (
78
<>
89
<Stack.Screen
910
options={{
10-
title: 'Savings',
11+
title: 'Details',
1112
}}
1213
/>
1314
<ScreenContainer>
14-
<Paragraph>SavingsAssetScreen</Paragraph>
15-
<Link href={'/earn/usdc'}>crypto</Link>
15+
<SendEarnProvider>
16+
<ActiveEarningsScreen />
17+
</SendEarnProvider>
1618
</ScreenContainer>
1719
</>
1820
)

apps/expo/app/earn/[asset]/withdraw.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Stack } from 'expo-router/build/layouts/Stack'
22
import { ScreenContainer } from 'apps-expo/components/layout/ScreenContainer'
3-
import { Paragraph } from '@my/ui'
3+
import { SendEarnProvider } from 'app/features/earn/providers/SendEarnProvider'
4+
import { WithdrawForm } from 'app/features/earn/withdraw/screen'
45

56
export default function WithdrawAssetSavingsScreen() {
67
return (
@@ -11,7 +12,9 @@ export default function WithdrawAssetSavingsScreen() {
1112
}}
1213
/>
1314
<ScreenContainer>
14-
<Paragraph>WithdrawAssetSavingsScreen</Paragraph>
15+
<SendEarnProvider>
16+
<WithdrawForm />
17+
</SendEarnProvider>
1518
</ScreenContainer>
1619
</>
1720
)

apps/expo/app/earn/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ScreenContainer } from 'apps-expo/components/layout/ScreenContainer'
22
import { Stack } from 'expo-router'
3-
import { Link, Paragraph } from '@my/ui'
3+
import { SendEarnProvider } from 'app/features/earn/providers/SendEarnProvider'
4+
import { EarnScreen } from 'app/features/earn/screen'
45

56
export default function SavingsScreen() {
67
return (
@@ -11,10 +12,9 @@ export default function SavingsScreen() {
1112
}}
1213
/>
1314
<ScreenContainer>
14-
<Paragraph>SavingsScreen</Paragraph>
15-
<Link href={'/earn/usdc/balance'}>balance</Link>
16-
<Link href={'/earn/usdc/deposit'}>deposit</Link>
17-
<Link href={'/earn/usdc/withdraw'}>withdraw</Link>
15+
<SendEarnProvider>
16+
<EarnScreen />
17+
</SendEarnProvider>
1818
</ScreenContainer>
1919
</>
2020
)

apps/expo/metro.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ config.resolver.nodeModulesPaths = [
1616
path.resolve(workspaceRoot, 'node_modules'),
1717
]
1818

19+
// Add support for package.json exports field and fix module resolution issues
20+
config.resolver.resolverMainFields = ['react-native', 'browser', 'main']
21+
config.resolver.platforms = ['ios', 'android', 'native', 'web']
22+
23+
// Custom resolver to handle packages with exports field that Metro doesn't support properly
24+
config.resolver.resolveRequest = (context, moduleName, platform) => {
25+
if (moduleName === '@0xsend/send-earn-contracts') {
26+
return {
27+
filePath: path.resolve(
28+
workspaceRoot,
29+
'node_modules/@0xsend/send-earn-contracts/dist/index.js'
30+
),
31+
type: 'sourceFile',
32+
}
33+
}
34+
// Fall back to default resolver for all other modules
35+
return context.resolveRequest(context, moduleName, platform)
36+
}
37+
1938
config.transformer = { ...config.transformer, unstable_allowRequireContext: true }
2039
config.transformer.minifierPath = require.resolve('metro-minify-terser')
2140

packages/app/features/earn/deposit/screen.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
} from '../params'
4848
import { useSendEarnDepositCalls, useSendEarnDepositVault } from './hooks'
4949
import { useSendEarnAPY } from '../hooks'
50+
import { Platform } from 'react-native'
5051

5152
const log = debug('app:earn:deposit')
5253
const MINIMUM_DEPOSIT = BigInt(5 * 1e6) // 5 USDC
@@ -120,9 +121,16 @@ export function DepositForm() {
120121
message: 'Your deposit is being processed.',
121122
})
122123
if (!coin.data) return
123-
router.push({
124-
pathname: `/earn/${coinToParam(coin.data)}/balance`,
125-
})
124+
125+
// for web redirect to balance is fine, on native back for better ux
126+
if (Platform.OS === 'web') {
127+
router.replace({
128+
pathname: `/earn/${coinToParam(coin.data)}/balance`,
129+
})
130+
return
131+
}
132+
133+
router.back()
126134
},
127135
onSettled: () => {
128136
log('sendEarn.deposit.onSettled')

packages/app/features/earn/earnings/screen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export const EarningsFeed = () => {
139139
onEndReached={() => hasNextPage && fetchNextPage()}
140140
ListFooterComponent={!isLoading && isFetchingNextPage ? <Spinner size="small" /> : null}
141141
stickySectionHeadersEnabled={true}
142+
contentContainerStyle={{ gap: 16 }}
142143
/>
143144
</Fade>
144145
)

packages/app/features/earn/withdraw/screen.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
} from '../params'
3939
import { useSendEarnWithdrawCalls, useSendEarnWithdrawVault } from './hooks'
4040
import { useSendEarnAPY } from '../hooks'
41+
import { Platform } from 'react-native'
4142

4243
export const log = debug('app:earn:withdraw')
4344

@@ -143,11 +144,14 @@ export function WithdrawForm() {
143144

144145
toast.show('Withdrawn successfully')
145146

146-
if (coinData) {
147+
if (coinData && Platform.OS === 'web') {
147148
router.push({
148149
pathname: `/earn/${coinToParam(coinData)}`,
149150
})
151+
return
150152
}
153+
154+
router.back()
151155
},
152156
onSettled: (data, error, variables, context) => {
153157
// Error or success... doesn't matter!

0 commit comments

Comments
 (0)