-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountryPage.js
55 lines (48 loc) · 2.21 KB
/
CountryPage.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
import React, { Component } from 'react';
import { FlatList, View, Text, Switch, InteractionManager } from 'react-native';
import { ListItem } from 'react-native-elements';
import CheckListItem from './CheckListItem';
import CheckList from './CheckList';
// import { connect } from 'react-redux';
import { inject, observer, Observer } from 'mobx-react';
import { toJS, decorate } from 'mobx';
import CountryPageModel from './ViewModels/CountryPageModel';
import { fromPromise } from 'mobx-utils';
import { SearchBar } from 'react-native-elements';
class CountryPage extends Component {
static navigationOptions = {
title: 'Country'
}
componentDidMount() {
// console.log(SearchParameters.geo.getCountries());
// SearchParameters.geo.getCountries().then(countries => { console.log(countries); this.setState({ data: countries }); });
// Promise.all(SearchParameters.geo.getCountries()).then(countries => this.setState({ data: countries }));
// SearchParameters.geo.getCountries().then(countries => this.setState({ data: countries }));
// this.setState({ data: SearchParameters.geo.getCountries() });
// this.props.geo.getCountries().then(countries => this.setState({ data: countries }));
this.loadAllCountries();
}
loadAllCountries() {
// replace only works for strings which observable seem to be https://stackoverflow.com/questions/39543194/mobx-replacing-item-in-observable-array
CountryPageModel.getInstance().getCountries().then(countries => { CountryPageModel.getInstance().countries = countries; }).then(() => { CountryPageModel.getInstance().query = ''; });
}
render() {
return (
<View style={{ flex: 1 }}>
<CheckList
searchEnable={true}
query={this.props.countryPageModel.query}
data={this.props.countryPageModel.getFilteredCountries()}
bindingContext={CountryPageModel.getInstance()}
/>
</View>
);
}
}
/*
function mapStateToProps(state) {
return { store: state.geo };
}
*/
// connect(mapStateToProps)(CountryPage);
export default inject('countryPageModel')(observer(CountryPage));