mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-23 23:57:15 +01:00
chore(suite-native): remove selector from common
This commit is contained in:
committed by
Bohdan Juříček
parent
0533c1bdea
commit
290646fca5
@@ -1,8 +1,6 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Pressable, PressableProps } from 'react-native';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { selectHasRunningDiscovery } from '@suite-common/wallet-core';
|
||||
import { Icon, IconName } from '@suite-native/icons';
|
||||
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';
|
||||
import { Color } from '@trezor/theme';
|
||||
@@ -17,10 +15,11 @@ import { Text } from '../Text';
|
||||
const ICON_WRAPPER_SIZE = 48;
|
||||
|
||||
type CardVariant = 'normal' | 'danger';
|
||||
type CompactCardWithIconLayoutProps = Omit<PressableProps, 'onPress'> & {
|
||||
export type CompactCardWithIconLayoutProps = Omit<PressableProps, 'onPress'> & {
|
||||
icon: IconName;
|
||||
title: ReactNode;
|
||||
subtitle: ReactNode;
|
||||
isDisabled?: boolean;
|
||||
alertBoxProps?: Omit<InlineAlertBoxProps, 'borderRadius'>;
|
||||
onPress?: () => void;
|
||||
variant?: CardVariant;
|
||||
@@ -68,14 +67,14 @@ export const CompactCardWithIconLayout = ({
|
||||
subtitle,
|
||||
alertBoxProps,
|
||||
onPress,
|
||||
isDisabled = false,
|
||||
variant = 'normal',
|
||||
...pressableProps
|
||||
}: CompactCardWithIconLayoutProps) => {
|
||||
const { applyStyle } = useNativeStyles();
|
||||
const isDiscoveryRunning = useSelector(selectHasRunningDiscovery);
|
||||
|
||||
return (
|
||||
<Pressable onPress={onPress} disabled={isDiscoveryRunning} {...pressableProps}>
|
||||
<Pressable onPress={onPress} disabled={isDisabled} {...pressableProps}>
|
||||
<Card borderColor="borderElevation1" noPadding>
|
||||
<HStack padding="sp16" spacing="sp12" alignItems="center">
|
||||
<Box style={applyStyle(iconWrapperStyle, { variant })}>
|
||||
@@ -91,7 +90,7 @@ export const CompactCardWithIconLayout = ({
|
||||
{subtitle}
|
||||
</Text>
|
||||
</VStack>
|
||||
{isDiscoveryRunning ? (
|
||||
{isDisabled ? (
|
||||
<Loader />
|
||||
) : (
|
||||
<Icon name="caretRight" size="mediumLarge" color="iconSubdued" />
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
|
||||
import { CompactCardWithIconLayout } from '@suite-native/atoms';
|
||||
import { Translation } from '@suite-native/intl';
|
||||
import {
|
||||
DeviceAuthenticityStackParamList,
|
||||
@@ -10,6 +9,8 @@ import {
|
||||
StackToStackCompositeNavigationProps,
|
||||
} from '@suite-native/navigation';
|
||||
|
||||
import { DeviceSettingsItemCard } from './DeviceSettingsItemCard';
|
||||
|
||||
type NavigationProp = StackToStackCompositeNavigationProps<
|
||||
DeviceAuthenticityStackParamList,
|
||||
DeviceAuthenticityStackRoutes,
|
||||
@@ -24,7 +25,7 @@ export const DeviceAuthenticityCard = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<CompactCardWithIconLayout
|
||||
<DeviceSettingsItemCard
|
||||
icon="shield"
|
||||
onPress={handleOnPress}
|
||||
title={<Translation id="moduleDeviceSettings.authenticity.title" />}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
selectIsDeviceBackedUp,
|
||||
selectSelectedDevice,
|
||||
} from '@suite-common/wallet-core';
|
||||
import { CompactCardWithIconLayout, InlineAlertBoxProps } from '@suite-native/atoms';
|
||||
import { InlineAlertBoxProps } from '@suite-native/atoms';
|
||||
import { useIsFirmwareUpdateFeatureEnabled } from '@suite-native/firmware';
|
||||
import { Translation } from '@suite-native/intl';
|
||||
import {
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
} from '@suite-native/navigation';
|
||||
import { getFirmwareVersion } from '@trezor/device-utils';
|
||||
|
||||
import { DeviceSettingsItemCard } from './DeviceSettingsItemCard';
|
||||
|
||||
type NavigationProp = StackNavigationProps<
|
||||
DeviceSettingsStackParamList,
|
||||
DeviceSettingsStackRoutes.ConfirmFirmwareUpdate
|
||||
@@ -71,7 +73,7 @@ export const DeviceFirmwareCard = () => {
|
||||
})();
|
||||
|
||||
return (
|
||||
<CompactCardWithIconLayout
|
||||
<DeviceSettingsItemCard
|
||||
icon="database"
|
||||
title={<Translation id="firmware.title" />}
|
||||
alertBoxProps={firmwareUpdateProps}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
selectIsDeviceProtectedByPin,
|
||||
selectSelectedDevice,
|
||||
} from '@suite-common/wallet-core';
|
||||
import { CompactCardWithIconLayout, InlineAlertBoxProps } from '@suite-native/atoms';
|
||||
import { InlineAlertBoxProps } from '@suite-native/atoms';
|
||||
import { Translation } from '@suite-native/intl';
|
||||
import {
|
||||
DeviceSettingsStackParamList,
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
StackNavigationProps,
|
||||
} from '@suite-native/navigation';
|
||||
|
||||
import { DeviceSettingsItemCard } from './DeviceSettingsItemCard';
|
||||
|
||||
type NavigationProp = StackNavigationProps<
|
||||
DeviceSettingsStackParamList,
|
||||
DeviceSettingsStackRoutes.DeviceSettings
|
||||
@@ -58,7 +60,7 @@ export const DevicePinProtectionCard = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<CompactCardWithIconLayout
|
||||
<DeviceSettingsItemCard
|
||||
icon="password"
|
||||
title={<Translation id="moduleDeviceSettings.pinProtection.title" />}
|
||||
subtitle={
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { selectHasRunningDiscovery } from '@suite-common/wallet-core';
|
||||
import { CompactCardWithIconLayout, CompactCardWithIconLayoutProps } from '@suite-native/atoms';
|
||||
|
||||
export const DeviceSettingsItemCard = ({
|
||||
icon,
|
||||
title,
|
||||
onPress,
|
||||
testID,
|
||||
subtitle,
|
||||
}: CompactCardWithIconLayoutProps) => {
|
||||
const hasRunningDiscovery = useSelector(selectHasRunningDiscovery);
|
||||
|
||||
return (
|
||||
<CompactCardWithIconLayout
|
||||
icon={icon}
|
||||
onPress={onPress}
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
isDisabled={hasRunningDiscovery}
|
||||
testID={testID}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
|
||||
import { CompactCardWithIconLayout } from '@suite-native/atoms';
|
||||
import { Translation } from '@suite-native/intl';
|
||||
import {
|
||||
DeviceSettingsStackParamList,
|
||||
@@ -9,6 +8,8 @@ import {
|
||||
WipeDeviceStackRoutes,
|
||||
} from '@suite-native/navigation';
|
||||
|
||||
import { DeviceSettingsItemCard } from './DeviceSettingsItemCard';
|
||||
|
||||
type NavigationProp = StackNavigationProps<
|
||||
DeviceSettingsStackParamList,
|
||||
DeviceSettingsStackRoutes.DeviceSettings
|
||||
@@ -24,7 +25,7 @@ export const WipeDeviceCard = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<CompactCardWithIconLayout
|
||||
<DeviceSettingsItemCard
|
||||
title={<Translation id="moduleDeviceSettings.wipeDevice.title" />}
|
||||
icon="warningOctagon"
|
||||
subtitle={<Translation id="moduleDeviceSettings.wipeDevice.subtitle" />}
|
||||
|
||||
Reference in New Issue
Block a user