@reown/appkit-ui-react-native 0.0.0-develop-20241121145434 → 0.0.0-develop-20250117202414
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/assets/svg/RecycleHorizontal.js +21 -0
- package/lib/commonjs/assets/svg/RecycleHorizontal.js.map +1 -0
- package/lib/commonjs/components/wui-icon/index.js +2 -0
- package/lib/commonjs/components/wui-icon/index.js.map +1 -1
- package/lib/commonjs/components/wui-pressable/index.js +68 -0
- package/lib/commonjs/components/wui-pressable/index.js.map +1 -0
- package/lib/commonjs/components/wui-shimmer/index.js +5 -1
- package/lib/commonjs/components/wui-shimmer/index.js.map +1 -1
- package/lib/commonjs/components/wui-text/index.js +2 -2
- package/lib/commonjs/components/wui-text/index.js.map +1 -1
- package/lib/commonjs/composites/wui-button/index.js +2 -1
- package/lib/commonjs/composites/wui-button/index.js.map +1 -1
- package/lib/commonjs/composites/wui-button/styles.js +3 -3
- package/lib/commonjs/composites/wui-button/styles.js.map +1 -1
- package/lib/commonjs/composites/wui-card-select/index.js +4 -2
- package/lib/commonjs/composites/wui-card-select/index.js.map +1 -1
- package/lib/commonjs/composites/wui-input-text/index.js +5 -4
- package/lib/commonjs/composites/wui-input-text/index.js.map +1 -1
- package/lib/commonjs/composites/wui-list-token/index.js +29 -9
- package/lib/commonjs/composites/wui-list-token/index.js.map +1 -1
- package/lib/commonjs/composites/wui-list-token/styles.js +3 -0
- package/lib/commonjs/composites/wui-list-token/styles.js.map +1 -1
- package/lib/commonjs/composites/wui-list-wallet/index.js +2 -3
- package/lib/commonjs/composites/wui-list-wallet/index.js.map +1 -1
- package/lib/commonjs/composites/wui-network-button/index.js +4 -2
- package/lib/commonjs/composites/wui-network-button/index.js.map +1 -1
- package/lib/commonjs/composites/wui-search-bar/index.js +2 -4
- package/lib/commonjs/composites/wui-search-bar/index.js.map +1 -1
- package/lib/commonjs/composites/wui-snackbar/index.js +6 -2
- package/lib/commonjs/composites/wui-snackbar/index.js.map +1 -1
- package/lib/commonjs/composites/wui-toggle/index.js +65 -0
- package/lib/commonjs/composites/wui-toggle/index.js.map +1 -0
- package/lib/commonjs/composites/wui-toggle/styles.js +30 -0
- package/lib/commonjs/composites/wui-toggle/styles.js.map +1 -0
- package/lib/commonjs/composites/wui-token-button/index.js +21 -11
- package/lib/commonjs/composites/wui-token-button/index.js.map +1 -1
- package/lib/commonjs/composites/wui-token-button/styles.js +4 -0
- package/lib/commonjs/composites/wui-token-button/styles.js.map +1 -1
- package/lib/commonjs/context/ThemeContext.js +41 -0
- package/lib/commonjs/context/ThemeContext.js.map +1 -0
- package/lib/commonjs/hooks/useTheme.js +5 -7
- package/lib/commonjs/hooks/useTheme.js.map +1 -1
- package/lib/commonjs/index.js +27 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/wui-flex/index.js +3 -2
- package/lib/commonjs/layout/wui-flex/index.js.map +1 -1
- package/lib/commonjs/layout/wui-separator/index.js +4 -4
- package/lib/commonjs/layout/wui-separator/index.js.map +1 -1
- package/lib/commonjs/utils/ThemeUtil.js +18 -1
- package/lib/commonjs/utils/ThemeUtil.js.map +1 -1
- package/lib/commonjs/utils/TransactionUtil.js +56 -45
- package/lib/commonjs/utils/TransactionUtil.js.map +1 -1
- package/lib/module/assets/svg/RecycleHorizontal.js +13 -0
- package/lib/module/assets/svg/RecycleHorizontal.js.map +1 -0
- package/lib/module/components/wui-icon/index.js +2 -0
- package/lib/module/components/wui-icon/index.js.map +1 -1
- package/lib/module/components/wui-pressable/index.js +62 -0
- package/lib/module/components/wui-pressable/index.js.map +1 -0
- package/lib/module/components/wui-shimmer/index.js +6 -2
- package/lib/module/components/wui-shimmer/index.js.map +1 -1
- package/lib/module/components/wui-text/index.js +2 -2
- package/lib/module/components/wui-text/index.js.map +1 -1
- package/lib/module/composites/wui-button/index.js +2 -1
- package/lib/module/composites/wui-button/index.js.map +1 -1
- package/lib/module/composites/wui-button/styles.js +3 -3
- package/lib/module/composites/wui-button/styles.js.map +1 -1
- package/lib/module/composites/wui-card-select/index.js +4 -2
- package/lib/module/composites/wui-card-select/index.js.map +1 -1
- package/lib/module/composites/wui-input-text/index.js +5 -4
- package/lib/module/composites/wui-input-text/index.js.map +1 -1
- package/lib/module/composites/wui-list-token/index.js +27 -8
- package/lib/module/composites/wui-list-token/index.js.map +1 -1
- package/lib/module/composites/wui-list-token/styles.js +3 -0
- package/lib/module/composites/wui-list-token/styles.js.map +1 -1
- package/lib/module/composites/wui-list-wallet/index.js +3 -4
- package/lib/module/composites/wui-list-wallet/index.js.map +1 -1
- package/lib/module/composites/wui-network-button/index.js +4 -2
- package/lib/module/composites/wui-network-button/index.js.map +1 -1
- package/lib/module/composites/wui-search-bar/index.js +2 -4
- package/lib/module/composites/wui-search-bar/index.js.map +1 -1
- package/lib/module/composites/wui-snackbar/index.js +6 -2
- package/lib/module/composites/wui-snackbar/index.js.map +1 -1
- package/lib/module/composites/wui-toggle/index.js +58 -0
- package/lib/module/composites/wui-toggle/index.js.map +1 -0
- package/lib/module/composites/wui-toggle/styles.js +24 -0
- package/lib/module/composites/wui-toggle/styles.js.map +1 -0
- package/lib/module/composites/wui-token-button/index.js +21 -11
- package/lib/module/composites/wui-token-button/index.js.map +1 -1
- package/lib/module/composites/wui-token-button/styles.js +4 -0
- package/lib/module/composites/wui-token-button/styles.js.map +1 -1
- package/lib/module/context/ThemeContext.js +33 -0
- package/lib/module/context/ThemeContext.js.map +1 -0
- package/lib/module/hooks/useTheme.js +4 -7
- package/lib/module/hooks/useTheme.js.map +1 -1
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/wui-flex/index.js +3 -2
- package/lib/module/layout/wui-flex/index.js.map +1 -1
- package/lib/module/layout/wui-separator/index.js +4 -4
- package/lib/module/layout/wui-separator/index.js.map +1 -1
- package/lib/module/utils/ThemeUtil.js +16 -0
- package/lib/module/utils/ThemeUtil.js.map +1 -1
- package/lib/module/utils/TransactionUtil.js +56 -45
- package/lib/module/utils/TransactionUtil.js.map +1 -1
- package/lib/typescript/assets/svg/RecycleHorizontal.d.ts +4 -0
- package/lib/typescript/assets/svg/RecycleHorizontal.d.ts.map +1 -0
- package/lib/typescript/components/wui-icon/index.d.ts.map +1 -1
- package/lib/typescript/components/wui-pressable/index.d.ts +17 -0
- package/lib/typescript/components/wui-pressable/index.d.ts.map +1 -0
- package/lib/typescript/components/wui-shimmer/index.d.ts.map +1 -1
- package/lib/typescript/components/wui-text/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-card-select/index.d.ts +2 -1
- package/lib/typescript/composites/wui-card-select/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-input-text/index.d.ts +3 -1
- package/lib/typescript/composites/wui-input-text/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-list-token/index.d.ts +4 -1
- package/lib/typescript/composites/wui-list-token/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-list-token/styles.d.ts +3 -0
- package/lib/typescript/composites/wui-list-token/styles.d.ts.map +1 -1
- package/lib/typescript/composites/wui-list-wallet/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-network-button/index.d.ts +2 -1
- package/lib/typescript/composites/wui-network-button/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-search-bar/index.d.ts +1 -2
- package/lib/typescript/composites/wui-search-bar/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-snackbar/index.d.ts +1 -1
- package/lib/typescript/composites/wui-snackbar/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-toggle/index.d.ts +11 -0
- package/lib/typescript/composites/wui-toggle/index.d.ts.map +1 -0
- package/lib/typescript/composites/wui-toggle/styles.d.ts +23 -0
- package/lib/typescript/composites/wui-toggle/styles.d.ts.map +1 -0
- package/lib/typescript/composites/wui-token-button/index.d.ts +7 -3
- package/lib/typescript/composites/wui-token-button/index.d.ts.map +1 -1
- package/lib/typescript/composites/wui-token-button/styles.d.ts +4 -0
- package/lib/typescript/composites/wui-token-button/styles.d.ts.map +1 -1
- package/lib/typescript/context/ThemeContext.d.ts +78 -0
- package/lib/typescript/context/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/hooks/useTheme.d.ts +1 -1
- package/lib/typescript/hooks/useTheme.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/layout/wui-flex/index.d.ts +2 -1
- package/lib/typescript/layout/wui-flex/index.d.ts.map +1 -1
- package/lib/typescript/layout/wui-separator/index.d.ts.map +1 -1
- package/lib/typescript/utils/ThemeUtil.d.ts +13 -0
- package/lib/typescript/utils/ThemeUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TransactionUtil.d.ts +9 -1
- package/lib/typescript/utils/TransactionUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypesUtil.d.ts +2 -2
- package/lib/typescript/utils/TypesUtil.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/assets/svg/RecycleHorizontal.tsx +12 -0
- package/src/components/wui-icon/index.tsx +2 -0
- package/src/components/wui-pressable/index.tsx +92 -0
- package/src/components/wui-shimmer/index.tsx +9 -2
- package/src/components/wui-text/index.tsx +3 -4
- package/src/composites/wui-button/index.tsx +1 -1
- package/src/composites/wui-button/styles.ts +3 -3
- package/src/composites/wui-card-select/index.tsx +4 -1
- package/src/composites/wui-input-text/index.tsx +11 -3
- package/src/composites/wui-list-token/index.tsx +31 -8
- package/src/composites/wui-list-token/styles.ts +3 -0
- package/src/composites/wui-list-wallet/index.tsx +5 -6
- package/src/composites/wui-network-button/index.tsx +4 -1
- package/src/composites/wui-search-bar/index.tsx +1 -4
- package/src/composites/wui-snackbar/index.tsx +13 -3
- package/src/composites/wui-toggle/index.tsx +81 -0
- package/src/composites/wui-toggle/styles.ts +24 -0
- package/src/composites/wui-token-button/index.tsx +37 -8
- package/src/composites/wui-token-button/styles.ts +4 -0
- package/src/context/ThemeContext.tsx +44 -0
- package/src/hooks/useTheme.ts +4 -8
- package/src/index.ts +4 -1
- package/src/layout/wui-flex/index.tsx +7 -3
- package/src/layout/wui-separator/index.tsx +4 -7
- package/src/utils/ThemeUtil.ts +18 -0
- package/src/utils/TransactionUtil.ts +72 -52
- package/src/utils/TypesUtil.ts +2 -0
- package/lib/commonjs/components/wui-lean-text/index.js +0 -15
- package/lib/commonjs/components/wui-lean-text/index.js.map +0 -1
- package/lib/commonjs/components/wui-lean-text/index.web.js +0 -13
- package/lib/commonjs/components/wui-lean-text/index.web.js.map +0 -1
- package/lib/commonjs/components/wui-lean-view/index.js +0 -15
- package/lib/commonjs/components/wui-lean-view/index.js.map +0 -1
- package/lib/commonjs/components/wui-lean-view/index.web.js +0 -13
- package/lib/commonjs/components/wui-lean-view/index.web.js.map +0 -1
- package/lib/module/components/wui-lean-text/index.js +0 -10
- package/lib/module/components/wui-lean-text/index.js.map +0 -1
- package/lib/module/components/wui-lean-text/index.web.js +0 -3
- package/lib/module/components/wui-lean-text/index.web.js.map +0 -1
- package/lib/module/components/wui-lean-view/index.js +0 -10
- package/lib/module/components/wui-lean-view/index.js.map +0 -1
- package/lib/module/components/wui-lean-view/index.web.js +0 -3
- package/lib/module/components/wui-lean-view/index.web.js.map +0 -1
- package/lib/typescript/components/wui-lean-text/index.d.ts +0 -5
- package/lib/typescript/components/wui-lean-text/index.d.ts.map +0 -1
- package/lib/typescript/components/wui-lean-text/index.web.d.ts +0 -3
- package/lib/typescript/components/wui-lean-text/index.web.d.ts.map +0 -1
- package/lib/typescript/components/wui-lean-view/index.d.ts +0 -5
- package/lib/typescript/components/wui-lean-view/index.d.ts.map +0 -1
- package/lib/typescript/components/wui-lean-view/index.web.d.ts +0 -3
- package/lib/typescript/components/wui-lean-view/index.web.d.ts.map +0 -1
- package/src/components/wui-lean-text/index.tsx +0 -10
- package/src/components/wui-lean-text/index.web.tsx +0 -3
- package/src/components/wui-lean-view/index.tsx +0 -10
- package/src/components/wui-lean-view/index.web.tsx +0 -3
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Pressable } from 'react-native';
|
|
2
1
|
import { Icon } from '../../components/wui-icon';
|
|
3
2
|
import { Image } from '../../components/wui-image';
|
|
4
3
|
import { Text } from '../../components/wui-text';
|
|
4
|
+
import { Pressable } from '../../components/wui-pressable';
|
|
5
5
|
import { useTheme } from '../../hooks/useTheme';
|
|
6
6
|
import { FlexView } from '../../layout/wui-flex';
|
|
7
7
|
import { UiUtil } from '../../utils/UiUtil';
|
|
8
8
|
import styles from './styles';
|
|
9
9
|
|
|
10
|
+
export const ListTokenTotalHeight = 64;
|
|
11
|
+
|
|
10
12
|
export interface ListTokenProps {
|
|
11
13
|
imageSrc: string;
|
|
12
14
|
networkSrc?: string;
|
|
@@ -15,6 +17,8 @@ export interface ListTokenProps {
|
|
|
15
17
|
amount?: string;
|
|
16
18
|
currency: string;
|
|
17
19
|
onPress?: () => void;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
pressable?: boolean;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export function ListToken({
|
|
@@ -24,17 +28,25 @@ export function ListToken({
|
|
|
24
28
|
value,
|
|
25
29
|
amount,
|
|
26
30
|
currency,
|
|
27
|
-
onPress
|
|
31
|
+
onPress,
|
|
32
|
+
disabled,
|
|
33
|
+
pressable = true
|
|
28
34
|
}: ListTokenProps) {
|
|
29
35
|
const Theme = useTheme();
|
|
30
36
|
|
|
31
37
|
return (
|
|
32
|
-
<Pressable
|
|
38
|
+
<Pressable
|
|
39
|
+
onPress={onPress}
|
|
40
|
+
disabled={disabled || !pressable}
|
|
41
|
+
style={styles.pressable}
|
|
42
|
+
backgroundColor="transparent"
|
|
43
|
+
>
|
|
33
44
|
<FlexView
|
|
34
45
|
flexDirection="row"
|
|
35
46
|
justifyContent="space-between"
|
|
36
47
|
alignItems="center"
|
|
37
|
-
padding={['
|
|
48
|
+
padding={['0', 'm', '0', 'xs']}
|
|
49
|
+
style={{ height: ListTokenTotalHeight }}
|
|
38
50
|
>
|
|
39
51
|
<FlexView flexDirection="row" alignItems="center">
|
|
40
52
|
{imageSrc ? (
|
|
@@ -66,15 +78,26 @@ export function ListToken({
|
|
|
66
78
|
)}
|
|
67
79
|
</FlexView>
|
|
68
80
|
<FlexView padding={['0', 's', '0', 's']}>
|
|
69
|
-
<Text color=
|
|
70
|
-
{
|
|
81
|
+
<Text color={disabled ? 'fg-200' : 'fg-100'} variant="paragraph-500">
|
|
82
|
+
{UiUtil.getTruncateString({
|
|
83
|
+
string: name,
|
|
84
|
+
charsStart: 15,
|
|
85
|
+
charsEnd: 0,
|
|
86
|
+
truncate: 'end'
|
|
87
|
+
})}
|
|
71
88
|
</Text>
|
|
72
89
|
<Text variant="small-400" color="fg-200">
|
|
73
|
-
{UiUtil.formatNumberToLocalString(amount, 4)}
|
|
90
|
+
{UiUtil.formatNumberToLocalString(amount, 4)}{' '}
|
|
91
|
+
{UiUtil.getTruncateString({
|
|
92
|
+
string: currency,
|
|
93
|
+
charsStart: 8,
|
|
94
|
+
charsEnd: 0,
|
|
95
|
+
truncate: 'end'
|
|
96
|
+
})}
|
|
74
97
|
</Text>
|
|
75
98
|
</FlexView>
|
|
76
99
|
</FlexView>
|
|
77
|
-
<Text color=
|
|
100
|
+
<Text color={disabled ? 'fg-200' : 'fg-100'} variant="paragraph-500">
|
|
78
101
|
${value?.toFixed(2) ?? '0.00'}
|
|
79
102
|
</Text>
|
|
80
103
|
</FlexView>
|
|
@@ -2,6 +2,9 @@ import { StyleSheet } from 'react-native';
|
|
|
2
2
|
import { BorderRadius, WalletImageSize } from '../../utils/ThemeUtil';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
+
pressable: {
|
|
6
|
+
borderRadius: BorderRadius.s
|
|
7
|
+
},
|
|
5
8
|
image: {
|
|
6
9
|
height: WalletImageSize.sm,
|
|
7
10
|
width: WalletImageSize.sm,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Animated, Pressable, type StyleProp, type ViewStyle } from 'react-native';
|
|
1
|
+
import { Animated, Pressable, type StyleProp, type ViewStyle, View } from 'react-native';
|
|
2
2
|
import { Text } from '../../components/wui-text';
|
|
3
3
|
import useAnimatedValue from '../../hooks/useAnimatedValue';
|
|
4
4
|
import { useTheme } from '../../hooks/useTheme';
|
|
@@ -6,7 +6,6 @@ import type { IconType, TagType } from '../../utils/TypesUtil';
|
|
|
6
6
|
import { Tag } from '../wui-tag';
|
|
7
7
|
import { WalletImage } from '../wui-wallet-image';
|
|
8
8
|
import { Icon } from '../../components/wui-icon';
|
|
9
|
-
import { LeanView } from '../../components/wui-lean-view';
|
|
10
9
|
import { IconBox } from '../wui-icon-box';
|
|
11
10
|
|
|
12
11
|
import styles from './styles';
|
|
@@ -68,7 +67,7 @@ export function ListWallet({
|
|
|
68
67
|
|
|
69
68
|
function imageTemplate() {
|
|
70
69
|
return (
|
|
71
|
-
<
|
|
70
|
+
<View>
|
|
72
71
|
<WalletImage
|
|
73
72
|
style={[styles.image, disabled && styles.imageDisabled]}
|
|
74
73
|
imageSrc={imageSrc}
|
|
@@ -77,7 +76,7 @@ export function ListWallet({
|
|
|
77
76
|
size="sm"
|
|
78
77
|
/>
|
|
79
78
|
{templateInstalled()}
|
|
80
|
-
</
|
|
79
|
+
</View>
|
|
81
80
|
);
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -117,12 +116,12 @@ export function ListWallet({
|
|
|
117
116
|
onPressOut={setStartValue}
|
|
118
117
|
testID={testID}
|
|
119
118
|
>
|
|
120
|
-
<
|
|
119
|
+
<View style={styles.leftSide}>
|
|
121
120
|
{imageTemplate()}
|
|
122
121
|
<Text variant="paragraph-500" style={styles.name} color={disabled ? 'fg-300' : 'fg-100'}>
|
|
123
122
|
{name}
|
|
124
123
|
</Text>
|
|
125
|
-
</
|
|
124
|
+
</View>
|
|
126
125
|
{iconTemplate()}
|
|
127
126
|
</AnimatedPressable>
|
|
128
127
|
);
|
|
@@ -19,6 +19,7 @@ export interface NetworkButtonProps {
|
|
|
19
19
|
imageHeaders?: Record<string, string>;
|
|
20
20
|
loading?: boolean;
|
|
21
21
|
style?: StyleProp<ViewStyle>;
|
|
22
|
+
testID?: string;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function NetworkButton({
|
|
@@ -29,7 +30,8 @@ export function NetworkButton({
|
|
|
29
30
|
imageSrc,
|
|
30
31
|
imageHeaders,
|
|
31
32
|
loading,
|
|
32
|
-
style
|
|
33
|
+
style,
|
|
34
|
+
testID
|
|
33
35
|
}: NetworkButtonProps) {
|
|
34
36
|
const Theme = useTheme();
|
|
35
37
|
const textColor = disabled ? 'fg-300' : 'fg-100';
|
|
@@ -49,6 +51,7 @@ export function NetworkButton({
|
|
|
49
51
|
onPressIn={setEndValue}
|
|
50
52
|
onPressOut={setStartValue}
|
|
51
53
|
disabled={disabled}
|
|
54
|
+
testID={testID}
|
|
52
55
|
>
|
|
53
56
|
<LoaderComponent loading={loading} />
|
|
54
57
|
<ImageComponent
|
|
@@ -10,15 +10,13 @@ export interface SearchBarProps {
|
|
|
10
10
|
onSubmitEditing?: TextInputProps['onSubmitEditing'];
|
|
11
11
|
onChangeText?: TextInputProps['onChangeText'];
|
|
12
12
|
inputStyle?: TextInputProps['style'];
|
|
13
|
-
testID?: string;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export function SearchBar({
|
|
17
16
|
placeholder = 'Search wallet',
|
|
18
17
|
onSubmitEditing,
|
|
19
18
|
onChangeText,
|
|
20
|
-
inputStyle
|
|
21
|
-
testID
|
|
19
|
+
inputStyle
|
|
22
20
|
}: SearchBarProps) {
|
|
23
21
|
const [showClear, setShowClear] = useState(false);
|
|
24
22
|
const inputRef = useRef<TextInput>(null);
|
|
@@ -38,7 +36,6 @@ export function SearchBar({
|
|
|
38
36
|
inputStyle={inputStyle}
|
|
39
37
|
returnKeyType="search"
|
|
40
38
|
disableFullscreenUI
|
|
41
|
-
testID={testID}
|
|
42
39
|
>
|
|
43
40
|
{showClear && (
|
|
44
41
|
<InputElement
|
|
@@ -4,11 +4,12 @@ import { useTheme } from '../../hooks/useTheme';
|
|
|
4
4
|
import type { ColorType, IconType } from '../../utils/TypesUtil';
|
|
5
5
|
import { IconBox } from '../wui-icon-box';
|
|
6
6
|
import styles from './styles';
|
|
7
|
+
import { LoadingSpinner } from '../../components/wui-loading-spinner';
|
|
7
8
|
|
|
8
9
|
export interface SnackbarProps {
|
|
9
10
|
message: string;
|
|
10
11
|
iconColor: ColorType;
|
|
11
|
-
icon: IconType;
|
|
12
|
+
icon: IconType | 'loading';
|
|
12
13
|
style?: StyleProp<ViewStyle>;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -24,8 +25,17 @@ export function Snackbar({ message, iconColor, icon, style }: SnackbarProps) {
|
|
|
24
25
|
style
|
|
25
26
|
]}
|
|
26
27
|
>
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
{icon === 'loading' ? (
|
|
29
|
+
<LoadingSpinner size="md" />
|
|
30
|
+
) : (
|
|
31
|
+
<IconBox icon={icon} iconColor={iconColor} size="sm" background />
|
|
32
|
+
)}
|
|
33
|
+
<Text
|
|
34
|
+
variant="paragraph-500"
|
|
35
|
+
color="fg-100"
|
|
36
|
+
style={styles.text}
|
|
37
|
+
testID="wui-snackbar-message"
|
|
38
|
+
>
|
|
29
39
|
{message}
|
|
30
40
|
</Text>
|
|
31
41
|
</Animated.View>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useState, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
type LayoutChangeEvent,
|
|
5
|
+
type StyleProp,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
Pressable
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
import { IconBox } from '../wui-icon-box';
|
|
11
|
+
import { FlexView } from '../../layout/wui-flex';
|
|
12
|
+
import { Text } from '../../components/wui-text';
|
|
13
|
+
import styles from './styles';
|
|
14
|
+
|
|
15
|
+
export interface ToggleProps {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
title?: string | React.ReactNode;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
initialOpen?: boolean;
|
|
20
|
+
canClose?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function Toggle({
|
|
24
|
+
children,
|
|
25
|
+
style,
|
|
26
|
+
title = 'Details',
|
|
27
|
+
initialOpen = false,
|
|
28
|
+
canClose = true
|
|
29
|
+
}: ToggleProps) {
|
|
30
|
+
const [isOpen, setIsOpen] = useState(initialOpen);
|
|
31
|
+
const animatedHeight = useRef(new Animated.Value(0)).current;
|
|
32
|
+
const contentHeight = useRef(0);
|
|
33
|
+
const hasInitialized = useRef(false);
|
|
34
|
+
|
|
35
|
+
const toggleDetails = () => {
|
|
36
|
+
if (canClose) {
|
|
37
|
+
const toValue = isOpen ? 0 : contentHeight.current;
|
|
38
|
+
|
|
39
|
+
Animated.spring(animatedHeight, {
|
|
40
|
+
toValue,
|
|
41
|
+
useNativeDriver: false,
|
|
42
|
+
bounciness: 0
|
|
43
|
+
}).start();
|
|
44
|
+
|
|
45
|
+
setIsOpen(!isOpen);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const measureContent = (event: LayoutChangeEvent) => {
|
|
50
|
+
const height = event.nativeEvent.layout.height;
|
|
51
|
+
contentHeight.current = height;
|
|
52
|
+
|
|
53
|
+
if (!hasInitialized.current && initialOpen) {
|
|
54
|
+
hasInitialized.current = true;
|
|
55
|
+
animatedHeight.setValue(height);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<FlexView style={[styles.container, style]}>
|
|
61
|
+
<Pressable onPress={toggleDetails} style={styles.header}>
|
|
62
|
+
{typeof title === 'string' ? (
|
|
63
|
+
<Text variant="small-400" color="fg-100">
|
|
64
|
+
{title}
|
|
65
|
+
</Text>
|
|
66
|
+
) : (
|
|
67
|
+
title
|
|
68
|
+
)}
|
|
69
|
+
{canClose && (
|
|
70
|
+
<IconBox icon={isOpen ? 'chevronTop' : 'chevronBottom'} size="sm" iconColor="fg-200" />
|
|
71
|
+
)}
|
|
72
|
+
</Pressable>
|
|
73
|
+
|
|
74
|
+
<Animated.View style={[styles.contentWrapper, { height: animatedHeight }]}>
|
|
75
|
+
<FlexView style={styles.content} onLayout={measureContent}>
|
|
76
|
+
{children}
|
|
77
|
+
</FlexView>
|
|
78
|
+
</Animated.View>
|
|
79
|
+
</FlexView>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Spacing } from '../../utils/ThemeUtil';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
overflow: 'hidden'
|
|
7
|
+
},
|
|
8
|
+
header: {
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'space-between',
|
|
12
|
+
paddingVertical: Spacing.s,
|
|
13
|
+
paddingHorizontal: Spacing.l
|
|
14
|
+
},
|
|
15
|
+
content: {
|
|
16
|
+
paddingHorizontal: Spacing.l,
|
|
17
|
+
paddingBottom: Spacing.l,
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
width: '100%'
|
|
20
|
+
},
|
|
21
|
+
contentWrapper: {
|
|
22
|
+
overflow: 'hidden'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
2
|
import { Image } from '../../components/wui-image';
|
|
3
3
|
import { Text } from '../../components/wui-text';
|
|
4
4
|
import { Button } from '../wui-button';
|
|
@@ -6,13 +6,30 @@ import styles from './styles';
|
|
|
6
6
|
|
|
7
7
|
export interface TokenButtonProps {
|
|
8
8
|
onPress?: () => void;
|
|
9
|
-
|
|
9
|
+
imageUrl?: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
inverse?: boolean;
|
|
12
|
+
style?: StyleProp<ViewStyle>;
|
|
13
|
+
disabled?: boolean;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
export function TokenButton({
|
|
13
|
-
|
|
16
|
+
export function TokenButton({
|
|
17
|
+
imageUrl,
|
|
18
|
+
text,
|
|
19
|
+
inverse,
|
|
20
|
+
onPress,
|
|
21
|
+
style,
|
|
22
|
+
disabled = false
|
|
23
|
+
}: TokenButtonProps) {
|
|
24
|
+
if (!text) {
|
|
14
25
|
return (
|
|
15
|
-
<Button
|
|
26
|
+
<Button
|
|
27
|
+
variant="accent"
|
|
28
|
+
style={[styles.selectButton, style]}
|
|
29
|
+
size="sm"
|
|
30
|
+
onPress={onPress}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
>
|
|
16
33
|
<Text variant="small-600" color="accent-100">
|
|
17
34
|
Select token
|
|
18
35
|
</Text>
|
|
@@ -20,10 +37,22 @@ export function TokenButton({ token, onPress }: TokenButtonProps) {
|
|
|
20
37
|
);
|
|
21
38
|
}
|
|
22
39
|
|
|
40
|
+
const content = [
|
|
41
|
+
imageUrl && (
|
|
42
|
+
<Image key="image" source={imageUrl} style={[styles.image, inverse && styles.imageInverse]} />
|
|
43
|
+
),
|
|
44
|
+
<Text key="text">{text}</Text>
|
|
45
|
+
];
|
|
46
|
+
|
|
23
47
|
return (
|
|
24
|
-
<Button
|
|
25
|
-
|
|
26
|
-
{
|
|
48
|
+
<Button
|
|
49
|
+
variant="shade"
|
|
50
|
+
style={[styles.container, style]}
|
|
51
|
+
size="sm"
|
|
52
|
+
onPress={onPress}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
>
|
|
55
|
+
{inverse ? content.reverse() : content}
|
|
27
56
|
</Button>
|
|
28
57
|
);
|
|
29
58
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useColorScheme } from 'react-native';
|
|
2
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
3
|
+
import type { ThemeMode, ThemeVariables } from '@reown/appkit-common-react-native';
|
|
4
|
+
|
|
5
|
+
import { DarkTheme, LightTheme, getAccentColors } from '../utils/ThemeUtil';
|
|
6
|
+
|
|
7
|
+
type ThemeContextType = {
|
|
8
|
+
themeMode?: ThemeMode;
|
|
9
|
+
themeVariables?: ThemeVariables;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
|
13
|
+
|
|
14
|
+
interface ThemeProviderProps {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
themeMode?: ThemeMode;
|
|
17
|
+
themeVariables?: ThemeVariables;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function ThemeProvider({ children, themeMode, themeVariables }: ThemeProviderProps) {
|
|
21
|
+
return (
|
|
22
|
+
<ThemeContext.Provider value={{ themeMode, themeVariables }}>{children}</ThemeContext.Provider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function useTheme() {
|
|
27
|
+
const context = useContext(ThemeContext);
|
|
28
|
+
const scheme = useColorScheme();
|
|
29
|
+
|
|
30
|
+
// If the theme mode is not set, use the system color scheme
|
|
31
|
+
const themeMode = context?.themeMode ?? scheme;
|
|
32
|
+
const themeVariables = context?.themeVariables ?? {};
|
|
33
|
+
|
|
34
|
+
let Theme = themeMode === 'dark' ? DarkTheme : LightTheme;
|
|
35
|
+
|
|
36
|
+
if (themeVariables.accent) {
|
|
37
|
+
Theme = {
|
|
38
|
+
...Theme,
|
|
39
|
+
...getAccentColors(themeVariables.accent)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return Theme;
|
|
44
|
+
}
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DarkTheme, LightTheme } from '../utils/ThemeUtil';
|
|
1
|
+
import { useTheme as useThemeContext } from '../context/ThemeContext';
|
|
3
2
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return Theme;
|
|
9
|
-
}
|
|
3
|
+
export const useTheme = () => {
|
|
4
|
+
return useThemeContext();
|
|
5
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -42,7 +42,7 @@ export { Link, type LinkProps } from './composites/wui-link';
|
|
|
42
42
|
export { ListItem, type ListItemProps } from './composites/wui-list-item';
|
|
43
43
|
export { ListItemLoader, type ListItemLoaderProps } from './composites/wui-list-item-loader';
|
|
44
44
|
export { ListSocial, type ListSocialProps } from './composites/wui-list-social';
|
|
45
|
-
export { ListToken, type ListTokenProps } from './composites/wui-list-token';
|
|
45
|
+
export { ListToken, ListTokenTotalHeight, type ListTokenProps } from './composites/wui-list-token';
|
|
46
46
|
export { ListTransaction, type ListTransactionProps } from './composites/wui-list-transaction';
|
|
47
47
|
export { ListWallet, type ListWalletProps } from './composites/wui-list-wallet';
|
|
48
48
|
export { Logo, type LogoProps } from './composites/wui-logo';
|
|
@@ -50,12 +50,14 @@ export { LogoSelect, type LogoSelectProps } from './composites/wui-logo-select';
|
|
|
50
50
|
export { NetworkButton, type NetworkButtonProps } from './composites/wui-network-button';
|
|
51
51
|
export { NetworkImage, type NetworkImageProps } from './composites/wui-network-image';
|
|
52
52
|
export { Otp, type OtpProps } from './composites/wui-otp';
|
|
53
|
+
export { Pressable, type PressableProps } from './components/wui-pressable';
|
|
53
54
|
export { Promo, type PromoProps } from './composites/wui-promo';
|
|
54
55
|
export { QrCode, type QrCodeProps } from './composites/wui-qr-code';
|
|
55
56
|
export { SearchBar, type SearchBarProps } from './composites/wui-search-bar';
|
|
56
57
|
export { Snackbar, type SnackbarProps } from './composites/wui-snackbar';
|
|
57
58
|
export { Tabs, type TabsProps } from './composites/wui-tabs';
|
|
58
59
|
export { Tag, type TagProps } from './composites/wui-tag';
|
|
60
|
+
export { Toggle, type ToggleProps } from './composites/wui-toggle';
|
|
59
61
|
export { TokenButton, type TokenButtonProps } from './composites/wui-token-button';
|
|
60
62
|
export { Tooltip, type TooltipProps } from './composites/wui-tooltip';
|
|
61
63
|
export { WalletImage, type WalletImageProps } from './composites/wui-wallet-image';
|
|
@@ -83,4 +85,5 @@ export { TransactionUtil } from './utils/TransactionUtil';
|
|
|
83
85
|
export { Spacing, BorderRadius } from './utils/ThemeUtil';
|
|
84
86
|
|
|
85
87
|
export { useTheme } from './hooks/useTheme';
|
|
88
|
+
export { ThemeProvider } from './context/ThemeContext';
|
|
86
89
|
export { useAnimatedValue } from './hooks/useAnimatedValue';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
1
|
+
import { type LayoutChangeEvent, type StyleProp, type ViewStyle, View } from 'react-native';
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
FlexAlignType,
|
|
@@ -10,10 +10,10 @@ import type {
|
|
|
10
10
|
SpacingType
|
|
11
11
|
} from '../../utils/TypesUtil';
|
|
12
12
|
import { UiUtil } from '../../utils/UiUtil';
|
|
13
|
-
import { LeanView } from '../../components/wui-lean-view';
|
|
14
13
|
|
|
15
14
|
export interface FlexViewProps {
|
|
16
15
|
children?: React.ReactNode;
|
|
16
|
+
onLayout?: (event: LayoutChangeEvent) => void;
|
|
17
17
|
flexDirection?: FlexDirectionType;
|
|
18
18
|
flexWrap?: FlexWrapType;
|
|
19
19
|
flexGrow?: FlexGrowType;
|
|
@@ -45,5 +45,9 @@ export function FlexView(props: FlexViewProps) {
|
|
|
45
45
|
marginLeft: props.margin && UiUtil.getSpacingStyles(props.margin, 3)
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return (
|
|
49
|
+
<View onLayout={props.onLayout} style={[styles, props.style]}>
|
|
50
|
+
{props.children}
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
49
53
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
1
|
+
import { type StyleProp, type ViewStyle, View } from 'react-native';
|
|
2
2
|
import { Text } from '../../components/wui-text';
|
|
3
|
-
import { LeanView } from '../../components/wui-lean-view';
|
|
4
3
|
import { FlexView } from '../../layout/wui-flex';
|
|
5
4
|
import { useTheme } from '../../hooks/useTheme';
|
|
6
5
|
import styles from './styles';
|
|
@@ -14,20 +13,18 @@ export function Separator({ text, style }: SeparatorProps) {
|
|
|
14
13
|
const Theme = useTheme();
|
|
15
14
|
|
|
16
15
|
if (!text) {
|
|
17
|
-
return
|
|
18
|
-
<LeanView style={[styles.single, { backgroundColor: Theme['gray-glass-005'] }, style]} />
|
|
19
|
-
);
|
|
16
|
+
return <View style={[styles.single, { backgroundColor: Theme['gray-glass-005'] }, style]} />;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
return (
|
|
23
20
|
<FlexView flexDirection="row" alignItems="center" style={style}>
|
|
24
|
-
<
|
|
21
|
+
<View
|
|
25
22
|
style={[styles.divider, styles.marginRight, { backgroundColor: Theme['gray-glass-005'] }]}
|
|
26
23
|
/>
|
|
27
24
|
<Text variant="small-500" color="fg-300">
|
|
28
25
|
{text}
|
|
29
26
|
</Text>
|
|
30
|
-
<
|
|
27
|
+
<View
|
|
31
28
|
style={[styles.divider, styles.marginLeft, { backgroundColor: Theme['gray-glass-005'] }]}
|
|
32
29
|
/>
|
|
33
30
|
</FlexView>
|
package/src/utils/ThemeUtil.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
import { transparentize, darken, lighten } from 'polished';
|
|
2
|
+
|
|
1
3
|
import type { SpacingType, ThemeKeys } from './TypesUtil';
|
|
2
4
|
|
|
5
|
+
export const getAccentColors = (baseAccentColor: string) => {
|
|
6
|
+
return {
|
|
7
|
+
'accent-100': baseAccentColor,
|
|
8
|
+
'accent-090': lighten(0.05, baseAccentColor),
|
|
9
|
+
'accent-080': lighten(0.1, baseAccentColor),
|
|
10
|
+
'accent-020': darken(0.1, baseAccentColor),
|
|
11
|
+
'accent-glass-090': transparentize(0.1, baseAccentColor),
|
|
12
|
+
'accent-glass-080': transparentize(0.2, baseAccentColor),
|
|
13
|
+
'accent-glass-020': transparentize(0.8, baseAccentColor),
|
|
14
|
+
'accent-glass-015': transparentize(0.85, baseAccentColor),
|
|
15
|
+
'accent-glass-010': transparentize(0.9, baseAccentColor),
|
|
16
|
+
'accent-glass-005': transparentize(0.95, baseAccentColor),
|
|
17
|
+
'accent-glass-002': transparentize(0.98, baseAccentColor)
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
3
21
|
export const DarkTheme: { [key in ThemeKeys]: string } = {
|
|
4
22
|
'accent-100': '#667DFF',
|
|
5
23
|
'accent-090': '#7388FD',
|