-
Notifications
You must be signed in to change notification settings - Fork 1
/
DeleteBar.js
57 lines (53 loc) · 1.66 KB
/
DeleteBar.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
/**
* The "Delete bar" is the area at the top of the screen where you can drag
* expressions to remove them.
*
* @flow
*/
import React from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import {
Text,
} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';
import StatelessComponent from './StatelessComponent';
import {TOOLBAR_HEIGHT} from './toolbar';
import {TrackedView} from './TrackedViews';
import * as t from './types';
type DeleteBarProps = {
isDeleteBarHighlighted: boolean,
isDraggingExpression: boolean,
}
export default class DeleteBar extends StatelessComponent<DeleteBarProps> {
shouldComponentUpdate(nextProps: DeleteBarProps, nextState: {}) {
return shallowCompare(this, nextProps, nextState);
}
render() {
const {isDeleteBarHighlighted, isDraggingExpression} = this.props;
const text = isDraggingExpression ? 'Remove' : 'Hide';
return <TrackedView
viewKey={t.DeleteBarKey.make()}
style={{
backgroundColor: isDeleteBarHighlighted ? '#AA0000' : '#888888',
position: 'absolute',
left: 0,
right: 0,
top: 0,
height: TOOLBAR_HEIGHT,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Icon name='clear' size={24} color='white' />
<Text
style={{
color: 'white',
fontSize: 18,
}}
>
{text}
</Text>
</TrackedView>;
}
}