-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.js
79 lines (69 loc) · 1.73 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React, { useEffect } from "react";
import { UIManager, Platform } from "react-native";
import { requireNativeComponent, findNodeHandle } from "react-native";
let byronController = undefined;
const ByronKline = requireNativeComponent("ByronKline");
export const dispatchByronKline = (event = "init", list = []) => {
if (!byronController) {
return;
}
UIManager.dispatchViewManagerCommand(
findNodeHandle(byronController),
Platform.OS === "android"
? "ByronKline"
: UIManager.getViewManagerConfig("ByronKline").Commands.byronController,
[{ event, list }]
);
};
export const CandleHollow = {
NONE_HOLLOW: 0,
ALL_HOLLOW: 1,
DECREASE_HOLLOW: 2,
INCREASE_HOLLOW: 3,
};
export const KLineIndicator = {
MainMA: 0,
MainBOLL: 1,
MainNONE: 2,
ChildMACD: 3,
ChildKDJ: 4,
ChildRSI: 5,
ChildWR: 6,
ChildNONE: 7,
TimeLineShow: 8,
TimeLineHide: 9,
VolumeShow: 10,
VolumeHide: 11,
};
const KlineComponent = (props, forwardedRef) => {
const { onMoreKLineData, ...localProps } = props;
const onMoreKLineDataEvent = onMoreKLineData
? (event) => onMoreKLineData(event.nativeEvent)
: null;
const _forwardedRef = (ref) => {
byronController = ref;
forwardedRef && forwardedRef(ref);
};
useEffect(() => {
dispatchByronKline();
}, []);
return (
<ByronKline
{...localProps}
ref={_forwardedRef}
onRNMoreKLineData={onMoreKLineDataEvent}
/>
);
};
const ByronKlineChart = React.forwardRef(KlineComponent);
ByronKlineChart.defaultProps = {
datas: [],
locales: [],
indicators: [],
pricePrecision: 2,
volumePrecision: 2,
mainBackgroundColor: '#18181A',
increaseColor: "#00BD9A",
decreaseColor: "#FF6960",
};
export default ByronKlineChart;