@ledgerhq/native-ui 0.23.3-nightly.2 → 0.23.4-nightly.0
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.
|
@@ -5,32 +5,38 @@ import styled, { useTheme } from "styled-components/native";
|
|
|
5
5
|
import { TouchableOpacity } from "react-native";
|
|
6
6
|
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from "react-native-reanimated";
|
|
7
7
|
const StyledTouchableOpacity = styled(TouchableOpacity) `
|
|
8
|
+
width: ${(p) => p.width}px;
|
|
8
9
|
flex: 1;
|
|
9
|
-
|
|
10
|
+
height: 100%;
|
|
10
11
|
`;
|
|
11
12
|
const StyledFlex = styled(Flex) `
|
|
12
|
-
width: 100%;
|
|
13
13
|
height: 100%;
|
|
14
14
|
justify-content: center;
|
|
15
15
|
align-items: center;
|
|
16
16
|
`;
|
|
17
17
|
const StyledText = styled(Text) `
|
|
18
18
|
line-height: 14.52px;
|
|
19
|
+
overflow: visible;
|
|
19
20
|
text-align: center;
|
|
20
21
|
font-size: 12px;
|
|
21
22
|
color: ${(p) => p.isSelected ? p.theme.colors.constant.black : p.theme.colors.opacityDefault.c50};
|
|
22
23
|
`;
|
|
23
|
-
const OptionButton = ({ option, selectedOption, handleSelectOption, label, }) => {
|
|
24
|
+
const OptionButton = ({ option, selectedOption, handleSelectOption, label, width, }) => {
|
|
24
25
|
const isSelected = selectedOption === option;
|
|
25
|
-
return (React.createElement(StyledTouchableOpacity, { onPress: () => handleSelectOption(option) },
|
|
26
|
+
return (React.createElement(StyledTouchableOpacity, { width: width, onPress: () => handleSelectOption(option) },
|
|
26
27
|
React.createElement(StyledFlex, { isSelected: isSelected },
|
|
27
|
-
React.createElement(StyledText, { fontWeight: "semiBold", isSelected: isSelected,
|
|
28
|
+
React.createElement(StyledText, { fontWeight: "semiBold", isSelected: isSelected, numberOfLines: 1 }, label))));
|
|
28
29
|
};
|
|
29
30
|
export default function TabSelector({ options, selectedOption, handleSelectOption, labels, }) {
|
|
30
31
|
const { colors } = useTheme();
|
|
31
|
-
const
|
|
32
|
+
const longuestLabel = labels[options[0]].length > labels[options[1]].length ? options[0] : options[1];
|
|
33
|
+
const widthFactor = 8;
|
|
34
|
+
const margin = 20;
|
|
35
|
+
const width = labels[longuestLabel].length * widthFactor + margin;
|
|
36
|
+
const semiWidth = width / 2;
|
|
37
|
+
const translateX = useSharedValue(-semiWidth);
|
|
32
38
|
useEffect(() => {
|
|
33
|
-
translateX.value = withSpring(selectedOption === options[0] ? -
|
|
39
|
+
translateX.value = withSpring(selectedOption === options[0] ? -semiWidth : semiWidth, {
|
|
34
40
|
damping: 30,
|
|
35
41
|
stiffness: 80,
|
|
36
42
|
});
|
|
@@ -40,16 +46,16 @@ export default function TabSelector({ options, selectedOption, handleSelectOptio
|
|
|
40
46
|
transform: [{ translateX: translateX.value }],
|
|
41
47
|
};
|
|
42
48
|
});
|
|
43
|
-
return (React.createElement(Flex, { flexDirection: "row", justifyContent: "center", alignItems: "center", width:
|
|
49
|
+
return (React.createElement(Flex, { flexDirection: "row", justifyContent: "center", alignItems: "center", width: width * 2 + 4, height: "35px", borderRadius: "40px", bg: colors.opacityDefault.c05, position: "relative" },
|
|
44
50
|
React.createElement(Animated.View, { style: [
|
|
45
51
|
{
|
|
46
52
|
position: "absolute",
|
|
47
|
-
width:
|
|
48
|
-
height: "
|
|
53
|
+
width: width - 2,
|
|
54
|
+
height: "90%",
|
|
49
55
|
backgroundColor: colors.primary.c80,
|
|
50
56
|
borderRadius: 40,
|
|
51
57
|
},
|
|
52
58
|
animatedStyle,
|
|
53
59
|
] }),
|
|
54
|
-
options.map((option) => (React.createElement(OptionButton, { key: option, option: option, selectedOption: selectedOption, handleSelectOption: handleSelectOption, label: labels[option] })))));
|
|
60
|
+
options.map((option) => (React.createElement(OptionButton, { width: width, key: option, option: option, selectedOption: selectedOption, handleSelectOption: handleSelectOption, label: labels[option] })))));
|
|
55
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.4-nightly.0",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"react-native-modal": "^13.0.0",
|
|
41
41
|
"rn-range-slider": "2.1.1",
|
|
42
42
|
"styled-system": "^5.1.5",
|
|
43
|
-
"@ledgerhq/crypto-icons-ui": "^1.4.0
|
|
44
|
-
"@ledgerhq/icons-ui": "^0.7.
|
|
43
|
+
"@ledgerhq/crypto-icons-ui": "^1.4.0",
|
|
44
|
+
"@ledgerhq/icons-ui": "^0.7.2",
|
|
45
45
|
"@ledgerhq/ui-shared": "^0.2.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|