@reown/appkit-ui-react-native 2.0.0-alpha.2 → 2.0.0-alpha.4

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.
Files changed (179) hide show
  1. package/lib/commonjs/assets/svg/Reown.js +47 -0
  2. package/lib/commonjs/assets/svg/Reown.js.map +1 -0
  3. package/lib/commonjs/components/wui-card/styles.js +2 -1
  4. package/lib/commonjs/components/wui-card/styles.js.map +1 -1
  5. package/lib/commonjs/components/wui-icon/index.js +2 -0
  6. package/lib/commonjs/components/wui-icon/index.js.map +1 -1
  7. package/lib/commonjs/components/wui-modal/index.js +138 -0
  8. package/lib/commonjs/components/wui-modal/index.js.map +1 -0
  9. package/lib/commonjs/components/wui-modal/styles.js +31 -0
  10. package/lib/commonjs/components/wui-modal/styles.js.map +1 -0
  11. package/lib/commonjs/components/wui-shimmer/index.js +92 -32
  12. package/lib/commonjs/components/wui-shimmer/index.js.map +1 -1
  13. package/lib/commonjs/composites/wui-account-button/index.js +2 -2
  14. package/lib/commonjs/composites/wui-account-button/index.js.map +1 -1
  15. package/lib/commonjs/composites/wui-button/index.js +5 -5
  16. package/lib/commonjs/composites/wui-button/index.js.map +1 -1
  17. package/lib/commonjs/composites/wui-card-select/index.js +2 -2
  18. package/lib/commonjs/composites/wui-card-select/index.js.map +1 -1
  19. package/lib/commonjs/composites/wui-card-select-loader/index.js +7 -3
  20. package/lib/commonjs/composites/wui-card-select-loader/index.js.map +1 -1
  21. package/lib/commonjs/composites/wui-chip/index.js +5 -5
  22. package/lib/commonjs/composites/wui-chip/index.js.map +1 -1
  23. package/lib/commonjs/composites/wui-email-input/index.js +3 -3
  24. package/lib/commonjs/composites/wui-email-input/index.js.map +1 -1
  25. package/lib/commonjs/composites/wui-input-text/index.js +2 -2
  26. package/lib/commonjs/composites/wui-input-text/index.js.map +1 -1
  27. package/lib/commonjs/composites/wui-link/index.js +4 -4
  28. package/lib/commonjs/composites/wui-link/index.js.map +1 -1
  29. package/lib/commonjs/composites/wui-list-transaction/index.js +2 -2
  30. package/lib/commonjs/composites/wui-list-transaction/index.js.map +1 -1
  31. package/lib/commonjs/composites/wui-logo-select/index.js +1 -1
  32. package/lib/commonjs/composites/wui-logo-select/index.js.map +1 -1
  33. package/lib/commonjs/composites/wui-otp/index.js +1 -1
  34. package/lib/commonjs/composites/wui-otp/index.js.map +1 -1
  35. package/lib/commonjs/composites/wui-qr-code/index.js +7 -25
  36. package/lib/commonjs/composites/wui-qr-code/index.js.map +1 -1
  37. package/lib/commonjs/composites/wui-qr-code/styles.js +0 -3
  38. package/lib/commonjs/composites/wui-qr-code/styles.js.map +1 -1
  39. package/lib/commonjs/composites/wui-search-bar/index.js +2 -2
  40. package/lib/commonjs/composites/wui-search-bar/index.js.map +1 -1
  41. package/lib/commonjs/composites/wui-tabs/index.js +2 -2
  42. package/lib/commonjs/composites/wui-tabs/index.js.map +1 -1
  43. package/lib/commonjs/composites/wui-toggle/index.js +2 -2
  44. package/lib/commonjs/composites/wui-toggle/index.js.map +1 -1
  45. package/lib/commonjs/composites/wui-token-button/index.js +4 -4
  46. package/lib/commonjs/composites/wui-token-button/index.js.map +1 -1
  47. package/lib/commonjs/composites/wui-transaction-visual/index.js +3 -3
  48. package/lib/commonjs/composites/wui-transaction-visual/index.js.map +1 -1
  49. package/lib/commonjs/composites/wui-wallet-image/index.js +2 -2
  50. package/lib/commonjs/composites/wui-wallet-image/index.js.map +1 -1
  51. package/lib/commonjs/hooks/useCustomDimensions.js +41 -0
  52. package/lib/commonjs/hooks/useCustomDimensions.js.map +1 -0
  53. package/lib/commonjs/index.js +14 -0
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/layout/wui-flex/index.js +3 -0
  56. package/lib/commonjs/layout/wui-flex/index.js.map +1 -1
  57. package/lib/commonjs/utils/QRCodeUtil.js +2 -2
  58. package/lib/commonjs/utils/QRCodeUtil.js.map +1 -1
  59. package/lib/commonjs/utils/UiUtil.js +1 -1
  60. package/lib/commonjs/utils/UiUtil.js.map +1 -1
  61. package/lib/module/assets/svg/Reown.js +42 -0
  62. package/lib/module/assets/svg/Reown.js.map +1 -0
  63. package/lib/module/components/wui-card/styles.js +2 -1
  64. package/lib/module/components/wui-card/styles.js.map +1 -1
  65. package/lib/module/components/wui-icon/index.js +2 -0
  66. package/lib/module/components/wui-icon/index.js.map +1 -1
  67. package/lib/module/components/wui-modal/index.js +133 -0
  68. package/lib/module/components/wui-modal/index.js.map +1 -0
  69. package/lib/module/components/wui-modal/styles.js +27 -0
  70. package/lib/module/components/wui-modal/styles.js.map +1 -0
  71. package/lib/module/components/wui-shimmer/index.js +93 -32
  72. package/lib/module/components/wui-shimmer/index.js.map +1 -1
  73. package/lib/module/composites/wui-account-button/index.js +2 -2
  74. package/lib/module/composites/wui-account-button/index.js.map +1 -1
  75. package/lib/module/composites/wui-button/index.js +5 -5
  76. package/lib/module/composites/wui-button/index.js.map +1 -1
  77. package/lib/module/composites/wui-card-select/index.js +2 -2
  78. package/lib/module/composites/wui-card-select/index.js.map +1 -1
  79. package/lib/module/composites/wui-card-select-loader/index.js +5 -1
  80. package/lib/module/composites/wui-card-select-loader/index.js.map +1 -1
  81. package/lib/module/composites/wui-chip/index.js +5 -5
  82. package/lib/module/composites/wui-chip/index.js.map +1 -1
  83. package/lib/module/composites/wui-email-input/index.js +3 -3
  84. package/lib/module/composites/wui-email-input/index.js.map +1 -1
  85. package/lib/module/composites/wui-input-text/index.js +2 -2
  86. package/lib/module/composites/wui-input-text/index.js.map +1 -1
  87. package/lib/module/composites/wui-link/index.js +4 -4
  88. package/lib/module/composites/wui-link/index.js.map +1 -1
  89. package/lib/module/composites/wui-list-transaction/index.js +2 -2
  90. package/lib/module/composites/wui-list-transaction/index.js.map +1 -1
  91. package/lib/module/composites/wui-logo-select/index.js +1 -1
  92. package/lib/module/composites/wui-logo-select/index.js.map +1 -1
  93. package/lib/module/composites/wui-otp/index.js +1 -1
  94. package/lib/module/composites/wui-otp/index.js.map +1 -1
  95. package/lib/module/composites/wui-qr-code/index.js +7 -25
  96. package/lib/module/composites/wui-qr-code/index.js.map +1 -1
  97. package/lib/module/composites/wui-qr-code/styles.js +0 -3
  98. package/lib/module/composites/wui-qr-code/styles.js.map +1 -1
  99. package/lib/module/composites/wui-search-bar/index.js +2 -2
  100. package/lib/module/composites/wui-search-bar/index.js.map +1 -1
  101. package/lib/module/composites/wui-tabs/index.js +2 -2
  102. package/lib/module/composites/wui-tabs/index.js.map +1 -1
  103. package/lib/module/composites/wui-toggle/index.js +2 -2
  104. package/lib/module/composites/wui-toggle/index.js.map +1 -1
  105. package/lib/module/composites/wui-token-button/index.js +4 -4
  106. package/lib/module/composites/wui-token-button/index.js.map +1 -1
  107. package/lib/module/composites/wui-transaction-visual/index.js +3 -3
  108. package/lib/module/composites/wui-transaction-visual/index.js.map +1 -1
  109. package/lib/module/composites/wui-wallet-image/index.js +2 -2
  110. package/lib/module/composites/wui-wallet-image/index.js.map +1 -1
  111. package/lib/module/hooks/useCustomDimensions.js +38 -0
  112. package/lib/module/hooks/useCustomDimensions.js.map +1 -0
  113. package/lib/module/index.js +11 -0
  114. package/lib/module/index.js.map +1 -1
  115. package/lib/module/layout/wui-flex/index.js +3 -0
  116. package/lib/module/layout/wui-flex/index.js.map +1 -1
  117. package/lib/module/utils/QRCodeUtil.js +3 -3
  118. package/lib/module/utils/QRCodeUtil.js.map +1 -1
  119. package/lib/module/utils/UiUtil.js +1 -1
  120. package/lib/module/utils/UiUtil.js.map +1 -1
  121. package/lib/typescript/assets/svg/Reown.d.ts +4 -0
  122. package/lib/typescript/assets/svg/Reown.d.ts.map +1 -0
  123. package/lib/typescript/components/wui-card/styles.d.ts +1 -0
  124. package/lib/typescript/components/wui-card/styles.d.ts.map +1 -1
  125. package/lib/typescript/components/wui-icon/index.d.ts.map +1 -1
  126. package/lib/typescript/components/wui-modal/index.d.ts +8 -0
  127. package/lib/typescript/components/wui-modal/index.d.ts.map +1 -0
  128. package/lib/typescript/components/wui-modal/styles.d.ts +24 -0
  129. package/lib/typescript/components/wui-modal/styles.d.ts.map +1 -0
  130. package/lib/typescript/components/wui-shimmer/index.d.ts +11 -3
  131. package/lib/typescript/components/wui-shimmer/index.d.ts.map +1 -1
  132. package/lib/typescript/composites/wui-card-select-loader/index.d.ts +3 -1
  133. package/lib/typescript/composites/wui-card-select-loader/index.d.ts.map +1 -1
  134. package/lib/typescript/composites/wui-qr-code/index.d.ts.map +1 -1
  135. package/lib/typescript/composites/wui-qr-code/styles.d.ts +0 -3
  136. package/lib/typescript/composites/wui-qr-code/styles.d.ts.map +1 -1
  137. package/lib/typescript/composites/wui-token-button/index.d.ts.map +1 -1
  138. package/lib/typescript/hooks/useCustomDimensions.d.ts +14 -0
  139. package/lib/typescript/hooks/useCustomDimensions.d.ts.map +1 -0
  140. package/lib/typescript/index.d.ts +7 -0
  141. package/lib/typescript/index.d.ts.map +1 -1
  142. package/lib/typescript/layout/wui-flex/index.d.ts +3 -0
  143. package/lib/typescript/layout/wui-flex/index.d.ts.map +1 -1
  144. package/lib/typescript/utils/TypesUtil.d.ts +1 -1
  145. package/lib/typescript/utils/TypesUtil.d.ts.map +1 -1
  146. package/lib/typescript/utils/UiUtil.d.ts +1 -1
  147. package/lib/typescript/utils/UiUtil.d.ts.map +1 -1
  148. package/package.json +2 -2
  149. package/src/assets/svg/Reown.tsx +40 -0
  150. package/src/components/wui-card/styles.ts +2 -1
  151. package/src/components/wui-icon/index.tsx +2 -0
  152. package/src/components/wui-modal/index.tsx +142 -0
  153. package/src/components/wui-modal/styles.ts +25 -0
  154. package/src/components/wui-shimmer/index.tsx +105 -39
  155. package/src/composites/wui-account-button/index.tsx +2 -2
  156. package/src/composites/wui-button/index.tsx +5 -5
  157. package/src/composites/wui-card-select/index.tsx +2 -2
  158. package/src/composites/wui-card-select-loader/index.tsx +5 -1
  159. package/src/composites/wui-chip/index.tsx +5 -5
  160. package/src/composites/wui-email-input/index.tsx +3 -3
  161. package/src/composites/wui-input-text/index.tsx +1 -1
  162. package/src/composites/wui-link/index.tsx +4 -4
  163. package/src/composites/wui-list-transaction/index.tsx +2 -2
  164. package/src/composites/wui-logo-select/index.tsx +1 -1
  165. package/src/composites/wui-otp/index.tsx +1 -1
  166. package/src/composites/wui-qr-code/index.tsx +6 -18
  167. package/src/composites/wui-qr-code/styles.ts +0 -3
  168. package/src/composites/wui-search-bar/index.tsx +2 -2
  169. package/src/composites/wui-tabs/index.tsx +2 -2
  170. package/src/composites/wui-toggle/index.tsx +2 -2
  171. package/src/composites/wui-token-button/index.tsx +4 -2
  172. package/src/composites/wui-transaction-visual/index.tsx +4 -4
  173. package/src/composites/wui-wallet-image/index.tsx +2 -2
  174. package/src/hooks/useCustomDimensions.ts +38 -0
  175. package/src/index.ts +8 -0
  176. package/src/layout/wui-flex/index.tsx +6 -0
  177. package/src/utils/QRCodeUtil.tsx +3 -3
  178. package/src/utils/TypesUtil.ts +1 -0
  179. package/src/utils/UiUtil.ts +2 -2
