-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
121 lines (110 loc) · 6.2 KB
/
Copy pathindex.android.js
File metadata and controls
121 lines (110 loc) · 6.2 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TextInput,
View
} from 'react-native';
import Realm from 'realm';
import { ListView } from 'realm/react-native';
const realm = new Realm({ schema: [{name: 'Translation', properties: {tibetan: 'string', english: 'string'}}] });
class TibetanDictionary extends Component {
constructor (props) {
super(props);
/*let allTranslations = realm.objects('Translation')
realm.write(() => {
realm.delete(allTranslations);
});*/
let dictionary = realm.objects('Translation').sorted('tibetan');
if (dictionary.length < 1) {
realm.write(() => {
realm.create('Translation', {tibetan: "ཀ་", english: " I. <consonant letter> The first of the གསལ་བྱེད་སུམ་ཅུ thirty consonants of the Tibetan language."});
realm.create('Translation', {tibetan: "ཀ་ཀ་", english: "<noun> 1) Corrupted form of ཀའ་ཀ q.v. 2) The ཨ་ཅུག of a sheep q.v. 3) [Dialect] The clothing of a young child. 4) Slang term for སྐྱག་པ faeces."});
realm.create('Translation', {tibetan: "ཀ་ཀ་ཎི་ལ་", english: "Mis-spelling of ཀ་ཀ་ནའི་ལ q.v."});
realm.create('Translation', {tibetan: "བསྐུལ་", english: "<verb> See བསྐུལ་བ q.v."});
realm.create('Translation', {tibetan: "བསྐུལ་བ་ཕྲིན་ལས་ཀྱི་སྔགས་", english: "english: <noun>phrase> \"The evocation action mantra\" of a deity. See སྔགས་བཞི \"the four mantras\"."});
realm.create('Translation', {tibetan: "བསྐུས་", english: "<verb> See བསྐུས་པ q.v."});
realm.create('Translation', {tibetan: "བསྐོ་བ་", english: "<verb> Fut. of སྐོ་བ [TC]."});
realm.create('Translation', {tibetan: "བསྐོང་བ་", english: "<verb> Fut. of v.t. སྐོང་བ q.v."});
realm.create('Translation', {tibetan: "བསྐོངས་པ་", english: "<verb> Past of v.t. form II སྐོང་བ q.v."});
realm.create('Translation', {tibetan: "བསྐོན་པ་", english: "<verb> Past and fut. of སྐོན་པ q.v."});
realm.create('Translation', {tibetan: "བསྐོར་", english: "<verb> See བསྐོར་བ q.v."});
realm.create('Translation', {tibetan: "བསྐོར་བ་", english: "<verb> Past and fut. of སྐོར་བ q.v."});
realm.create('Translation', {tibetan: "བསྐོལ་", english: "<verb> See བསྐོལ་བ q.v."});
realm.create('Translation', {tibetan: "བསྐོས་", english: "<verb> See བསྐོས་པ q.v."});
realm.create('Translation', {tibetan: "བསྐོས་པ་", english: "<verb> Past of སྐོ་བ q.v."});
realm.create('Translation', {tibetan: "བསྐྱ་བ་", english: "<verb> Fut. of སྐྱ་བ q.v."});
realm.create('Translation', {tibetan: "ཁ་སྦྱོར་ཡན་ལག་བདུན་དང་ལདན་པ་", english: "See the usual abbrev. ཁ་སྦྱོར་ཡན་ལག་བདུན་ལདན q.v."});
realm.create('Translation', {tibetan: "དགུ་བརྒྱ་", english: "<noun> The number \"nine hundred\"."});
realm.create('Translation', {tibetan: "དགུ་བརྒྱ་ཐམ་པ་", english: "<noun> The number \"nine hundred (exactly)\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་", english: "<noun> The number \"ninety\". To indicate ninety exactly, དགུ་བཅུ་ཐམ་པ is used."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་དགུ་", english: "<noun> The number \"ninety-nine\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་བརྒྱད་", english: "<noun> The number \"ninety-eight\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་ལྔ་", english: "<noun> The number \"ninety-five\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་གཅིག་", english: "<noun> The number \"ninety-one\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་གཉིས་", english: "<noun> The number \"ninety-two\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་དྲུག་", english: "<noun> The number \"ninety-six\"."});
realm.create('Translation', {tibetan: "དགུ་བཅུ་གོ་བདུན་", english: "<noun> The number \"ninety-seven\"."});
});
}
// This is a Results object, which will live-update.
this.dictionary = dictionary;
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}).cloneWithRows(dictionary)
};
}
onSearchChange(event: Object) {
var query = event.nativeEvent.text.toLowerCase();
var filtered = this.dictionary.filtered('tibetan BEGINSWITH "' + query + '"');
this.setState({
dataSource: this.state.dataSource.cloneWithRows(filtered)
});
}
render = () => {
return (
<View style = { styles.parent }>
<TextInput
placeholder="Type something in English"
onChange={this.onSearchChange.bind(this)}
/>
<ListView
dataSource={this.state.dataSource}
style={styles.list}
renderRow={(translation) => <View style={styles.list_line}>
<Text style={styles.list_word}>{translation.tibetan}</Text>
<Text style={styles.list_definition}>{translation.english}</Text>
</View>}
/>
</View>
);
}
};
var styles = StyleSheet.create({
parent: {
flex: 1,
padding: 10
},
list: {
flex: 1
},
list_line: {
padding: 10,
borderBottomColor: '#eee',
borderBottomWidth: 1
},
list_word: {
fontSize: 20,
fontWeight: 'bold'
},
list_definition: {
fontSize: 18
}
});
AppRegistry.registerComponent('TibetanDictionary', () => TibetanDictionary);