-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat(suite-native): Mobile Trade: Token picker modal visual stub
- Loading branch information
Showing
4 changed files
with
90 additions
and
76 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
suite-native/module-trading/src/components/general/SheetHeaderTitle.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,40 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { RequireAllOrNone } from 'type-fest'; | ||
|
||
import { Box, HStack, IconButton, Text } from '@suite-native/atoms'; | ||
import { IconName } from '@suite-native/icons'; | ||
|
||
export type SheetHeaderTitleProps = { | ||
children: ReactNode; | ||
} & RequireAllOrNone<{ | ||
onLeftButtonPress: () => void; | ||
leftButtonIcon: IconName; | ||
}>; | ||
|
||
export const SheetHeaderTitle = ({ | ||
onLeftButtonPress, | ||
leftButtonIcon, | ||
children, | ||
}: SheetHeaderTitleProps) => ( | ||
<HStack alignItems="center" justifyContent="space-between"> | ||
{leftButtonIcon && ( | ||
<Box flex={1}> | ||
<IconButton | ||
iconName={leftButtonIcon} | ||
onPress={onLeftButtonPress} | ||
colorScheme="tertiaryElevation0" | ||
size="medium" | ||
accessibilityRole="button" | ||
accessibilityLabel="Close" | ||
/> | ||
</Box> | ||
)} | ||
<Box flex={3}> | ||
<Text variant="highlight" textAlign="center" ellipsizeMode="tail" numberOfLines={1}> | ||
{children} | ||
</Text> | ||
</Box> | ||
{leftButtonIcon && <Box flex={1} />} | ||
</HStack> | ||
); |
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
96 changes: 46 additions & 50 deletions
96
...module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheetHeader.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 |
---|---|---|
@@ -1,66 +1,62 @@ | ||
import { useMemo, useState } from 'react'; | ||
import { useState } from 'react'; | ||
import Animated, { FadeIn, FadeOut, LinearTransition } from 'react-native-reanimated'; | ||
|
||
import { LinearGradient } from 'expo-linear-gradient'; | ||
|
||
import { hexToRgba } from '@suite-common/suite-utils'; | ||
import { Text, VStack } from '@suite-native/atoms'; | ||
import { BottomSheetGrabber, VStack } from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { useNativeStyles } from '@trezor/styles'; | ||
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; | ||
|
||
import { SheetHeaderTitle } from '../SheetHeaderTitle'; | ||
import { TradeableAssetsFilterTabs } from './TradeableAssetsFilterTabs'; | ||
import { SearchInputWithCancel } from '../SearchInputWithCancel'; | ||
|
||
export const SHEET_HEADER_HEIGHT = 140 as const; | ||
type TradeableAssetsSheetHeaderProps = { | ||
onClose: () => void; | ||
}; | ||
|
||
const HEADER_HEIGHT = 160; | ||
const FOCUS_ANIMATION_DURATION = 300 as const; | ||
|
||
const GRADIENT_START = { x: 0.5, y: 0.9 } as const; | ||
const GRADIENT_END = { x: 0.5, y: 1 } as const; | ||
const wrapperStyle = prepareNativeStyle<{}>(({ spacings }) => ({ | ||
height: HEADER_HEIGHT, | ||
padding: spacings.sp16, | ||
gap: spacings.sp16, | ||
})); | ||
|
||
export const TradeableAssetsSheetHeader = ({ onClose }: TradeableAssetsSheetHeaderProps) => { | ||
const { applyStyle } = useNativeStyles(); | ||
|
||
export const TradeableAssetsSheetHeader = () => { | ||
const { | ||
utils: { | ||
colors: { backgroundSurfaceElevation0 }, | ||
}, | ||
} = useNativeStyles(); | ||
const [isFilterActive, setIsFilterActive] = useState(false); | ||
const [filterValue, setFilterValue] = useState(''); | ||
|
||
const gradientColors = useMemo<[string, string]>( | ||
() => [backgroundSurfaceElevation0, hexToRgba(backgroundSurfaceElevation0, 0.1)], | ||
[backgroundSurfaceElevation0], | ||
); | ||
|
||
return ( | ||
<LinearGradient colors={gradientColors} start={GRADIENT_START} end={GRADIENT_END}> | ||
<VStack spacing="sp16" padding="sp16"> | ||
<Animated.View layout={LinearTransition.duration(FOCUS_ANIMATION_DURATION)}> | ||
{!isFilterActive && ( | ||
<Animated.View | ||
entering={FadeIn.duration(FOCUS_ANIMATION_DURATION)} | ||
exiting={FadeOut.duration(FOCUS_ANIMATION_DURATION)} | ||
> | ||
<Text variant="highlight" textAlign="center"> | ||
<Translation id="moduleTrading.tradeableAssetsSheet.title" /> | ||
</Text> | ||
</Animated.View> | ||
)} | ||
</Animated.View> | ||
<Animated.View layout={LinearTransition.duration(FOCUS_ANIMATION_DURATION)}> | ||
<SearchInputWithCancel | ||
onChange={setFilterValue} | ||
onFocus={() => setIsFilterActive(true)} | ||
onBlur={() => setIsFilterActive(false)} | ||
value={filterValue} | ||
/> | ||
</Animated.View> | ||
<Animated.View layout={LinearTransition.duration(FOCUS_ANIMATION_DURATION)}> | ||
<TradeableAssetsFilterTabs | ||
visible={isFilterActive} | ||
animationDuration={FOCUS_ANIMATION_DURATION} | ||
/> | ||
</Animated.View> | ||
</VStack> | ||
</LinearGradient> | ||
<VStack style={applyStyle(wrapperStyle)}> | ||
<BottomSheetGrabber /> | ||
<Animated.View layout={LinearTransition.duration(FOCUS_ANIMATION_DURATION)}> | ||
{!isFilterActive && ( | ||
<Animated.View | ||
entering={FadeIn.duration(FOCUS_ANIMATION_DURATION)} | ||
exiting={FadeOut.duration(FOCUS_ANIMATION_DURATION)} | ||
> | ||
<SheetHeaderTitle leftButtonIcon="x" onLeftButtonPress={onClose}> | ||
<Translation id="moduleTrading.tradeableAssetsSheet.title" /> | ||
</SheetHeaderTitle> | ||
</Animated.View> | ||
)} | ||
</Animated.View> | ||
<Animated.View layout={LinearTransition.duration(FOCUS_ANIMATION_DURATION)}> | ||
<SearchInputWithCancel | ||
onChange={setFilterValue} | ||
onFocus={() => setIsFilterActive(true)} | ||
onBlur={() => setIsFilterActive(false)} | ||
value={filterValue} | ||
/> | ||
</Animated.View> | ||
<Animated.View layout={LinearTransition.duration(FOCUS_ANIMATION_DURATION)}> | ||
<TradeableAssetsFilterTabs | ||
visible={isFilterActive} | ||
animationDuration={FOCUS_ANIMATION_DURATION} | ||
/> | ||
</Animated.View> | ||
</VStack> | ||
); | ||
}; |