-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVariables.jsx
49 lines (46 loc) · 1.3 KB
/
Variables.jsx
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
import React, { useState } from "react";
import { FlatList, StyleSheet, TextInput } from "react-native";
import Text from "./Text";
import Highlight from "./Highlight";
export default ({ variables }) => {
const [filter, setFilter] = useState("");
return (
<>
<TextInput
value={filter}
placeholder="Filter..."
placeholderTextColor="grey"
style={styles.textInput}
onChangeText={(t) => setFilter(t.toLowerCase())}
clearButtonMode="always"
/>
<FlatList
contentContainerStyle={{ padding: 5, paddingBottom: 20 }}
data={Object.keys(variables).filter(
(k) =>
!filter ||
variables[k].toLowerCase().includes(filter) ||
k.toLowerCase().includes(filter)
)}
showsVerticalScrollIndicator
keyExtractor={(i) => i}
renderItem={({ item }) => (
<Text selectable style={{ color: "white", marginVertical: 10 }}>
<Highlight text={item} filter={filter} />
{" : "}
<Highlight text={variables[item]} filter={filter} />
</Text>
)}
/>
</>
);
};
const styles = StyleSheet.create({
textInput: {
marginHorizontal: 5,
padding: 5,
color: "white",
backgroundColor: "#333",
borderRadius: 8,
},
});