@@ -1,66 +1,132 @@
1
- import { Svg, Rect } from 'react-native-svg';
2
- import { Animated, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
1
+ import { Animated, StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native';
2
+ import { memo, useEffect, useRef, useState } from 'react';
3
3
  import { useTheme } from '../../hooks/useTheme';
4
4
 
5
- const AnimatedRect = Animated.createAnimatedComponent(Rect);
5
+ type PercentString = `${number}%`;
6
+ type ShimmerDimension = number | PercentString;
6
7
 
7
8
  export interface ShimmerProps {
8
- width?: number | string;
9
- height?: number | string;
9
+ width?: ShimmerDimension;
10
+ height?: ShimmerDimension;
10
11
  duration?: number;
11
12
  borderRadius?: number;
12
13
  backgroundColor?: string;
13
14
  foregroundColor?: string;
15
+ highlightWidthRatio?: number;
16
+ highlightOpacity?: number;
17
+ angle?: number; // in degrees
14
18
  style?: StyleProp<ViewStyle>;
15
19
  }
16
20
 
17
- export const Shimmer = ({
21
+ function _Shimmer({
18
22
  width = 200,
19
23
  height = 200,
20
24
  duration = 1000,
21
25
  borderRadius = 0,
22
26
  backgroundColor,
23
27
  foregroundColor,
28
+ highlightWidthRatio = 0.3,
29
+ highlightOpacity = 0.5,
30
+ angle = 20,
24
31
  style
25
- }: ShimmerProps) => {
26
- const animatedValue = new Animated.Value(0);
32
+ }: ShimmerProps) {
27
33
  const Theme = useTheme();
28
34
 
29
- const animatedProps = {
30
- fill: animatedValue.interpolate({
31
- inputRange: [0, 0.5, 1],
32
- outputRange: [
33
- backgroundColor ?? Theme['bg-200'],
34
- foregroundColor ?? Theme['bg-300'],
35
- backgroundColor ?? Theme['bg-200']
36
- ]
37
- }),
35
+ const [measuredWidth, setMeasuredWidth] = useState<number | null>(null);
36
+ const [measuredHeight, setMeasuredHeight] = useState<number | null>(null);
37
+
38
+ const translateRef = useRef(new Animated.Value(0));
39
+ const loopRef = useRef<Animated.CompositeAnimation | null>(null);
40
+
41
+ useEffect(() => {
42
+ if (!measuredWidth) {
43
+ return undefined;
44
+ }
45
+ const translateX = translateRef.current;
46
+ translateX.setValue(0);
47
+ const timing = Animated.timing(translateX, {
48
+ toValue: 1,
49
+ duration,
50
+ useNativeDriver: true
51
+ });
52
+ const loop = Animated.loop(timing);
53
+ loopRef.current = loop;
54
+
55
+ loop.start();
56
+
57
+ return () => {
58
+ loop.stop();
59
+ if (loopRef.current === loop) {
60
+ loopRef.current = null;
61
+ }
62
+ translateX.stopAnimation(() => {
63
+ translateX.setValue(0);
64
+ });
65
+ };
66
+ }, [duration, measuredWidth]);
67
+
68
+ const baseColor = backgroundColor ?? Theme['bg-200'];
69
+ const highlightColor = foregroundColor ?? Theme['bg-300'];
70
+
71
+ const onLayout = (event: any) => {
72
+ const { width: w, height: h } = event.nativeEvent.layout;
73
+ // Update measurements whenever they change to adapt to dynamic layout/orientation
74
+ if (measuredWidth == null || Math.abs(w - measuredWidth) > 0.5) {
75
+ setMeasuredWidth(w);
76
+ }
77
+ if (measuredHeight == null || Math.abs(h - measuredHeight) > 0.5) {
78
+ setMeasuredHeight(h);
79
+ }
80
+ };
81
+
82
+ // Compute animated translateX only if we have width
83
+ let animatedTranslateX: any = 0;
84
+ let bandWidth = 0;
85
+ if (measuredWidth) {
86
+ bandWidth = Math.max(8, measuredWidth * highlightWidthRatio);
87
+ const travel = measuredWidth + bandWidth * 2;
88
+ animatedTranslateX = translateRef.current.interpolate({
89
+ inputRange: [0, 1],
90
+ outputRange: [-bandWidth, travel - bandWidth]
91
+ });
92
+ }
93
+
94
+ const containerStyle: ViewStyle = {
38
95
  width,
39
96
  height,
40
- x: 0,
41
- y: 0,
42
- rx: borderRadius,
43
- ry: borderRadius
97
+ borderRadius,
98
+ overflow: 'hidden',
99
+ borderWidth: StyleSheet.hairlineWidth,
100
+ borderColor: Theme['bg-300'],
101
+ backgroundColor: baseColor
44
102
  };
45
103
 
46
- Animated.loop(
47
- Animated.timing(animatedValue, {
48
- toValue: 1,
49
- duration,
50
- useNativeDriver: false
51
- })
52
- ).start();
104
+ const bandStyle: ViewStyle = {
105
+ position: 'absolute',
106
+ top: measuredHeight ? -measuredHeight * 0.25 : 0,
107
+ bottom: measuredHeight ? -measuredHeight * 0.25 : 0,
108
+ width: bandWidth,
109
+ backgroundColor: highlightColor,
110
+ opacity: highlightOpacity
111
+ };
53
112
 
54
113
  return (
55
- <Svg
56
- width={width}
57
- height={height}
58
- style={[
59
- { borderWidth: StyleSheet.hairlineWidth, borderColor: Theme['bg-300'], borderRadius },
60
- style
61
- ]}
62
- >
63
- <AnimatedRect {...animatedProps} />
64
- </Svg>
114
+ <View onLayout={onLayout} style={[containerStyle, style]}>
115
+ {measuredWidth && measuredHeight ? (
116
+ <Animated.View
117
+ pointerEvents="none"
118
+ style={[
119
+ bandStyle,
120
+ {
121
+ transform: [{ translateX: animatedTranslateX }, { rotate: `${angle}deg` }]
122
+ }
123
+ ]}
124
+ />
125
+ ) : null}
126
+ </View>
65
127
  );
66
- };
128
+ }
129
+
130
+ export const Shimmer = memo(_Shimmer, () => {
131
+ return true;
132
+ });
@@ -114,11 +114,11 @@ export function AccountButton({
114
114
  borderWidth={2}
115
115
  style={[styles.image, !avatarSrc && styles.avatarPlaceholder]}
116
116
  />
117
- {address && (
117
+ {address ? (
118
118
  <Text variant="paragraph-500" color="fg-200" style={styles.address}>
119
119
  {formattedAddress}
120
120
  </Text>
121
- )}
121
+ ) : null}
122
122
  </View>
123
123
  </AnimatedPressable>
124
124
  );
@@ -90,15 +90,15 @@ export function Button({
90
90
  {...rest}
91
91
  >
92
92
  <FlexView flexDirection="row" alignItems="center" justifyContent="center">
93
- {iconLeft && (
93
+ {iconLeft ? (
94
94
  <Icon
95
95
  color={iconColor}
96
96
  name={iconLeft}
97
97
  size={iconSize}
98
98
  style={[styles.iconLeft, iconStyle]}
99
99
  />
100
- )}
101
- {loading && <LoadingSpinner color={iconColor} size="md" />}
100
+ ) : null}
101
+ {loading ? <LoadingSpinner color={iconColor} size="md" /> : null}
102
102
  {!loading &&
103
103
  (typeof children === 'string' ? (
104
104
  <Text
@@ -110,14 +110,14 @@ export function Button({
110
110
  ) : (
111
111
  children
112
112
  ))}
113
- {iconRight && (
113
+ {iconRight ? (
114
114
  <Icon
115
115
  color={iconColor}
116
116
  name={iconRight}
117
117
  size={iconSize}
118
118
  style={[styles.iconRight, iconStyle]}
119
119
  />
120
- )}
120
+ ) : null}
121
121
  </FlexView>
122
122
  </AnimatedPressable>
123
123
  );
@@ -86,7 +86,7 @@ function _CardSelect({
86
86
  imageSrc={imageSrc}
87
87
  imageHeaders={imageHeaders}
88
88
  size="md"
89
- style={disabled && styles.disabledImage}
89
+ style={disabled ? styles.disabledImage : null}
90
90
  selected={selected}
91
91
  disabled={disabled}
92
92
  />
@@ -100,5 +100,5 @@ function _CardSelect({
100
100
  }
101
101
 
102
102
  export const CardSelect = memo(_CardSelect, (prevProps, nextProps) => {
103
- return prevProps.name === nextProps.name;
103
+ return prevProps.name === nextProps.name && prevProps.imageSrc === nextProps.imageSrc;
104
104
  });
@@ -1,3 +1,4 @@
1
+ import { memo } from 'react';
1
2
  import { type StyleProp, type ViewStyle } from 'react-native';
2
3
  import { BorderRadius, Spacing, WalletImageSize } from '../../utils/ThemeUtil';
3
4
  import { useTheme } from '../../hooks/useTheme';
@@ -11,7 +12,7 @@ export interface CardSelectLoaderProps {
11
12
  style?: StyleProp<ViewStyle>;
12
13
  }
13
14
 
14
- export function CardSelectLoader({ style }: CardSelectLoaderProps) {
15
+ export function _CardSelectLoader({ style }: CardSelectLoaderProps) {
15
16
  const Theme = useTheme();
16
17
 
17
18
  return (
@@ -34,3 +35,6 @@ export function CardSelectLoader({ style }: CardSelectLoaderProps) {
34
35
  </FlexView>
35
36
  );
36
37
  }
38
+ export const CardSelectLoader = memo(_CardSelectLoader, () => {
39
+ return true;
40
+ });
@@ -80,7 +80,7 @@ export function Chip({
80
80
  onPressOut={onPressOut}
81
81
  onPress={handlePress}
82
82
  >
83
- {imageSrc && (
83
+ {imageSrc ? (
84
84
  <Image
85
85
  style={[
86
86
  styles.image,
@@ -90,22 +90,22 @@ export function Chip({
90
90
  ]}
91
91
  source={imageSrc}
92
92
  />
93
- )}
94
- {leftIcon && <Icon name={leftIcon} color={themedTextColor as ColorType} />}
93
+ ) : null}
94
+ {leftIcon ? <Icon name={leftIcon} color={themedTextColor as ColorType} /> : null}
95
95
  <Text
96
96
  variant={size === 'md' ? 'paragraph-600' : 'small-600'}
97
97
  style={[styles.link, { color: Theme[themedTextColor] }]}
98
98
  >
99
99
  {label}
100
100
  </Text>
101
- {rightIcon && (
101
+ {rightIcon ? (
102
102
  <Icon
103
103
  name={rightIcon}
104
104
  size={iconSize}
105
105
  color={themedTextColor as ColorType}
106
106
  style={styles.icon}
107
107
  />
108
- )}
108
+ ) : null}
109
109
  </AnimatedPressable>
110
110
  );
111
111
  }
@@ -84,7 +84,7 @@ export function EmailInput({
84
84
  return (
85
85
  <RightIcon
86
86
  loading={loading}
87
- showChevron={submitEnabled && !errorMessage}
87
+ showChevron={submitEnabled ? !errorMessage : false}
88
88
  onPress={handleChevronPress}
89
89
  />
90
90
  );
@@ -107,11 +107,11 @@ export function EmailInput({
107
107
  >
108
108
  {rightIconTemplate()}
109
109
  </InputText>
110
- {errorMessage && (
110
+ {errorMessage ? (
111
111
  <Text color="error-100" variant="tiny-500" style={styles.text}>
112
112
  {errorMessage}
113
113
  </Text>
114
- )}
114
+ ) : null}
115
115
  </View>
116
116
  );
117
117
  }
@@ -113,7 +113,7 @@ export const InputText = forwardRef<InputRef, InputTextProps>(
113
113
  disabled && { backgroundColor: Theme['gray-glass-002'] }
114
114
  ]}
115
115
  >
116
- {icon && <Icon name={icon} size="md" color="fg-275" style={styles.icon} />}
116
+ {icon ? <Icon name={icon} size="md" color="fg-275" style={styles.icon} /> : null}
117
117
  <TextInput
118
118
  ref={inputRef}
119
119
  onFocus={handleFocus}
@@ -54,15 +54,15 @@ export function Link({
54
54
  {...rest}
55
55
  >
56
56
  <FlexView flexDirection="row" alignItems="center" justifyContent="center">
57
- {iconLeft && (
57
+ {iconLeft ? (
58
58
  <Icon color={_color} name={iconLeft} size={iconSize} style={styles.iconLeft} />
59
- )}
59
+ ) : null}
60
60
  <Text variant={size === 'md' ? 'paragraph-600' : 'small-600'} color={_color}>
61
61
  {children}
62
62
  </Text>
63
- {iconRight && (
63
+ {iconRight ? (
64
64
  <Icon color={_color} name={iconRight} size={iconSize} style={styles.iconRight} />
65
- )}
65
+ ) : null}
66
66
  </FlexView>
67
67
  </AnimatedPressable>
68
68
  );
@@ -38,7 +38,7 @@ export function ListTransaction({
38
38
  <FlexView flexDirection="row" alignItems="center" style={styles.middleContainer}>
39
39
  <FlexView justifyContent="center" alignItems="flex-start">
40
40
  <FlexView flexDirection="row" alignItems="center">
41
- {type && (
41
+ {type ? (
42
42
  <IconBox
43
43
  icon={getIcon(type)}
44
44
  size="sm"
@@ -47,7 +47,7 @@ export function ListTransaction({
47
47
  border
48
48
  borderColor="bg-100"
49
49
  />
50
- )}
50
+ ) : null}
51
51
  <Text variant="paragraph-500" color="fg-100">
52
52
  {getTypeLabel(type)}
53
53
  </Text>
@@ -29,7 +29,7 @@ export function LogoSelect({ logo, disabled, style, onPress }: LogoSelectProps)
29
29
  style={[styles.box, { backgroundColor: animatedValue }, style]}
30
30
  disabled={disabled}
31
31
  >
32
- <Logo logo={logo} style={disabled && styles.disabled} />
32
+ <Logo logo={logo} style={disabled ? styles.disabled : null} />
33
33
  </AnimatedPressable>
34
34
  );
35
35
  }
@@ -82,7 +82,7 @@ export function Otp({ length, style, onChangeText, autoFocus }: OtpProps) {
82
82
  <View style={styles.container}>
83
83
  {Array.from({ length }).map((_, index) => (
84
84
  <InputNumeric
85
- autoFocus={autoFocus && index === 0}
85
+ autoFocus={autoFocus ? index === 0 : undefined}
86
86
  key={index}
87
87
  style={style}
88
88
  value={value[index] || ''}
@@ -4,8 +4,6 @@ import Svg from 'react-native-svg';
4
4
  import { Icon } from '../../components/wui-icon';
5
5
  import { Image } from '../../components/wui-image';
6
6
  import { Shimmer } from '../../components/wui-shimmer';
7
- import { Text } from '../../components/wui-text';
8
- import { FlexView } from '../../layout/wui-flex';
9
7
  import { QRCodeUtil } from '../../utils/QRCodeUtil';
10
8
  import { BorderRadius, LightTheme, Spacing } from '../../utils/ThemeUtil';
11
9
  import type { IconType } from '../../utils/TypesUtil';
@@ -21,8 +19,6 @@ export interface QrCodeProps {
21
19
  style?: StyleProp<ViewStyle>;
22
20
  }
23
21
 
24
- const LABEL_HEIGHT = 18;
25
-
26
22
  export function QrCode({ size, uri, imageSrc, testID, arenaClear, icon, style }: QrCodeProps) {
27
23
  const Theme = LightTheme;
28
24
  const containerPadding = Spacing.l;
@@ -66,25 +62,17 @@ export function QrCode({ size, uri, imageSrc, testID, arenaClear, icon, style }:
66
62
  <View
67
63
  style={[
68
64
  styles.container,
69
- { width: size, backgroundColor: Theme['bg-100'], padding: containerPadding },
65
+ { width: size, backgroundColor: Theme['inverse-100'], padding: containerPadding },
70
66
  style
71
67
  ]}
72
68
  testID={testID}
73
69
  >
74
- <FlexView alignItems="center" justifyContent="center">
75
- <Svg height={qrSize} width={qrSize}>
76
- {dots}
77
- </Svg>
78
- {logoTemplate()}
79
- </FlexView>
80
- <Text variant="small-500" color="fg-150" style={[styles.label, { height: LABEL_HEIGHT }]}>
81
- UX by{' '}
82
- <Text variant="small-500" color="inverse-000">
83
- Reown
84
- </Text>
85
- </Text>
70
+ <Svg height={qrSize} width={qrSize}>
71
+ {dots}
72
+ </Svg>
73
+ {logoTemplate()}
86
74
  </View>
87
75
  ) : (
88
- <Shimmer width={size} height={size + LABEL_HEIGHT} borderRadius={BorderRadius.l} />
76
+ <Shimmer width={size} height={size} borderRadius={BorderRadius.l} />
89
77
  );
90
78
  }
@@ -11,8 +11,5 @@ export default StyleSheet.create({
11
11
  },
12
12
  icon: {
13
13
  position: 'absolute'
14
- },
15
- label: {
16
- marginTop: Spacing.s
17
14
  }
18
15
  });
@@ -41,7 +41,7 @@ export function SearchBar({
41
41
  returnKeyType="search"
42
42
  disableFullscreenUI
43
43
  >
44
- {showClear && (
44
+ {showClear ? (
45
45
  <InputElement
46
46
  icon="close"
47
47
  style={{ marginRight: Spacing['4xs'] }}
@@ -51,7 +51,7 @@ export function SearchBar({
51
51
  handleChangeText('');
52
52
  }}
53
53
  />
54
- )}
54
+ ) : null}
55
55
  </InputText>
56
56
  </FlexView>
57
57
  );
@@ -72,14 +72,14 @@ export function Tabs({ tabs, onTabChange, style }: TabsProps) {
72
72
  key={isString ? option : option.label}
73
73
  style={[styles.tabItem, { width: tabWidth }]}
74
74
  >
75
- {!isString && option.icon && (
75
+ {!isString && option.icon ? (
76
76
  <Icon
77
77
  name={option.icon}
78
78
  size="xs"
79
79
  color={isActive ? 'fg-100' : 'fg-200'}
80
80
  style={styles.tabIcon}
81
81
  />
82
- )}
82
+ ) : null}
83
83
  <Text variant="small-600" color={isActive ? 'fg-100' : 'fg-200'}>
84
84
  {isString ? option : option.label}
85
85
  </Text>
@@ -74,9 +74,9 @@ export function Toggle({
74
74
  ) : (
75
75
  title
76
76
  )}
77
- {canClose && (
77
+ {canClose ? (
78
78
  <IconBox icon={isOpen ? 'chevronTop' : 'chevronBottom'} size="sm" iconColor="fg-200" />
79
- )}
79
+ ) : null}
80
80
  </Pressable>
81
81
 
82
82
  <Animated.View style={[styles.contentWrapper, { height: animatedHeight }]}>
@@ -59,7 +59,7 @@ export function TokenButton({
59
59
  source={imageUrl}
60
60
  style={[styles.image, { backgroundColor: Theme['inverse-100'] }]}
61
61
  />
62
- {renderClip && <View style={styles.clipContainer}>{renderClip}</View>}
62
+ {renderClip ? <View style={styles.clipContainer}>{renderClip}</View> : null}
63
63
  </View>
64
64
  ),
65
65
  <Text key="text">{text}</Text>
@@ -75,7 +75,9 @@ export function TokenButton({
75
75
  testID={testID}
76
76
  >
77
77
  {inverse ? content.reverse() : content}
78
- {chevron && <Icon name="chevronBottom" size="xxs" color="fg-150" style={styles.chevron} />}
78
+ {chevron ? (
79
+ <Icon name="chevronBottom" size="xxs" color="fg-150" style={styles.chevron} />
80
+ ) : null}
79
81
  </Button>
80
82
  );
81
83
  }
@@ -32,13 +32,13 @@ export function TransactionVisual({ images, networkSrc, isAllNFT }: TransactionV
32
32
  <Icon name={isFirstNFT ? 'nftPlaceholder' : 'coinPlaceholder'} size="sm" color="fg-200" />
33
33
  </FlexView>
34
34
  )}
35
- {hasOneImage && firstImage?.url && (
35
+ {hasOneImage && firstImage?.url ? (
36
36
  <Image
37
37
  source={firstImage.url}
38
38
  style={[styles.image, firstImage?.type === 'NFT' && styles.imageNft, { backgroundColor }]}
39
39
  />
40
- )}
41
- {hasTwoImages && firstImage?.url && secondImage?.url && (
40
+ ) : null}
41
+ {hasTwoImages && firstImage?.url && secondImage?.url ? (
42
42
  <FlexView flexDirection="row" padding={['0', 's', '0', '0']}>
43
43
  <FlexView style={styles.halfContainer}>
44
44
  <Image
@@ -58,7 +58,7 @@ export function TransactionVisual({ images, networkSrc, isAllNFT }: TransactionV
58
58
  />
59
59
  </FlexView>
60
60
  </FlexView>
61
- )}
61
+ ) : null}
62
62
  <FlexView
63
63
  alignItems="center"
64
64
  justifyContent="center"
@@ -66,7 +66,7 @@ export function WalletImage({
66
66
  return (
67
67
  <Animated.View style={style}>
68
68
  {templateVisual()}
69
- {border && (
69
+ {border ? (
70
70
  <View
71
71
  style={[
72
72
  styles.border,
@@ -79,7 +79,7 @@ export function WalletImage({
79
79
  }
80
80
  ]}
81
81
  />
82
- )}
82
+ ) : null}
83
83
  </Animated.View>
84
84
  );
85
85
  }
@@ -0,0 +1,38 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+
4
+ /**
5
+ * Hook used to get the width of the screen and the padding needed to accomplish portrait and landscape modes.
6
+ * @returns { width: number, isPortrait: boolean, isLandscape: boolean, padding: number }
7
+ */
8
+
9
+ type CustomDimensionsType = {
10
+ maxWidth: number;
11
+ maxHeight: number;
12
+ isPortrait: boolean;
13
+ isLandscape: boolean;
14
+ padding: number;
15
+ };
16
+
17
+ const MAX_HEIGHT_PERCENTAGE = 0.9;
18
+
19
+ const getMaxHeight = (width: number, height: number) => {
20
+ return Math.max(width, height) * MAX_HEIGHT_PERCENTAGE;
21
+ };
22
+
23
+ export function useCustomDimensions(): CustomDimensionsType {
24
+ const { width, height } = useWindowDimensions();
25
+ const [maxWidth, setMaxWidth] = useState<number>(Math.min(width, height));
26
+ const [maxHeight, setMaxHeight] = useState<number>(getMaxHeight(width, height));
27
+ const [isPortrait, setIsPortrait] = useState<boolean>(height > width);
28
+ const [padding, setPadding] = useState<number>(0);
29
+
30
+ useEffect(() => {
31
+ setMaxWidth(Math.min(width, height));
32
+ setMaxHeight(getMaxHeight(width, height));
33
+ setIsPortrait(height > width);
34
+ setPadding(width < height ? 0 : (width - height) / 2);
35
+ }, [width, height]);
36
+
37
+ return { maxWidth, maxHeight, isPortrait, isLandscape: !isPortrait, padding };
38
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /********** Components **********/
1
2
  export { Card, type CardProps } from './components/wui-card';
2
3
  export { Icon, type IconProps } from './components/wui-icon';
3
4
  export { Image, type ImageProps } from './components/wui-image';
@@ -8,6 +9,7 @@ export { Text, type TextProps } from './components/wui-text';
8
9
  export { Visual, type VisualProps } from './components/wui-visual';
9
10
  export { Shimmer, type ShimmerProps } from './components/wui-shimmer';
10
11
 
12
+ /********** Composites **********/
11
13
  export { AccountButton, type AccountButtonProps } from './composites/wui-account-button';
12
14
  export { AccountPill, type AccountPillProps } from './composites/wui-account-pill';
13
15
  export { ActionEntry, type ActionEntryProps } from './composites/wui-action-entry';
@@ -48,6 +50,7 @@ export { ListTransaction, type ListTransactionProps } from './composites/wui-lis
48
50
  export { ListWallet, type ListWalletProps } from './composites/wui-list-wallet';
49
51
  export { Logo, type LogoProps } from './composites/wui-logo';
50
52
  export { LogoSelect, type LogoSelectProps } from './composites/wui-logo-select';
53
+ export { Modal, type ModalProps } from './components/wui-modal';
51
54
  export { NetworkButton, type NetworkButtonProps } from './composites/wui-network-button';
52
55
  export { NetworkImage, type NetworkImageProps } from './composites/wui-network-image';
53
56
  export { NumericKeyboard, type NumericKeyboardProps } from './composites/wui-numeric-keyboard';
@@ -67,6 +70,7 @@ export { Overlay, type OverlayProps } from './layout/wui-overlay';
67
70
  export { FlexView, type FlexViewProps } from './layout/wui-flex';
68
71
  export { Separator } from './layout/wui-separator';
69
72
 
73
+ /********** Types **********/
70
74
  export type {
71
75
  ButtonType,
72
76
  CardSelectType,
@@ -82,10 +86,14 @@ export type {
82
86
  VisualType,
83
87
  TransactionType
84
88
  } from './utils/TypesUtil';
89
+
90
+ /********** Utils **********/
85
91
  export { UiUtil } from './utils/UiUtil';
86
92
  export { TransactionUtil } from './utils/TransactionUtil';
87
93
  export { Spacing, BorderRadius } from './utils/ThemeUtil';
88
94
 
95
+ /********** Hooks **********/
89
96
  export { useTheme } from './hooks/useTheme';
90
97
  export { ThemeProvider } from './context/ThemeContext';
91
98
  export { useAnimatedValue } from './hooks/useAnimatedValue';
99
+ export { useCustomDimensions } from './hooks/useCustomDimensions';