Commit 4fa9ef38 authored by Trisno's avatar Trisno

tambah function untuk open settings

parent 550c8306
......@@ -3095,6 +3095,11 @@
"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": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-8.0.0.tgz",
......
......@@ -83,7 +83,8 @@
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"sentry-expo": "^2.0.4"
"sentry-expo": "^2.0.4",
"expo-intent-launcher": "~8.0.0"
},
"devDependencies": {
"babel-preset-expo": "~8.0.0",
......
This diff is collapsed.
......@@ -5,12 +5,13 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
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 MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { connect } from 'react-redux';
import session from '../function/session';
import * as IntentLauncher from 'expo-intent-launcher';
class AddreesDetail extends React.Component {
......@@ -44,11 +45,31 @@ class AddreesDetail extends React.Component {
this._getPermissions();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
//Permission (melakukan izin)
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
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) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -311,7 +332,7 @@ class AddreesDetail extends React.Component {
}}
/>
</View>
<View style={{ flex: 1, margin: 5 , display:'none'}} >
<View style={{ flex: 1, margin: 5, display: 'none' }} >
<TouchableOpacity onPress={() => this._searchLocation()}>
<Ionicons name="ios-search" size={32} color="#ccb46c" />
</TouchableOpacity>
......
......@@ -5,12 +5,13 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
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 MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { connect } from 'react-redux';
import session from '../function/session';
import * as IntentLauncher from 'expo-intent-launcher';
class EditAddressDetail extends React.Component {
......@@ -44,11 +45,31 @@ class EditAddressDetail extends React.Component {
this._getPermissions();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
//Permission (melakukan izin)
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
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) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -79,7 +100,7 @@ class EditAddressDetail extends React.Component {
let postalCode = detail[0].postalCode
let latitude = parseFloat(this.props.route.params.lat);
let longitude = parseFloat(this.props.route.params.long);
this.setState({ latitude: latitude, longitude: longitude})
this.setState({ latitude: latitude, longitude: longitude })
if (street == null) {
let str_city = city.replace('null', '')
......@@ -151,8 +172,8 @@ class EditAddressDetail extends React.Component {
}
this.setState({
name:this.props.route.params.name,
description:this.props.route.params.address
name: this.props.route.params.name,
description: this.props.route.params.address
})
......@@ -322,7 +343,7 @@ class EditAddressDetail extends React.Component {
}}
/>
</View>
<View style={{ flex: 1, margin: 5 , display:'none'}} >
<View style={{ flex: 1, margin: 5, display: 'none' }} >
<TouchableOpacity onPress={() => this._searchLocation()}>
<Ionicons name="ios-search" size={32} color="#ccb46c" />
</TouchableOpacity>
......
......@@ -5,7 +5,7 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
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 { SliderBox } from "react-native-image-slider-box";
import { Card } from 'react-native-shadow-cards';
......@@ -17,6 +17,7 @@ import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType';
import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
......@@ -127,6 +128,16 @@ class Home extends React.Component {
this._unsubscribe();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
settings() {
//disini masukin open settings
this._getPermissions()
......@@ -134,7 +145,7 @@ class Home extends React.Component {
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
......@@ -142,7 +153,7 @@ class Home extends React.Component {
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.settings()
onPress: () => this.openSetting()
}
],
{ cancelable: false }
......@@ -154,7 +165,7 @@ class Home extends React.Component {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
......
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 Item from './Item';
import { connect } from 'react-redux';
......@@ -16,6 +16,7 @@ import Constants from 'expo-constants';
import requestParams from '../helper/requestParams';
import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
class MenuSelection extends React.Component {
constructor(props) {
......@@ -71,11 +72,31 @@ class MenuSelection extends React.Component {
this._unsubscribe();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
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) {
Alert.alert(i18n.t('tryItRealDevice'))
......
......@@ -13,6 +13,7 @@ import RNPickerSelect from 'react-native-picker-select';
import { connect } from 'react-redux';
import requestParams from '../helper/requestParams';
import CustomIosStatusBar from './CustomIosStatusBar';
import * as IntentLauncher from 'expo-intent-launcher';
class Outlets extends React.Component {
......@@ -37,11 +38,11 @@ class Outlets extends React.Component {
}
componentDidMount() {
// this._getOutletClosest()
this.OrderedList()
this._getPermissions()
// this._unsubscribe = this.props.navigation.addListener('focus', () => {
// this.setState({
// indicator: true,
......@@ -57,10 +58,30 @@ class Outlets extends React.Component {
// this._unsubscribe()
// }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
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) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -90,11 +111,11 @@ class Outlets extends React.Component {
this.setState({
spinner: true,
})
let params = Object.assign(requestParams,{
let params = Object.assign(requestParams, {
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;
for (let i = 0; i < dataOutlets.length; i++) {
dataOutlets[i]['distance'] = this.distance(dataOutlets[i]['lat'], dataOutlets[i]['long']);
......@@ -145,7 +166,7 @@ class Outlets extends React.Component {
}
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 data_city = []
......@@ -267,7 +288,7 @@ class Outlets extends React.Component {
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/> */}
{Platform.OS === 'ios' && <CustomIosStatusBar color='#CFB368'/>}
{Platform.OS === 'ios' && <CustomIosStatusBar color='#CFB368' />}
<View style={{ flex: 1 }}>
<MapView style={{ flex: 1, marginRight: 10, marginLeft: 10 }}
region={{
......@@ -296,7 +317,7 @@ class Outlets extends React.Component {
<View style={{ flex: 1 }}></View>
<View style={{ flex: 1, justifyContent: 'center' }}>
<RNPickerSelect
placeholder={{ label: i18n.t('allcity')}}
placeholder={{ label: i18n.t('allcity') }}
onValueChange={(label) => this.filterData(label)}
items={this.state.data_outlet}
style={{ inputIOSContainer: { paddingVertical: 10, alignItems: 'center' } }}
......
......@@ -6,12 +6,13 @@ import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import _ from 'lodash';
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 { TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType';
import MyStatusBar from './MyStatusBar';
import * as IntentLauncher from 'expo-intent-launcher';
class PickupName extends React.Component {
constructor(props) {
......@@ -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 () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
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) {
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