-
Notifications
You must be signed in to change notification settings - Fork 1
/
AvailableStock.view.tsx
86 lines (72 loc) · 2.33 KB
/
AvailableStock.view.tsx
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
80
81
82
83
84
85
86
import React from 'react';
import { LayoutAnimation, Text } from 'react-native';
import { AvailableStock } from '../../business/state/AvailableStock';
import { Space } from '../theme/Space';
import MaterialButton from '../utils/MaterialButton';
import Divider from '../utils/Divider';
import Color from '../theme/Color';
import { Column, Row } from '../utils/Layout';
import { Font } from '../theme/Font';
import { AbTesting } from '../../business/RunConfig/ABTesting';
export const AvailableStockView: React.FC<{
availableStock: AvailableStock;
ifBuyDisabled: boolean;
ifSellDisabled: boolean;
abTesting: AbTesting,
onBuy: () => void;
onSell: () => void;
}>
= ({
availableStock,
ifBuyDisabled,
ifSellDisabled,
abTesting,
onBuy,
onSell
}) => {
const animate = () => {
// Call this before updating the state that causes a re-render.
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
};
const $ticker = Font.large();
const $name = Font.small(Color.textDimmed);
const $priceA = Font.big(Color.blueText);
const $priceB = Font.small();
return (
<Column style={{ paddingTop: 12, paddingHorizontal: 12 }}>
<Row>
<Column style={{ flex: 1 }}>
<Text style={$ticker}>{availableStock.ticker}</Text>
<Space.px4 />
<Text style={$name}>{availableStock.name}</Text>
</Column>
<Space.px8 />
<Column>
<Text style={abTesting.choose($priceA, $priceB)}>
{availableStock.currentPriceStr}
</Text>
<Space.px8 />
<Row>
<MaterialButton label="BUY"
backgroundColor={Color.up}
disabled={ifBuyDisabled}
onPress={() => {
animate();
onBuy();
}} />
<Space.px8 />
<MaterialButton label="SELL"
backgroundColor={Color.down}
disabled={ifSellDisabled}
onPress={() => {
animate();
onSell();
}} />
</Row>
</Column>
</Row>
<Space.px12 />
<Divider />
</Column>
);
};