-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAvailableStock.mixed.tsx
75 lines (61 loc) · 2.35 KB
/
AvailableStock.mixed.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
import React from 'react';
import { LayoutAnimation, Text } from 'react-native';
import { runConfig, store } from '../../../../inject';
import { observer } from 'mobx-react-lite';
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';
export const AvailableStock_Mixed: React.FC<{
availableStock: AvailableStock;
}>
= observer(({ availableStock }) => {
const animateAddition = () => {
// 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={runConfig.abTesting.choose($priceA, $priceB)}>
{availableStock.currentPriceStr}
</Text>
<Space.px8 />
<Row>
<MaterialButton label="BUY"
backgroundColor={Color.up}
disabled={!store.portfolio.hasMoneyToBuyStock(availableStock)}
onPress={() => {
animateAddition();
store.portfolio.buy(availableStock, 1);
}} />
<Space.px8 />
<MaterialButton label="SELL"
backgroundColor={Color.down}
disabled={!store.portfolio.hasStock(availableStock)}
onPress={() => {
animateAddition();
store.portfolio.sell(availableStock, 1);
}} />
</Row>
</Column>
</Row>
<Space.px12 />
<Divider />
</Column>
);
});