diff --git a/suite-native/module-trading/src/components/general/SheetHeaderTitle.tsx b/suite-native/module-trading/src/components/general/SheetHeaderTitle.tsx new file mode 100644 index 00000000000..f4d1eb4a1c3 --- /dev/null +++ b/suite-native/module-trading/src/components/general/SheetHeaderTitle.tsx @@ -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) => ( + + {leftButtonIcon && ( + + + + )} + + + {children} + + + {leftButtonIcon && } + +); diff --git a/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeAssetsListEmptyComponent.tsx b/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeAssetsListEmptyComponent.tsx index 12df3893a95..53baca1fa24 100644 --- a/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeAssetsListEmptyComponent.tsx +++ b/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeAssetsListEmptyComponent.tsx @@ -2,13 +2,8 @@ import { Text, VStack } from '@suite-native/atoms'; import { Translation } from '@suite-native/intl'; import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; -import { SHEET_HEADER_HEIGHT } from './TradeableAssetsSheetHeader'; -import { PICKER_BUTTON_HEIGHT } from '../PickerCloseButton'; - const emptyComponentStyle = prepareNativeStyle(({ spacings }) => ({ - paddingTop: SHEET_HEADER_HEIGHT + spacings.sp12, - paddingBottom: PICKER_BUTTON_HEIGHT + spacings.sp12, - paddingHorizontal: spacings.sp52, + padding: spacings.sp52, alignContent: 'center', justifyContent: 'center', gap: spacings.sp12, diff --git a/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheet.tsx b/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheet.tsx index 8b81558e2c3..1df690e695e 100644 --- a/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheet.tsx +++ b/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheet.tsx @@ -7,9 +7,8 @@ import { Translation } from '@suite-native/intl'; import { TradeAssetsListEmptyComponent } from './TradeAssetsListEmptyComponent'; import { ASSET_ITEM_HEIGHT, TradeableAssetListItem } from './TradeableAssetListItem'; -import { SHEET_HEADER_HEIGHT, TradeableAssetsSheetHeader } from './TradeableAssetsSheetHeader'; +import { TradeableAssetsSheetHeader } from './TradeableAssetsSheetHeader'; import { TradeableAsset } from '../../../types'; -import { PICKER_BUTTON_HEIGHT, PickerCloseButton } from '../PickerCloseButton'; export type TradeableAssetsSheetProps = { isVisible: boolean; @@ -18,8 +17,6 @@ export type TradeableAssetsSheetProps = { }; type ListInnerItemShape = - // [type, height, key] - | ['spacer', number, string] // [type, text, key] | ['sectionHeader', ReactNode, string] // [type, data, isFavourite] @@ -54,16 +51,12 @@ const getMockFiatRate = () => Math.random() * 1000; const getMockPriceChange = () => Math.random() * 3 - 1; const getEstimatedListHeight = (itemsCount: number) => - itemsCount * ASSET_ITEM_HEIGHT + - SHEET_HEADER_HEIGHT + - PICKER_BUTTON_HEIGHT + - 2 * SECTION_HEADER_HEIGHT; + itemsCount * ASSET_ITEM_HEIGHT + 2 * SECTION_HEADER_HEIGHT; const transformToInnerFlatListData = ( favourites: TradeableAsset[], assetsData: TradeableAsset[], ): ListInnerItemShape[] => [ - ['spacer', SHEET_HEADER_HEIGHT, 'spacer_top'], [ 'sectionHeader', , @@ -98,12 +91,10 @@ const transformToInnerFlatListData = ( }, ] as ListInnerItemShape, ), - ['spacer', PICKER_BUTTON_HEIGHT, 'spacer_bottom'], ]; const keyExtractor = (item: ListInnerItemShape) => { switch (item[0]) { - case 'spacer': case 'sectionHeader': return item[2]; @@ -120,12 +111,6 @@ const keyExtractor = (item: ListInnerItemShape) => { const renderItem = (data: ListInnerItemShape, onAssetSelect: (asset: TradeableAsset) => void) => { switch (data[0]) { - case 'spacer': { - const height = data[1]; - - return ; - } - case 'sectionHeader': { const text = data[1]; @@ -188,10 +173,8 @@ export const TradeableAssetsSheet = ({ isVisible={isVisible} onClose={onClose} - isCloseDisplayed={false} ListEmptyComponent={} - stickyListHeaderComponent={} - stickyListFooterComponent={} + handleComponent={() => } data={data} keyExtractor={keyExtractor} estimatedListHeight={estimatedListHeight} diff --git a/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheetHeader.tsx b/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheetHeader.tsx index dd2823baf6e..d3f616fcf31 100644 --- a/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheetHeader.tsx +++ b/suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheetHeader.tsx @@ -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 ( - - - - {!isFilterActive && ( - - - - - - )} - - - setIsFilterActive(true)} - onBlur={() => setIsFilterActive(false)} - value={filterValue} - /> - - - - - - + + + + {!isFilterActive && ( + + + + + + )} + + + setIsFilterActive(true)} + onBlur={() => setIsFilterActive(false)} + value={filterValue} + /> + + + + + ); };