Skip to content
This repository was archived by the owner on Mar 31, 2021. It is now read-only.

Commit 18045dc

Browse files
authored
Merge pull request #16 from kpolnitz/add-boolean-button
Add boolean button
2 parents 755611f + 91e8288 commit 18045dc

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

code-editor.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import React, { useState, useEffect } from 'react';
3+
import {Button} from 'react-native-elements';
34
import {ActivityIndicator, FlatList, Platform, TextInput, KeyboardAvoidingView, Text, View, StyleSheet} from 'react-native';
45
import {AnalyzerService} from './pyright/server/src/analyzer/service';
56
import {ArgumentCategory, ParseNodeType} from './pyright/server/src/parser/parseNodes';
@@ -46,19 +47,40 @@ function CodeInput(props) {
4647
clearTimeout(changeTimeout);
4748
setChangeTimeout(0);
4849
}
50+
4951
if (oldValue != newValue) {
5052
console.log("done");
53+
5154
if (newValue.length > 0) {
5255
patch(props.offset, oldValue, newValue);
5356
}
5457
}
5558
}
59+
function changeValue() {
60+
newValue = newValue == "True" ? onChange("False") : onChange("True");
61+
}
62+
63+
if ( props.keyword == "yes" ) {
64+
65+
return (
66+
67+
<Button onPress={changeValue}
68+
title={newValue}
69+
type="clear"
70+
titleStyle={[props.style, {fontFamily: font}, debugStyle]}
71+
buttonStyle={{padding: 0}}
72+
/>
73+
74+
)
75+
}
76+
5677
return (<TextInput {...props} style={[props.style, {fontFamily: font, paddingVertical: 0, textAlignVertical: 'top'}, debugStyle]} onChangeText={onChange} onEndEditing={onDone}>{newValue}</TextInput>);
5778
}
5879

5980
const styles = StyleSheet.create({
6081
keyword: {
61-
color: 'blue',
82+
color: '#145C9E',
83+
fontSize: 15,
6284
},
6385
});
6486

@@ -76,7 +98,8 @@ function Indent(props) {
7698
function renderKeyword(token, changeCode, offset) {
7799
if (token.keywordType == KeywordType.True || token.keywordType == KeywordType.False) {
78100
let value = token.keywordType == KeywordType.True ? "True" : "False";
79-
return (<CodeInput placeholder="bool"
101+
return (<CodeInput placeholder="bool"
102+
keyword="yes"
80103
style={styles.keyword}
81104
editable={true}
82105
multiline={false}
@@ -155,7 +178,7 @@ function renderParseNode(node, changeCode) {
155178
if (node.items.length == 1) {
156179
return renderParseNode(node.items[0], changeCode);
157180
}
158-
sbreak;
181+
break;
159182
case ParseNodeType.MemberAccess:
160183
return (<View style={{flexDirection: 'row', alignItems: 'flex-end'}}>{renderParseNode(node.leftExpression, changeCode)}<Code>.</Code>{renderParseNode(node.memberName, changeCode)}</View>);
161184

0 commit comments

Comments
 (0)