123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import React, {Component} from 'react';
- import {
- StyleSheet,
- Text,
- View,
- Platform,
- ScrollView,
- DeviceEventEmitter
-
- } from 'react-native';
- import ContactPickerBridge from 'react-native-contacts-picker';
- import ContactsWrapper from 'react-native-contacts-wrapper';
- import checkContactsPermission from '../../tool/requestPermission';
- import { connect } from 'react-redux';
- import ContactList from './components/ContactList'
- import searchBar from './components/searchBar'
- import Search from './Search'
- import NewFriend from './NewFriend'
- import FriendsValidation from './FriendsValidation'
- import DetailedInfo from './DetailedInfo'
- import AddFriend from './AddFriend'
- import BottomTabNavigator from '../../navigators/BottomTabNavigator'
- if(Platform.OS==='android'){
- checkContactsPermission()
- }
- class ContactPicker extends Component {
- constructor(props){
- super(props)
- }
- componentDidMount(){
- const {navigation } =this.props
- this.subscription = DeviceEventEmitter.addListener('OPENMENUCONTACT', ()=>{
- navigation.navigate({ routeName:"AddFriend" })
- });
-
- }
-
-
-
- componentWillUnmount(){
-
- this.subscription.remove();
-
- }
- render() {
- return (
- // <View style={styles.container}>
- // <Text style={styles.welcome} onPress={this.openContactPicker}>打开通讯录选择器</Text>
- // <Text style={styles.welcome} onPress={this.getAllContact}>获取全部通讯录</Text>
- // <Text style={styles.welcome} onPress={this.checkContactPermissions}>是否有通讯录权限</Text>
- // <Text style={styles.welcome} onPress={()=>{this.onButtonPressed()}}>另外一个</Text>
- // </View>
- <ContactList props={this.props}/>
- );
- }
- onButtonPressed() {
- ContactsWrapper.getContact()
- .then((contact) => {
- // Replace this code
- console.log(contact);
- })
- .catch((error) => {
- console.log("ERROR CODE: ", error.code);
- console.log("ERROR MESSAGE: ", error.message);
- });
- }
- openContactPicker = () => {
- ContactPickerBridge.openContactPicker((result) => {
- console.log('openContactPicker ---->', JSON.stringify(result));
- });
- };
- getAllContact = () => {
- ContactPickerBridge
- .getAllContact((result) => {
- console.log('getAllContact ---->', JSON.stringify(result));
- });
- };
- checkContactPermissions = () => {
- ContactPickerBridge
- .checkContactPermissions((result) => {
- console.log('getAllContact ---->', JSON.stringify(result));
- });
- };
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#F5FCFF',
- },
- welcome: {
- fontSize: 20,
- textAlign: 'center',
- margin: 10,
- },
- instructions: {
- textAlign: 'center',
- color: '#333333',
- marginBottom: 5,
- },
- });
- ContactPicker.navigationOptions ={
- header: null
- }
- const getHeaderButtonClick =(state)=>{
- return {...state.menu}
- }
- export default connect(getHeaderButtonClick)(ContactPicker);
|