Commit 4fa9ef38 authored by Trisno's avatar Trisno

tambah function untuk open settings

parent 550c8306
...@@ -3095,6 +3095,11 @@ ...@@ -3095,6 +3095,11 @@
"expo-permissions": "*" "expo-permissions": "*"
} }
}, },
"expo-intent-launcher": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-intent-launcher/-/expo-intent-launcher-8.0.0.tgz",
"integrity": "sha512-Rf+AprbFKJx4YH1+DooCGg92Y4jjlP3iMpW3rpinTD4N1TJzqkpsflMphARGsF/GKxcrhzvqX52D/JrmXrcjhA=="
},
"expo-keep-awake": { "expo-keep-awake": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-8.0.0.tgz", "resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-8.0.0.tgz",
......
...@@ -83,7 +83,8 @@ ...@@ -83,7 +83,8 @@
"redux": "^4.0.5", "redux": "^4.0.5",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"sentry-expo": "^2.0.4" "sentry-expo": "^2.0.4",
"expo-intent-launcher": "~8.0.0"
}, },
"devDependencies": { "devDependencies": {
"babel-preset-expo": "~8.0.0", "babel-preset-expo": "~8.0.0",
......
This diff is collapsed.
...@@ -5,12 +5,13 @@ import * as Location from 'expo-location'; ...@@ -5,12 +5,13 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions'; import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import React from 'react'; import React from 'react';
import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView } from 'react-native'; import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView, Linking } from 'react-native';
import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'; import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps'; import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete'; import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import session from '../function/session'; import session from '../function/session';
import * as IntentLauncher from 'expo-intent-launcher';
class AddreesDetail extends React.Component { class AddreesDetail extends React.Component {
...@@ -44,11 +45,31 @@ class AddreesDetail extends React.Component { ...@@ -44,11 +45,31 @@ class AddreesDetail extends React.Component {
this._getPermissions(); this._getPermissions();
} }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
//Permission (melakukan izin) //Permission (melakukan izin)
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted')) Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice')) Alert.alert(i18n.t('tryItRealDevice'))
...@@ -311,7 +332,7 @@ class AddreesDetail extends React.Component { ...@@ -311,7 +332,7 @@ class AddreesDetail extends React.Component {
}} }}
/> />
</View> </View>
<View style={{ flex: 1, margin: 5 , display:'none'}} > <View style={{ flex: 1, margin: 5, display: 'none' }} >
<TouchableOpacity onPress={() => this._searchLocation()}> <TouchableOpacity onPress={() => this._searchLocation()}>
<Ionicons name="ios-search" size={32} color="#ccb46c" /> <Ionicons name="ios-search" size={32} color="#ccb46c" />
</TouchableOpacity> </TouchableOpacity>
......
...@@ -5,12 +5,13 @@ import * as Location from 'expo-location'; ...@@ -5,12 +5,13 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions'; import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import React from 'react'; import React from 'react';
import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView } from 'react-native'; import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView, Linking } from 'react-native';
import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'; import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps'; import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete'; import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import session from '../function/session'; import session from '../function/session';
import * as IntentLauncher from 'expo-intent-launcher';
class EditAddressDetail extends React.Component { class EditAddressDetail extends React.Component {
...@@ -44,11 +45,31 @@ class EditAddressDetail extends React.Component { ...@@ -44,11 +45,31 @@ class EditAddressDetail extends React.Component {
this._getPermissions(); this._getPermissions();
} }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
//Permission (melakukan izin) //Permission (melakukan izin)
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted')) Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice')) Alert.alert(i18n.t('tryItRealDevice'))
...@@ -79,7 +100,7 @@ class EditAddressDetail extends React.Component { ...@@ -79,7 +100,7 @@ class EditAddressDetail extends React.Component {
let postalCode = detail[0].postalCode let postalCode = detail[0].postalCode
let latitude = parseFloat(this.props.route.params.lat); let latitude = parseFloat(this.props.route.params.lat);
let longitude = parseFloat(this.props.route.params.long); let longitude = parseFloat(this.props.route.params.long);
this.setState({ latitude: latitude, longitude: longitude}) this.setState({ latitude: latitude, longitude: longitude })
if (street == null) { if (street == null) {
let str_city = city.replace('null', '') let str_city = city.replace('null', '')
...@@ -151,8 +172,8 @@ class EditAddressDetail extends React.Component { ...@@ -151,8 +172,8 @@ class EditAddressDetail extends React.Component {
} }
this.setState({ this.setState({
name:this.props.route.params.name, name: this.props.route.params.name,
description:this.props.route.params.address description: this.props.route.params.address
}) })
...@@ -322,7 +343,7 @@ class EditAddressDetail extends React.Component { ...@@ -322,7 +343,7 @@ class EditAddressDetail extends React.Component {
}} }}
/> />
</View> </View>
<View style={{ flex: 1, margin: 5 , display:'none'}} > <View style={{ flex: 1, margin: 5, display: 'none' }} >
<TouchableOpacity onPress={() => this._searchLocation()}> <TouchableOpacity onPress={() => this._searchLocation()}>
<Ionicons name="ios-search" size={32} color="#ccb46c" /> <Ionicons name="ios-search" size={32} color="#ccb46c" />
</TouchableOpacity> </TouchableOpacity>
......
...@@ -5,7 +5,7 @@ import * as Location from 'expo-location'; ...@@ -5,7 +5,7 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions'; import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import * as React from 'react'; import * as React from 'react';
import { ActivityIndicator, Alert, Dimensions, Platform, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, PermissionStatus } from 'react-native'; import { ActivityIndicator, Alert, Dimensions, Platform, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, PermissionStatus, Linking } from 'react-native';
import { Badge } from 'react-native-elements'; import { Badge } from 'react-native-elements';
import { SliderBox } from "react-native-image-slider-box"; import { SliderBox } from "react-native-image-slider-box";
import { Card } from 'react-native-shadow-cards'; import { Card } from 'react-native-shadow-cards';
...@@ -17,6 +17,7 @@ import requestParams from '../helper/requestParams'; ...@@ -17,6 +17,7 @@ import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import CustomIosStatusBar from './CustomIosStatusBar'; import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
...@@ -127,6 +128,16 @@ class Home extends React.Component { ...@@ -127,6 +128,16 @@ class Home extends React.Component {
this._unsubscribe(); this._unsubscribe();
} }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
settings() { settings() {
//disini masukin open settings //disini masukin open settings
this._getPermissions() this._getPermissions()
...@@ -134,7 +145,7 @@ class Home extends React.Component { ...@@ -134,7 +145,7 @@ class Home extends React.Component {
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert( Alert.alert(
i18n.t('titleAlertLocationNotPermitted'), i18n.t('titleAlertLocationNotPermitted'),
...@@ -142,7 +153,7 @@ class Home extends React.Component { ...@@ -142,7 +153,7 @@ class Home extends React.Component {
[ [
{ {
text: i18n.t('selectOpenSetting'), text: i18n.t('selectOpenSetting'),
onPress: () => this.settings() onPress: () => this.openSetting()
} }
], ],
{ cancelable: false } { cancelable: false }
...@@ -154,7 +165,7 @@ class Home extends React.Component { ...@@ -154,7 +165,7 @@ class Home extends React.Component {
this._getCurrentPosisition() this._getCurrentPosisition()
} }
} }
_getCurrentPosisition = async () => { _getCurrentPosisition = async () => {
let location = await Location.getCurrentPositionAsync({ let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest accuracy: Location.Accuracy.Highest
......
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, ScrollView, Platform, TouchableOpacity, Image, FlatList, Button, StatusBar, ActivityIndicator, Alert, Modal } from 'react-native'; import { View, Text, StyleSheet, ScrollView, Platform, TouchableOpacity, Image, FlatList, Button, StatusBar, ActivityIndicator, Alert, Modal, Linking } from 'react-native';
import Axios from 'axios'; import Axios from 'axios';
import Item from './Item'; import Item from './Item';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
...@@ -16,6 +16,7 @@ import Constants from 'expo-constants'; ...@@ -16,6 +16,7 @@ import Constants from 'expo-constants';
import requestParams from '../helper/requestParams'; import requestParams from '../helper/requestParams';
import CustomIosStatusBar from './CustomIosStatusBar'; import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
class MenuSelection extends React.Component { class MenuSelection extends React.Component {
constructor(props) { constructor(props) {
...@@ -71,11 +72,31 @@ class MenuSelection extends React.Component { ...@@ -71,11 +72,31 @@ class MenuSelection extends React.Component {
this._unsubscribe(); this._unsubscribe();
} }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted')) Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice')) Alert.alert(i18n.t('tryItRealDevice'))
......
...@@ -13,6 +13,7 @@ import RNPickerSelect from 'react-native-picker-select'; ...@@ -13,6 +13,7 @@ import RNPickerSelect from 'react-native-picker-select';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import requestParams from '../helper/requestParams'; import requestParams from '../helper/requestParams';
import CustomIosStatusBar from './CustomIosStatusBar'; import CustomIosStatusBar from './CustomIosStatusBar';
import * as IntentLauncher from 'expo-intent-launcher';
class Outlets extends React.Component { class Outlets extends React.Component {
...@@ -37,11 +38,11 @@ class Outlets extends React.Component { ...@@ -37,11 +38,11 @@ class Outlets extends React.Component {
} }
componentDidMount() { componentDidMount() {
// this._getOutletClosest() // this._getOutletClosest()
this.OrderedList() this.OrderedList()
this._getPermissions() this._getPermissions()
// this._unsubscribe = this.props.navigation.addListener('focus', () => { // this._unsubscribe = this.props.navigation.addListener('focus', () => {
// this.setState({ // this.setState({
// indicator: true, // indicator: true,
...@@ -57,10 +58,30 @@ class Outlets extends React.Component { ...@@ -57,10 +58,30 @@ class Outlets extends React.Component {
// this._unsubscribe() // this._unsubscribe()
// } // }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted')) Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice')) Alert.alert(i18n.t('tryItRealDevice'))
...@@ -90,11 +111,11 @@ class Outlets extends React.Component { ...@@ -90,11 +111,11 @@ class Outlets extends React.Component {
this.setState({ this.setState({
spinner: true, spinner: true,
}) })
let params = Object.assign(requestParams,{ let params = Object.assign(requestParams, {
session_id: this.props.session_id, session_id: this.props.session_id,
}) })
Axios.post(this.props.BASE_URL+"crm/v2/outlet/get_list", params).then(res => { Axios.post(this.props.BASE_URL + "crm/v2/outlet/get_list", params).then(res => {
let dataOutlets = res.data.outlets; let dataOutlets = res.data.outlets;
for (let i = 0; i < dataOutlets.length; i++) { for (let i = 0; i < dataOutlets.length; i++) {
dataOutlets[i]['distance'] = this.distance(dataOutlets[i]['lat'], dataOutlets[i]['long']); dataOutlets[i]['distance'] = this.distance(dataOutlets[i]['lat'], dataOutlets[i]['long']);
...@@ -145,7 +166,7 @@ class Outlets extends React.Component { ...@@ -145,7 +166,7 @@ class Outlets extends React.Component {
} }
OrderedList() { OrderedList() {
Axios.get(this.props.BASE_URL+'crm/v2/outlet/get_city_list').then(res => { Axios.get(this.props.BASE_URL + 'crm/v2/outlet/get_city_list').then(res => {
let cities = res.data.city let cities = res.data.city
let data_city = [] let data_city = []
...@@ -267,7 +288,7 @@ class Outlets extends React.Component { ...@@ -267,7 +288,7 @@ class Outlets extends React.Component {
textContent={'Loading...'} textContent={'Loading...'}
textStyle={styles.spinnerTextStyle} textStyle={styles.spinnerTextStyle}
/> */} /> */}
{Platform.OS === 'ios' && <CustomIosStatusBar color='#CFB368'/>} {Platform.OS === 'ios' && <CustomIosStatusBar color='#CFB368' />}
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<MapView style={{ flex: 1, marginRight: 10, marginLeft: 10 }} <MapView style={{ flex: 1, marginRight: 10, marginLeft: 10 }}
region={{ region={{
...@@ -296,7 +317,7 @@ class Outlets extends React.Component { ...@@ -296,7 +317,7 @@ class Outlets extends React.Component {
<View style={{ flex: 1 }}></View> <View style={{ flex: 1 }}></View>
<View style={{ flex: 1, justifyContent: 'center' }}> <View style={{ flex: 1, justifyContent: 'center' }}>
<RNPickerSelect <RNPickerSelect
placeholder={{ label: i18n.t('allcity')}} placeholder={{ label: i18n.t('allcity') }}
onValueChange={(label) => this.filterData(label)} onValueChange={(label) => this.filterData(label)}
items={this.state.data_outlet} items={this.state.data_outlet}
style={{ inputIOSContainer: { paddingVertical: 10, alignItems: 'center' } }} style={{ inputIOSContainer: { paddingVertical: 10, alignItems: 'center' } }}
......
...@@ -6,12 +6,13 @@ import * as Permissions from 'expo-permissions'; ...@@ -6,12 +6,13 @@ import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import _ from 'lodash'; import _ from 'lodash';
import React from 'react'; import React from 'react';
import { ActivityIndicator, Alert, FlatList, StyleSheet, Text, TextInput, View } from 'react-native'; import { ActivityIndicator, Alert, FlatList, StyleSheet, Text, TextInput, View, Platform, Linking } from 'react-native';
import { CheckBox } from 'react-native-elements'; import { CheckBox } from 'react-native-elements';
import { TouchableOpacity } from 'react-native-gesture-handler'; import { TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import MyStatusBar from './MyStatusBar'; import MyStatusBar from './MyStatusBar';
import * as IntentLauncher from 'expo-intent-launcher';
class PickupName extends React.Component { class PickupName extends React.Component {
constructor(props) { constructor(props) {
...@@ -91,10 +92,30 @@ class PickupName extends React.Component { ...@@ -91,10 +92,30 @@ class PickupName extends React.Component {
}) })
} }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted')) Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice')) Alert.alert(i18n.t('tryItRealDevice'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment