Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { pink } from "./colors.js";
import { Feather } from '@expo/vector-icons';
import MapView from 'react-native-maps';
import { isIOS } from "./utilities";
const INITIAL_LAT = 42.518217;
const INITIAL_LONG = -70.891919;
const INITIAL_DELTA = 0.005;
const ZOOM_IN_DELTA = .001;
const ANIMATION_DELAY = 500;
const ANIMATION_DURATION = 1000;
// This triggers asking the user for location permissions.
// This won't do anything if the permission is already granted.
Permissions.askAsync(Permissions.LOCATION);
let exploreStyles = {};
// Note: For all intents and purposes, "mural key" is the same as "mural id".
// But "mural index" does not refer to either of those things, it only refers
// to a mural's order in the tour.
export default class ExplorePage extends React.Component {
constructor(props) {
super(props);
self = this;
// Where we will store the refs to all the markers
// This is necessary because showing and hiding a callout must be done imperatively.
this.markers = {};
relationships: 'relationships',
users: 'users',
complaints: 'complaints',
},
isDetached: false,
googleLoginProps,
facebookFields: fields,
facebookLoginProps: {
permissions: [
'public_profile',
'email',
// 'user_friends'
],
},
permissions: [
Permissions.LOCATION,
Permissions.NOTIFICATIONS,
Permissions.CONTACTS,
],
hideBooty: true,
noName: 'Sasuke Uchiha',
isIos: Platform.OS === 'ios',
osVersion: sizeInfo.osVersion,
loginBehavior: sizeInfo.loginBehavior,
isRunningInExpo: sizeInfo.isRunningInExpo,
isIPhone: sizeInfo.isIPhone,
isIPad: sizeInfo.isIPad,
isIPhoneX: sizeInfo.isIPhoneX,
bottomInset: sizeInfo.bottomInset,
topInset: sizeInfo.topInset,
isSimulator: !Constants.isDevice,
debug,
_getLocationAsync = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
this.setState({
errorMessage: 'Permission to access location was denied',
});
return null;
}
let location = await Location.getCurrentPositionAsync({});
this.setState({ location });
return location;
};
{
text: "Open Settings",
onPress: () => {
Linking.openURL("app-settings:");
}
}
]
);
throw new Error("Permission Denied");
} else if (askStatus === "granted") {
store.dispatch(Location.actions.set({ authorized: true }));
return;
}
const { status: locationStatus } = await Permissions.askAsync(
Permissions.LOCATION
);
if (locationStatus !== "granted") {
throw new Error("Permission Denied");
}
store.dispatch(Location.actions.set({ authorized: true }));
}
_getLocationAsync = async () => {
const { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
this.setState({
errorMessage: 'Permission to access location was denied',
});
return null;
}
const location = await Location.getCurrentPositionAsync({});
return location;
};
const getLocationSaga = function* () {
yield put({ type: GET_LOCATION_REQUEST });
try {
const { status } = yield call(Permissions.askAsync, Permissions.LOCATION);
if (status === 'granted') {
const location = yield call(Location.getCurrentPositionAsync, {});
yield put({ type: GET_LOCATION_SUCCESS, payload: location });
yield put({ type: GET_WEATHER_FORECAST_TRIGGER });
} else {
yield put({ type: GET_LOCATION_FAILURE, payload: 'Permission to access location was denied' });
}
} catch (error) {
yield put({ type: GET_LOCATION_FAILURE, payload: { isClientError: true, errorMessage: error.message } });
}
};
async function checkLocationPermission() {
const { status: locationStatus } = await Permissions.getAsync(
Permissions.LOCATION
);
if (locationStatus === "granted") {
store.dispatch(Location.actions.set({ authorized: true }));
}
}
async getPremissions() {
let { status } = await Permissions.askAsync(Permissions.LOCATION)
if (status === 'granted') {
const location = await Location.getCurrentPositionAsync({})
this.props.changeLocation(location)
}
}
Observable.defer(async () => {
const time = moment();
const body = {
now: time.valueOf(),
utc: time.utcOffset()
};
let coordinates;
const { status: locationStatus } = await Permissions.getAsync(
Permissions.LOCATION
);
if (locationStatus === "granted") {
const {
coords: { latitude, longitude }
} = await locate();
body.lat = latitude;
body.lng = longitude;
coordinates = {
latitude,
longitude
};
}