-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
185 additions
and
2 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/components/asset-list/RecyclerAssetList2/WrappedClaimable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { Box, BoxProps, Inline, Text } from '@/design-system'; | ||
import { useAccountSettings } from '@/hooks'; | ||
import { usePositions } from '@/resources/defi/PositionsQuery'; | ||
import { PositionCard } from '@/components/positions/PositionsCard'; | ||
|
||
export default function WrappedClaimable({ uniqueId, placement }: { uniqueId: string; placement: 'left' | 'right' }) { | ||
// const { accountAddress, nativeCurrency } = useAccountSettings(); | ||
// const { data } = usePositions({ | ||
// address: accountAddress, | ||
// currency: nativeCurrency, | ||
// }); | ||
|
||
// const position = data?.positions.find(position => position.type === uniqueId); | ||
|
||
// const placementProps: BoxProps = | ||
// placement === 'left' | ||
// ? { | ||
// alignItems: 'flex-start', | ||
// paddingLeft: '19px (Deprecated)', | ||
// paddingRight: '8px', | ||
// } | ||
// : { | ||
// alignItems: 'flex-end', | ||
// paddingRight: '19px (Deprecated)', | ||
// paddingLeft: '8px', | ||
// }; | ||
|
||
// if (!position) return null; | ||
const color = 'rgba(7, 17, 32, 0.02)'; | ||
return ( | ||
<Box padding="20px" justifyContent="center"> | ||
<Inline alignVertical="center"> | ||
<Box style={{ height: 40, width: 40, backgroundColor: 'blue', borderRadius: 11 }}></Box> | ||
<Box | ||
alignItems="center" | ||
justifyContent="center" | ||
height={{ custom: 28 }} | ||
paddingHorizontal="8px" | ||
borderRadius={12} | ||
borderWidth={1.333} | ||
borderColor={{ custom: color }} | ||
style={{ backgroundColor: color }} | ||
> | ||
<Text weight="semibold" color="label" align="center" size="17pt"> | ||
$662.72 | ||
</Text> | ||
</Box> | ||
</Inline> | ||
</Box> | ||
); | ||
} |
78 changes: 78 additions & 0 deletions
78
src/components/asset-list/RecyclerAssetList2/WrappedClaimablesListHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { useEffect } from 'react'; | ||
import useOpenPositionCards from '@/hooks/useOpenPositionCards'; | ||
import { StyleSheet } from 'react-native'; | ||
import CaretImageSource from '../../../assets/family-dropdown-arrow.png'; | ||
import { useTheme } from '../../../theme/ThemeContext'; | ||
import { ButtonPressAnimation } from '../../animations'; | ||
import { Inline, Text } from '@/design-system'; | ||
import * as i18n from '@/languages'; | ||
import Animated, { useAnimatedReaction, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated'; | ||
import useOpenClaimables from '@/hooks/useOpenClaimables'; | ||
|
||
export default function WrappedClaimablesListHeader({ total, ...props }: { total: string }) { | ||
const { colors } = useTheme(); | ||
const { isClaimablesOpen, toggleOpenClaimables } = useOpenClaimables(); | ||
|
||
const animationValue = useSharedValue(Number(isClaimablesOpen)); | ||
|
||
useEffect(() => { | ||
animationValue.value = withTiming(isClaimablesOpen ? 1 : 0, { | ||
duration: 200, | ||
}); | ||
}, [animationValue, isClaimablesOpen]); | ||
|
||
const caretAnimatedStyle = useAnimatedStyle(() => ({ | ||
transform: [ | ||
{ | ||
rotate: `${animationValue.value * 90}deg`, | ||
}, | ||
], | ||
})); | ||
|
||
const totalOpacityAnimatedStyle = useAnimatedStyle(() => ({ | ||
opacity: 1 - animationValue.value, | ||
})); | ||
|
||
return ( | ||
<ButtonPressAnimation | ||
key={`claimables_${isClaimablesOpen}`} | ||
onPress={toggleOpenClaimables} | ||
scaleTo={1.05} | ||
style={sx.container} | ||
testID="claimables-list-header" | ||
> | ||
<Inline alignHorizontal="justify" alignVertical="center"> | ||
<Text size="22pt" color="label" weight="heavy"> | ||
{i18n.t(i18n.l.account.tab_claimables)} | ||
</Text> | ||
<Inline horizontalSpace="8px" alignVertical="center"> | ||
{!isClaimablesOpen && ( | ||
<Animated.View style={[sx.total, totalOpacityAnimatedStyle]}> | ||
<Text size="20pt" color="label" weight="regular"> | ||
{total} | ||
</Text> | ||
</Animated.View> | ||
)} | ||
<Animated.Image source={CaretImageSource} style={[sx.caret, caretAnimatedStyle]} tintColor={colors.dark} /> | ||
</Inline> | ||
</Inline> | ||
</ButtonPressAnimation> | ||
); | ||
} | ||
|
||
const sx = StyleSheet.create({ | ||
container: { | ||
height: 48, | ||
justifyContent: 'center', | ||
paddingHorizontal: 19, | ||
}, | ||
caret: { | ||
height: 18, | ||
width: 8, | ||
marginBottom: 1, | ||
right: 5, | ||
}, | ||
total: { | ||
paddingRight: 4, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useCallback } from 'react'; | ||
import { useMMKVBoolean } from 'react-native-mmkv'; | ||
import useAccountSettings from './useAccountSettings'; | ||
|
||
export default function useOpenClaimables() { | ||
const { accountAddress } = useAccountSettings(); | ||
const [isClaimablesOpen, setIsClaimablesOpen] = useMMKVBoolean('claimables-open-' + accountAddress); | ||
|
||
const toggleOpenClaimables = useCallback(() => setIsClaimablesOpen(prev => !prev), [setIsClaimablesOpen]); | ||
|
||
return { | ||
isClaimablesOpen, | ||
toggleOpenClaimables, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters