Skip to content

Commit fc9106f

Browse files
authored
CP-9706: DeFi list and detail (#2315)
1 parent b0d66ea commit fc9106f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1701
-272
lines changed

packages/core-mobile/app/components/Row.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { View } from '@avalabs/k2-mobile'
21
import React, { FC } from 'react'
3-
import { ViewProps } from 'react-native'
2+
import { ViewProps, View } from 'react-native'
43

54
export const Row: FC<ViewProps> = ({ style, children, testID }) => {
65
return (

packages/core-mobile/app/hooks/defi/useDeFiProtocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { refetchIntervals } from 'services/defi/constants'
77
import { ReactQueryKeys } from 'consts/reactQueryKeys'
88

99
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
10-
export const useDeFiProtocol = (protocolId: string) => {
10+
export const useDeFiProtocol = (protocolId: string | undefined = '') => {
1111
const addressC = useSelector(selectActiveAccount)?.addressC ?? ''
1212

1313
return useRefreshableQuery({
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import { Image, SxProp } from '@avalabs/k2-alpine'
3+
import { Placeholder } from './Placeholder'
4+
5+
export const ErrorState = ({
6+
sx,
7+
icon = (
8+
<Image
9+
source={require('../../assets/icons/error_state_emoji.png')}
10+
sx={{ width: 42, height: 42 }}
11+
/>
12+
),
13+
title = 'Oops! Something went wrong',
14+
description = 'Please try again later',
15+
button
16+
}: {
17+
sx?: SxProp
18+
icon?: JSX.Element
19+
title?: string
20+
description?: string
21+
button?: {
22+
title: string
23+
onPress: () => void
24+
}
25+
}): JSX.Element => {
26+
return (
27+
<Placeholder
28+
sx={sx}
29+
icon={icon}
30+
title={title}
31+
description={description}
32+
button={button}
33+
/>
34+
)
35+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { alpha, useTheme } from '@avalabs/k2-alpine'
2+
import { LinearGradient } from 'expo-linear-gradient'
3+
import React from 'react'
4+
import { View } from 'react-native'
5+
import { BlurViewWithFallback } from './BlurViewWithFallback'
6+
7+
export const LinearGradientBottomWrapper = ({
8+
children
9+
}: {
10+
children: React.ReactNode
11+
}): React.JSX.Element => {
12+
const { theme } = useTheme()
13+
14+
return (
15+
<View
16+
style={{
17+
marginBottom: -1
18+
}}>
19+
<LinearGradient
20+
colors={[
21+
alpha(theme.colors.$surfacePrimary, 0),
22+
alpha(theme.colors.$surfacePrimary, 0.9)
23+
]}
24+
style={{
25+
position: 'absolute',
26+
top: -44,
27+
left: 0,
28+
right: 0,
29+
height: 60
30+
}}
31+
start={{ x: 0.5, y: 0 }}
32+
end={{ x: 0.5, y: 0.5 }}
33+
/>
34+
<BlurViewWithFallback>{children}</BlurViewWithFallback>
35+
</View>
36+
)
37+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ActivityIndicator, SxProp, View } from '@avalabs/k2-alpine'
2+
import React from 'react'
3+
4+
export const LoadingState = ({ sx }: { sx?: SxProp }): React.JSX.Element => {
5+
return (
6+
<View
7+
sx={{
8+
justifyContent: 'center',
9+
alignItems: 'center',
10+
...sx
11+
}}>
12+
<ActivityIndicator size={'large'} />
13+
</View>
14+
)
15+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Button, SxProp, Text, View } from '@avalabs/k2-alpine'
2+
import React from 'react'
3+
4+
export const Placeholder = ({
5+
icon,
6+
title,
7+
description,
8+
button,
9+
sx
10+
}: {
11+
icon: JSX.Element
12+
title: string
13+
description?: string
14+
button?: {
15+
title: string
16+
onPress: () => void
17+
}
18+
sx?: SxProp
19+
}): React.JSX.Element => {
20+
return (
21+
<View
22+
sx={{
23+
justifyContent: 'center',
24+
alignItems: 'center',
25+
...sx
26+
}}>
27+
<View sx={{ maxWidth: 300, alignItems: 'center' }}>
28+
{icon}
29+
<Text
30+
variant="heading6"
31+
sx={{ color: '$textPrimary', marginTop: 32, textAlign: 'center' }}>
32+
{title}
33+
</Text>
34+
{description && (
35+
<Text
36+
variant="body2"
37+
sx={{
38+
color: '$textSecondary',
39+
fontSize: 12,
40+
lineHeight: 16,
41+
marginTop: 8,
42+
textAlign: 'center',
43+
marginHorizontal: 55
44+
}}>
45+
{description}
46+
</Text>
47+
)}
48+
{button && (
49+
<Button
50+
size="medium"
51+
type="secondary"
52+
style={{ marginTop: 16 }}
53+
onPress={button.onPress}>
54+
{button.title}
55+
</Button>
56+
)}
57+
</View>
58+
</View>
59+
)
60+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import { Easing, FadeInRight, FadeInUp } from 'react-native-reanimated'
22

3-
export enum ActionButtonTitle {
4-
Send = 'Send',
5-
Swap = 'Swap',
6-
Buy = 'Buy',
7-
Stake = 'Stake',
8-
Bridge = 'Bridge',
9-
Connect = 'Connect'
10-
}
11-
12-
export const LIST_ITEM_HEIGHT = 60
13-
export const GRID_ITEM_HEIGHT = 170
14-
153
export const getItemEnteringAnimation = (index: number): FadeInRight =>
164
FadeInRight.duration(100)
175
.delay(index * 50)
@@ -23,5 +11,3 @@ export const getListItemEnteringAnimation = (index: number): FadeInRight =>
2311
.delay(index * 50)
2412
.easing(Easing.bezierFn(0.25, 1, 0.5, 1))
2513
.springify()
26-
27-
export const SEGMENT_CONTROL_HEIGHT = 40

packages/core-mobile/app/new/features/portfolio/components/ActionButtons.tsx renamed to packages/core-mobile/app/new/features/portfolio/assets/components/ActionButtons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react'
22
import Animated, { LinearTransition } from 'react-native-reanimated'
33
import { SquareButton, SquareButtonIconType } from '@avalabs/k2-alpine'
4-
import { useOnPressAnimation } from './assets/useOnPressAnimation'
5-
import { ActionButtonTitle, getItemEnteringAnimation } from './assets/consts'
4+
import { getItemEnteringAnimation } from 'common/utils/animations'
5+
import { useOnPressAnimation } from 'common/hooks/useOnPressAnimation'
6+
import { ActionButtonTitle } from '../consts'
67

78
export const ActionButtons = ({
89
buttons

0 commit comments

Comments
 (0)