MainTab.js 2.07 KB
import { Component } from 'react';
import { StyleSheet, Text, View, Image, TouchableOpacity, Alert } from 'react-native';
import { Icon } from 'native-base'; // 추가된 코드
import React from 'react'
import {Marker} from 'react-native-maps'
import Constants from 'expo-constants';
import * as Location from 'expo-location';
import MapView from "../ClusteredMapView";


export default class MainScreen extends Component {
 
  // navigationOptions 코드 추가
  static navigationOptions = {
    headerLeft: <Icon name='ios-camera' style={{ paddingLeft:10 }}/>,
    title: 'PME Service',
    headerRight: <Icon name='ios-send' style={{ paddingRight:10 }}/>,
  }
  constructor(props) {
      super(props)
      this.state= {
          location:null,
          errorMsg:null
      }
  }
  componentDidMount() {
    (async () => {
        let { status } = await Location.requestPermissionsAsync();
        if (status !== 'granted') {
            this.setState({
                errorMsg:'Permission to access location was denied'
            })
        }
  
        let location = await Location.getCurrentPositionAsync({});
        console.log(location)
        this.setState({
            location
        },() => {
            console.log(this.state.location.coords.latitude)
        })
      })();
  }
  render() {
    return (
        //this.state.location?
        <View style={{width:"100%",height:"100%"}}>
          
          <TouchableOpacity onPress={() => Alert.alert('OK',"주변에 의심자가 있습니까?",[{text:"OK",onPress:() =>alert("확인")},{text:'cancel'}])} style={{position:"absolute",bottom:10,right:10, width:50,height:50,backgroundColor:"red",borderRadius:100}}>
              <View style={{flex:1,justifyContent: 'center',alignItems: 'center'}}>
              <Image style={{width:22,height:22}} source={require('../assets/security.png')}/>
              </View>
          </TouchableOpacity>
          </View>
          //:<Text>Loading..</Text>

    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});