Skip to content

Commit

Permalink
Merge pull request #2 from rn-bridge/remove_bob_builder
Browse files Browse the repository at this point in the history
refactor code and added keywords
  • Loading branch information
sriharshamadamanchi authored Aug 17, 2024
2 parents 9dc99e2 + d1ed3ad commit 075649f
Show file tree
Hide file tree
Showing 14 changed files with 524 additions and 5,152 deletions.
15 changes: 0 additions & 15 deletions .editorconfig

This file was deleted.

3 changes: 0 additions & 3 deletions .gitattributes

This file was deleted.

4 changes: 1 addition & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module.exports = {
presets: [
['module:react-native-builder-bob/babel-preset', { modules: 'commonjs' }],
],
presets: ['module:metro-react-native-babel-preset']
};
15 changes: 3 additions & 12 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
const path = require('path');
const { getConfig } = require('react-native-builder-bob/babel-config');
const pkg = require('../package.json');

const root = path.resolve(__dirname, '..');

module.exports = getConfig(
{
presets: ['module:@react-native/babel-preset'],
},
{ root, pkg }
);
module.exports = {
presets: ['module:metro-react-native-babel-preset']
};
4 changes: 2 additions & 2 deletions example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { name as appName } from './app.json';
import { Geofence, Events } from '@rn-bridge/react-native-geofencing';

Geofence.onEnter((ids: string[]) => {
console.log(Events.Enter, ids);
console.log(Events.Enter, ids);
});

Geofence.onExit((ids: string[]) => {
console.log(Events.Exit, ids);
console.log(Events.Exit, ids);
});

AppRegistry.registerComponent(appName, () => App);
2 changes: 1 addition & 1 deletion example/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
preset: 'react-native',
preset: 'react-native'
};
6 changes: 3 additions & 3 deletions example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const root = path.resolve(__dirname, '..');
* @type {import('metro-config').MetroConfig}
*/
module.exports = getConfig(getDefaultConfig(__dirname), {
root,
pkg,
project: __dirname,
root,
pkg,
project: __dirname
});
20 changes: 10 additions & 10 deletions example/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const path = require('path');
const pkg = require('../package.json');

module.exports = {
project: {
ios: {
automaticPodsInstallation: true,
},
},
dependencies: {
[pkg.name]: {
root: path.join(__dirname, '..'),
},
},
project: {
ios: {
automaticPodsInstallation: true
}
},
dependencies: {
[pkg.name]: {
root: path.join(__dirname, '..')
}
}
};
256 changes: 128 additions & 128 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,154 +1,154 @@
import { StyleSheet, View, TouchableOpacity, Text, Alert } from 'react-native';
import {
addGeofence,
removeGeofence,
getRegisteredGeofences,
requestLocation,
getLocationAuthorizationStatus,
getCurrentLocation,
addGeofence,
removeGeofence,
getRegisteredGeofences,
requestLocation,
getLocationAuthorizationStatus,
getCurrentLocation
} from '@rn-bridge/react-native-geofencing';

const Button = ({
title,
style = {},
textStyle = {},
onPress,
title,
style = {},
textStyle = {},
onPress
}: {
title: string;
style: any;
textStyle: any;
onPress: () => void;
title: string;
style: any;
textStyle: any;
onPress: () => void;
}) => {
return (
<TouchableOpacity style={style} onPress={onPress}>
<Text style={textStyle}>{title}</Text>
</TouchableOpacity>
);
return (
<TouchableOpacity style={style} onPress={onPress}>
<Text style={textStyle}>{title}</Text>
</TouchableOpacity>
);
};

