-
Notifications
You must be signed in to change notification settings - Fork 1
/
Palette.js
89 lines (83 loc) · 2.56 KB
/
Palette.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
80
81
82
83
84
85
86
87
88
89
/**
* @flow
*/
import React from 'react';
import {
DrawerLayoutAndroid,
ScrollView,
Text,
View,
} from 'react-native';
import {Expression} from './Expression';
import SimpleComponent from './SimpleComponent';
import * as t from './types';
import {PaletteDisplayState} from './types';
import {TOOLBAR_HEIGHT} from './toolbar';
type PalettePropTypes = {
displayState: PaletteDisplayState,
};
export default class Palette extends SimpleComponent<PalettePropTypes, {}> {
shouldComponentUpdate(nextProps: PalettePropTypes) {
return !this.props.displayState.equals(nextProps.displayState);
}
render() {
const {activePalette, lambdas, definitions} = this.props.displayState;
if (activePalette === 'none') {
return null;
}
let viewContents;
if (activePalette === 'lambda') {
viewContents = lambdas.map(varName =>
<View key={`lambda-${varName}`} style={{margin: 10}}>
<Expression expr={t.DisplayLambda.make(
t.PaletteLambdaKey.make(varName),
false,
null,
null,
false,
varName,
null,
)} />
</View>
);
} else {
viewContents = [<Text key='definitionText' style={{
fontSize: 24,
margin: 16,
color: 'black',
fontWeight: 'bold',
textDecorationLine: 'underline',
}}>
Definitions
</Text>];
viewContents.push(definitions.map(defName =>
<View key={`def-${defName}`} style={{margin: 10}}>
<Expression expr={t.DisplayReference.make(
t.PaletteReferenceKey.make(defName),
false,
false,
defName,
)} />
</View>
));
}
return <ScrollView
onStartShouldSetResponder={() => {
console.log('got here');
return true;
}}
style={{
backgroundColor: '#E6CEA3',
position: 'absolute',
right: 0,
top: TOOLBAR_HEIGHT,
bottom: 0,
}}
contentContainerStyle={{
alignItems: 'center',
}}
>
{viewContents}
</ScrollView>;
}
}