@ledgerhq/native-ui 0.11.0 → 0.12.0-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.
- package/lib/components/Carousel/index.js +14 -7
- package/lib/components/Layout/Modals/BottomDrawer/index.js +1 -0
- package/lib/components/Navigation/StoriesIndicator/index.js +6 -1
- package/lib/components/Text/index.d.ts +1 -1
- package/lib/components/Text/index.js +2 -2
- package/lib/components/cta/Button/getButtonStyle.js +2 -0
- package/lib/components/message/Log/Brackets.js +12 -4
- package/package.json +5 -5
|
@@ -2,9 +2,15 @@ import React, { useEffect, useState, useRef, useCallback } from "react";
|
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
3
|
import styled from "styled-components/native";
|
|
4
4
|
import { Flex, SlideIndicator } from "../index";
|
|
5
|
+
import { I18nManager } from "react-native";
|
|
5
6
|
const HorizontalScrollView = styled.ScrollView.attrs({ horizontal: true }) `
|
|
6
7
|
flex: 1;
|
|
7
8
|
`;
|
|
9
|
+
/*
|
|
10
|
+
In RTL activated, this carousel is making a jump to the last item at start. It's patched by scrolling back to the activeIndex item, but i don't know how to patch this definitely.
|
|
11
|
+
It's seems like a behavior that react-native is doing to start from the end of list, except we don't want this kind of RTL behavior as this list is "time based" and need to always stay LTR.
|
|
12
|
+
Except a visual jump on RTL layout.
|
|
13
|
+
*/
|
|
8
14
|
function Carousel({ activeIndex = 0, autoDelay, restartAfterEnd = true, scrollOnSidePress = false, containerProps, slideIndicatorContainerProps, scrollViewProps, onChange, onOverflow, IndicatorComponent = SlideIndicator, maxDurationOfTap, children, onAutoChange, onManualChange, }) {
|
|
9
15
|
const [init, setInit] = useState(false);
|
|
10
16
|
const [activeIndexState, setActiveIndexState] = useState(activeIndex);
|
|
@@ -25,17 +31,15 @@ function Carousel({ activeIndex = 0, autoDelay, restartAfterEnd = true, scrollOn
|
|
|
25
31
|
}, [itemWidth]);
|
|
26
32
|
useEffect(() => {
|
|
27
33
|
// On init scroll to the active index prop location - if specified.
|
|
28
|
-
if (init && activeIndex) {
|
|
34
|
+
if (init && typeof activeIndex === "number") {
|
|
29
35
|
scrollToIndex(activeIndex, false);
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
}, [init]);
|
|
37
|
+
}, [activeIndex, init, scrollToIndex]);
|
|
33
38
|
useEffect(() => {
|
|
34
39
|
if (scrollToIndex && typeof activeIndex === "number") {
|
|
35
|
-
scrollToIndex(activeIndex);
|
|
40
|
+
scrollToIndex(activeIndex, false);
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
}, [activeIndex]);
|
|
42
|
+
}, [activeIndex, scrollToIndex]);
|
|
39
43
|
const onContentSizeChange = (contentWidth, contentHeight) => {
|
|
40
44
|
dimensions.current = { contentWidth, contentHeight };
|
|
41
45
|
setInit(true);
|
|
@@ -109,7 +113,10 @@ function Carousel({ activeIndex = 0, autoDelay, restartAfterEnd = true, scrollOn
|
|
|
109
113
|
disableTimer.current = true;
|
|
110
114
|
}, onScrollEndDrag: () => {
|
|
111
115
|
disableTimer.current = false;
|
|
112
|
-
}, pagingEnabled: Platform.OS !== "web", showsHorizontalScrollIndicator: false, scrollEventThrottle: 200, contentContainerStyle: {
|
|
116
|
+
}, pagingEnabled: Platform.OS !== "web", showsHorizontalScrollIndicator: false, scrollEventThrottle: 200, contentContainerStyle: {
|
|
117
|
+
width: `${fullWidth}%`,
|
|
118
|
+
flexDirection: I18nManager.isRTL && Platform.OS !== "ios" ? "row-reverse" : "row",
|
|
119
|
+
}, decelerationRate: "fast", onTouchStart: scrollOnSidePress ? onStartTap : undefined, onTouchEnd: scrollOnSidePress ? onEndTap : undefined }, scrollViewProps), React.Children.map(children, (child, index) => (React.createElement(Flex, { key: index, flex: 1 }, child)))),
|
|
113
120
|
React.createElement(Flex, Object.assign({ my: 8 }, slideIndicatorContainerProps), React.isValidElement(IndicatorComponent) ? (IndicatorComponent) : (React.createElement(IndicatorComponent, { activeIndex: activeIndexState || 0, onChange: (index) => {
|
|
114
121
|
scrollToIndex(index);
|
|
115
122
|
setResetTimer({});
|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useMemo } from "react";
|
|
|
2
2
|
import styled from "styled-components/native";
|
|
3
3
|
import Animated, { useAnimatedStyle, withTiming, useSharedValue, Easing, } from "react-native-reanimated";
|
|
4
4
|
import { Flex } from "../../Layout";
|
|
5
|
+
import { I18nManager } from "react-native";
|
|
5
6
|
const ProgressBar = styled.View `
|
|
6
7
|
background-color: ${(p) => p.theme.colors.primary.c100};
|
|
7
8
|
border-radius: ${(p) => p.theme.radii[2]}px;
|
|
@@ -27,6 +28,10 @@ function StoryBar({ full = false, isActive, duration }) {
|
|
|
27
28
|
}
|
|
28
29
|
function StoriesIndicator({ activeIndex, slidesLength, duration }) {
|
|
29
30
|
const storiesArray = useMemo(() => new Array(slidesLength).fill(0), [slidesLength]);
|
|
30
|
-
return (React.createElement(Flex, { flexDirection: "row", alignItems: "stretch", width: "100%"
|
|
31
|
+
return (React.createElement(Flex, { flexDirection: "row", alignItems: "stretch", width: "100%", style: I18nManager.isRTL
|
|
32
|
+
? {
|
|
33
|
+
transform: [{ scaleX: -1 }],
|
|
34
|
+
}
|
|
35
|
+
: undefined }, storiesArray.map((_, storyIndex) => (React.createElement(StoryBar, { key: storyIndex, full: activeIndex > storyIndex, isActive: activeIndex === storyIndex, duration: duration })))));
|
|
31
36
|
}
|
|
32
37
|
export default React.memo(StoriesIndicator);
|
|
@@ -16,5 +16,5 @@ export interface BaseTextProps extends TextProps, BaseStyledProps, FontSizeProps
|
|
|
16
16
|
uppercase?: boolean;
|
|
17
17
|
children: React.ReactNode;
|
|
18
18
|
}
|
|
19
|
-
declare const Text: ({ children, bracket, ...props }: BaseTextProps) => JSX.Element;
|
|
19
|
+
declare const Text: ({ children, bracket, textAlign, ...props }: BaseTextProps) => JSX.Element;
|
|
20
20
|
export default Text;
|
|
@@ -56,9 +56,9 @@ const BracketText = (_a) => {
|
|
|
56
56
|
React.createElement(BracketRight, { fill: c, width: size, height: size })));
|
|
57
57
|
};
|
|
58
58
|
const Text = (_a) => {
|
|
59
|
-
var { children, bracket } = _a, props = __rest(_a, ["children", "bracket"]);
|
|
59
|
+
var { children, bracket, textAlign = "left" } = _a, props = __rest(_a, ["children", "bracket", "textAlign"]);
|
|
60
60
|
if (bracket)
|
|
61
61
|
return React.createElement(BracketText, Object.assign({}, props), children);
|
|
62
|
-
return React.createElement(Base, Object.assign({}, props), children);
|
|
62
|
+
return (React.createElement(Base, Object.assign({ textAlign: textAlign }, props), children));
|
|
63
63
|
};
|
|
64
64
|
export default Text;
|
|
@@ -3,6 +3,7 @@ import styled, { useTheme } from "styled-components/native";
|
|
|
3
3
|
import { Svg, Path } from "react-native-svg";
|
|
4
4
|
import FlexBox from "../../Layout/Flex";
|
|
5
5
|
import { getColor } from "../../../styles";
|
|
6
|
+
import { I18nManager } from "react-native";
|
|
6
7
|
const BracketContainer = styled(FlexBox).attrs({
|
|
7
8
|
flexDirection: "column",
|
|
8
9
|
position: "relative",
|
|
@@ -15,15 +16,22 @@ export const Bracket = ({ color, style, mb, mt }) => {
|
|
|
15
16
|
React.createElement(Svg, { width: "17", height: "10", viewBox: "0 0 17 10" },
|
|
16
17
|
React.createElement(Path, { d: "M16.8125 0H2.8125H0.8125V2V10H2.8125V2H16.8125V0Z", fill: fill }))));
|
|
17
18
|
};
|
|
19
|
+
const RTLBracketManager = ({ children }) => {
|
|
20
|
+
return (React.createElement(FlexBox, { style: { transform: I18nManager.isRTL ? [{ scaleX: -1 }] : undefined } }, children));
|
|
21
|
+
};
|
|
18
22
|
export const BracketTopLeft = ({ color }) => {
|
|
19
|
-
return React.createElement(
|
|
23
|
+
return (React.createElement(RTLBracketManager, null,
|
|
24
|
+
React.createElement(Bracket, { color: color })));
|
|
20
25
|
};
|
|
21
26
|
export const BracketTopRight = ({ color }) => {
|
|
22
|
-
return React.createElement(
|
|
27
|
+
return (React.createElement(RTLBracketManager, null,
|
|
28
|
+
React.createElement(Bracket, { color: color, style: { transform: [{ scaleX: -1 }] } })));
|
|
23
29
|
};
|
|
24
30
|
export const BracketBottomLeft = ({ color }) => {
|
|
25
|
-
return React.createElement(
|
|
31
|
+
return (React.createElement(RTLBracketManager, null,
|
|
32
|
+
React.createElement(Bracket, { color: color, style: { transform: [{ scaleY: -1 }] } })));
|
|
26
33
|
};
|
|
27
34
|
export const BracketBottomRight = ({ color }) => {
|
|
28
|
-
return React.createElement(
|
|
35
|
+
return (React.createElement(RTLBracketManager, null,
|
|
36
|
+
React.createElement(Bracket, { color: color, style: { transform: [{ scale: -1 }] } })));
|
|
29
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-nightly.0",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -134,13 +134,13 @@
|
|
|
134
134
|
"regenerator-runtime": "^0.13.9",
|
|
135
135
|
"rimraf": "^3.0.2",
|
|
136
136
|
"styled-components": "^5.3.3",
|
|
137
|
-
"typescript": "^4.4.4",
|
|
138
|
-
"victory": "^35.5.5",
|
|
139
|
-
"webpack": "^4.46.0",
|
|
140
137
|
"stylelint": "^14.9.1",
|
|
141
138
|
"stylelint-config-recommended": "^8.0.0",
|
|
142
139
|
"stylelint-config-styled-components": "^0.1.1",
|
|
143
|
-
"stylelint-processor-styled-components": "^1.10.0"
|
|
140
|
+
"stylelint-processor-styled-components": "^1.10.0",
|
|
141
|
+
"typescript": "^4.4.4",
|
|
142
|
+
"victory": "^35.5.5",
|
|
143
|
+
"webpack": "^4.46.0"
|
|
144
144
|
},
|
|
145
145
|
"scripts": {
|
|
146
146
|
"android": "expo start --android",
|