-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rn-bridge/remove_bob_builder
refactor code and added keywords
- Loading branch information
Showing
14 changed files
with
524 additions
and
5,152 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
preset: 'react-native', | ||
preset: 'react-native' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
}); |
Oops, something went wrong.