export const App = () => {
return (
<View style={styles.container}>
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Request Location While Using"
onPress={async () => {
const response = await requestLocation({ allowWhileUsing: true });
console.log('requestLocation:', response);
Alert.alert('Status', `Location: ${response.location}`);
}}
/>
return (
<View style={styles.container}>
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Request Location While Using"
onPress={async () => {
const response = await requestLocation({ allowWhileUsing: true });
console.log('requestLocation:', response);
Alert.alert('Status', `Location: ${response.location}`);
}}
/>

<Button
textStyle={styles.textStyle}
style={styles.button}
title="Request Location Always"
onPress={async () => {
const response = await requestLocation({ allowAlways: true });
console.log('requestLocation:', response);
Alert.alert('Status', `Location: ${response.location}`);
}}
/>
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Request Location Always"
onPress={async () => {
const response = await requestLocation({ allowAlways: true });
console.log('requestLocation:', response);
Alert.alert('Status', `Location: ${response.location}`);
}}
/>

<Button
textStyle={styles.textStyle}
style={styles.button}
title="Get Current Location"
onPress={async () => {
const response = await getCurrentLocation();
console.log('getCurrentLocation:', response);
Alert.alert(
'Status',
`Latitude: ${response.latitude}\nLongitude: ${response.longitude}`
);
}}
/>
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Get Current Location"
onPress={async () => {
const response = await getCurrentLocation();
console.log('getCurrentLocation:', response);
Alert.alert(
'Status',
`Latitude: ${response.latitude}\nLongitude: ${response.longitude}`
);
}}
/>

<Button
textStyle={styles.textStyle}
style={styles.button}
title="Add Geo Fence"
onPress={async () => {
const response = await addGeofence({
id: 'a9957259-8036-4dcb-974c-34eae9b44bdb',
latitude: 10.9314,
longitude: 76.9781,
radius: 500,
});
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Add Geo Fence"
onPress={async () => {
const response = await addGeofence({
id: 'a9957259-8036-4dcb-974c-34eae9b44bdb',
latitude: 10.9314,
longitude: 76.9781,
radius: 500
});

console.log('addGeofence:', response);
console.log('addGeofence:', response);

const message = response.success
? 'Successfully added geofence!!'
: 'Failed to add geofence!!';
const message = response.success
? 'Successfully added geofence!!'
: 'Failed to add geofence!!';

Alert.alert('Status', message);
}}
/>
Alert.alert('Status', message);
}}
/>

<Button
textStyle={styles.textStyle}
style={styles.button}
title="Remove Geo Fence"
onPress={async () => {
const response = await removeGeofence(
'a9957259-8036-4dcb-974c-34eae9b44bdb'
);
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Remove Geo Fence"
onPress={async () => {
const response = await removeGeofence(
'a9957259-8036-4dcb-974c-34eae9b44bdb'
);

console.log('removeGeofence:', response);
console.log('removeGeofence:', response);

const message = response.success
? 'Successfully removed geofence!!'
: response.error;
const message = response.success
? 'Successfully removed geofence!!'
: response.error;

Alert.alert('Status', message);
}}
/>
Alert.alert('Status', message);
}}
/>

<Button
textStyle={styles.textStyle}
style={styles.button}
title="Get Registered Geo Fences"
onPress={async () => {
const response = await getRegisteredGeofences();
console.log('getRegisteredGeofences:', response);
Alert.alert('Status', JSON.stringify(response));
}}
/>
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Get Registered Geo Fences"
onPress={async () => {
const response = await getRegisteredGeofences();
console.log('getRegisteredGeofences:', response);
Alert.alert('Status', JSON.stringify(response));
}}
/>

<Button
textStyle={styles.textStyle}
style={styles.button}
title="Get Authorization Status"
onPress={async () => {
const response = await getLocationAuthorizationStatus();
console.log('getLocationAuthorizationStatus:', response);
Alert.alert('Status', `Location: ${response}`);
}}
/>
</View>
);
<Button
textStyle={styles.textStyle}
style={styles.button}
title="Get Authorization Status"
onPress={async () => {
const response = await getLocationAuthorizationStatus();
console.log('getLocationAuthorizationStatus:', response);
Alert.alert('Status', `Location: ${response}`);
}}
/>
</View>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
button: {
backgroundColor: 'black',
width: 300,
height: 50,
borderRadius: 20,
justifyContent: 'center',
alignItems: 'center',
marginVertical: 10,
},
textStyle: {
color: 'white',
fontSize: 18,
fontWeight: '500',
},
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
button: {
backgroundColor: 'black',
width: 300,
height: 50,
borderRadius: 20,
justifyContent: 'center',
alignItems: 'center',
marginVertical: 10
},
textStyle: {
color: 'white',
fontSize: 18,
fontWeight: '500'
}
});
Loading

0 comments on commit 075649f

Please sign in to comment.