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",
......
......@@ -6,7 +6,7 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import React from 'react';
import { ActivityIndicator, Alert, Image, ImageBackground, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { ActivityIndicator, Alert, Image, ImageBackground, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, Platform, Linking } from 'react-native';
import { Card } from 'react-native-shadow-cards';
import Toast from 'react-native-tiny-toast';
import NumberFormat from 'react-number-format';
......@@ -15,6 +15,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';
class Account extends React.Component {
......@@ -65,14 +66,34 @@ class Account extends React.Component {
} catch (error) {
Alert.alert('Error : ' + error)
}
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
try {
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'))
......@@ -85,7 +106,7 @@ class Account extends React.Component {
}
_getCurrentPosisition = async () => {
try {
try {
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
})
......@@ -119,55 +140,55 @@ class Account extends React.Component {
}
handleClaimCredit() {
this.setState({spinner: true})
this.setState({old_balance_claimed: true}) /** set jadi true dulu buat hilangkan bagian claim credit */
this.setState({indicator: true}) /** atau sekalian dibuat loading aja bagian profilecardnya */
this.setState({ spinner: true })
this.setState({ old_balance_claimed: true }) /** set jadi true dulu buat hilangkan bagian claim credit */
this.setState({ indicator: true }) /** atau sekalian dibuat loading aja bagian profilecardnya */
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
session_id: this.props.session_id,
})
// console.log("start processing claim_old_balance")
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
// console.log("success processing claim_old_balance")
this.setState({spinner: false})
this.setState({ spinner: false })
this._getProfile()
// Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
// Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => {
// console.log("failed processing claim_old_balance")
this._getProfile()
let response = error.response.data
let response = error.response.data
Alert.alert(
"Error",
response.msg,
[
{
text: 'OK', onPress: () => this.setState({spinner: false})
text: 'OK', onPress: () => this.setState({ spinner: false })
}
]
);
})
}
onClickClaimCredit() {
}
onClickClaimCredit() {
Alert.alert(
"",
i18n.t('makeSureClaimCredit'),
[
{
text: i18n.t('alertno'),
onPress: () => console.log('Cancel Claim Credit'),
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
],
{ cancelable: false },
"",
i18n.t('makeSureClaimCredit'),
[
{
text: i18n.t('alertno'),
onPress: () => console.log('Cancel Claim Credit'),
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
],
{ cancelable: false },
)
}
}
_getProfile() {
try {
......@@ -178,7 +199,7 @@ class Account extends React.Component {
long: this.state.my_long,
closest_outlet: 1
})
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
// console.log("INI DATANYA : " + JSON.stringify(res))
const dataCard = res.data
......@@ -197,14 +218,14 @@ class Account extends React.Component {
let is_expired = dataCard.is_expired
let card_number = dataCard.card_number
let account_number = dataCard.account_number
if (kaspro === "") {
let cardProps = {
set_card: false
}
this.props.setCardactive(cardProps)
} else {
let cardProps = {
......@@ -212,7 +233,7 @@ class Account extends React.Component {
}
this.props.setCardactive(cardProps)
}
this.setState({
email: email,
points: point,
......@@ -229,14 +250,14 @@ class Account extends React.Component {
old_balance: old_balance,
is_expired: is_expired,
card_number: card_number
})
let setCardNumberProps = {
card_number: this.state.card_number
}
this.props.setCardNumber(setCardNumberProps)
}).catch(error => {
// const { navigation } = this.props
// let response = error.response.data
......@@ -245,11 +266,11 @@ class Account extends React.Component {
// Alert.alert('',response.msg);
Toast.show(response.msg)
})
} catch (error) {
Alert.alert('Error :' + error)
}
}
TransferBalance() {
......@@ -259,7 +280,7 @@ class Account extends React.Component {
Alert.alert(
i18n.t('notPremiumYet'),
i18n.t('wantUpgradePremium'),
[{ text: i18n.t('alertCancel') },
{ text: 'OK', onPress: () => this.props.navigation.navigate('Upgrade Premium') }
]
......@@ -271,7 +292,7 @@ class Account extends React.Component {
Alert.alert('Error : ' + error)
}
}
handleuseBalance() {
......@@ -292,7 +313,7 @@ class Account extends React.Component {
} catch (error) {
Alert.alert('Error:' + error)
}
}
render() {
......@@ -300,12 +321,12 @@ class Account extends React.Component {
const navigation = this.props.navigation
return (
<View style={styles.container}>
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
{Platform.OS === 'ios' ? (
<CustomIosStatusBar color='#CFB368' />
<CustomIosStatusBar color='#CFB368' />
) : null}
<ScrollView style={{ paddingTop: StatusBar.currentHeight }}>
<View style={{ flex: 1, height: 90 }}>
<View style={{ alignSelf: 'center' }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}>
......@@ -326,8 +347,8 @@ class Account extends React.Component {
</TouchableOpacity>
</View>
</View>
{
this.props.set_card === false ? (
<View style={{ marginTop: 65 }}>
......@@ -339,7 +360,7 @@ class Account extends React.Component {
</View>
</TouchableOpacity>
</View>
</View>
<View style={{ flex: 1, height: 250 }}>
<TouchableOpacity style={{ top: 10, marginLeft: 15, marginRight: 15, justifyContent: 'center' }} onPress={() => this.logout()}>
......@@ -352,7 +373,7 @@ class Account extends React.Component {
<Image resizeMode="contain" source={require('../assets/images/daun.png')} style={styles.logo}></Image>
</View>
<View style={{ flex: 1 }}>
</View>
</View>
</View>
......@@ -377,7 +398,7 @@ class Account extends React.Component {
<View style={{ flex: 0.5 }}>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light', color: this.state.is_expired ? "#d34343" : "#333333" }}>
{i18n.t('expired')} {this.state.expire_date}
</Text>
</Text>
</View>
</View>
<View style={{ paddingHorizontal: 10 }}>
......@@ -386,7 +407,7 @@ class Account extends React.Component {
</Text>
</View>
<View style={styles.line}></View>
<View style={{ flexDirection: 'row', flex: 1 }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
......@@ -396,9 +417,9 @@ class Account extends React.Component {
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.balance}</Text>
</View>
</View>
{/* <View style={styles.line2}></View> */}
<View style={{ flexDirection: 'row', flex: 1, display:'none' }}>
<View style={{ flexDirection: 'row', flex: 1, display: 'none' }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')}</Text>
......@@ -432,7 +453,7 @@ class Account extends React.Component {
</View>
</Card>) : (null)}
</>
)
}
</View>
......@@ -443,13 +464,13 @@ class Account extends React.Component {
</TouchableOpacity>
{/* Member Card */}
<View style={{ marginVertical:30, marginHorizontal:20 }}>
<ImageBackground style={{ width: 350, height: 210 }}
resizeMode='stretch' source={this.state.img_card ? { uri: this.state.img_card } : null}>
<View style={{ marginVertical: 30, marginHorizontal: 20 }}>
<ImageBackground style={{ width: 350, height: 210 }}
resizeMode='stretch' source={this.state.img_card ? { uri: this.state.img_card } : null}>
<View style={{ justifyContent: 'center' }}>
<Text style={{
fontFamily: 'Gotham-Black', fontSize: 20, color: '#c9af6d',
top: 160, left:30
<Text style={{
fontFamily: 'Gotham-Black', fontSize: 20, color: '#c9af6d',
top: 160, left: 30
}}>
{this.state.card_number}
</Text>
......@@ -457,7 +478,7 @@ class Account extends React.Component {
</ImageBackground>
</View>
{/* Actions Grid */}
{/* Actions Grid */}
<View style={styles.action_grid_container} >
{/* Action Transfer Balance */}
......@@ -472,9 +493,9 @@ class Account extends React.Component {
</View>
*/}
{/* Action Use Balance */}
{/* Action Use Balance */}
<View style={styles.action_grid_col_full}>
<TouchableOpacity onPress={() => this.handleuseBalance()}>
<TouchableOpacity onPress={() => this.handleuseBalance()}>
<Card style={styles.action_grid_card}>
<Image style={styles.action_grid_icon} source={require('../assets/icon/2.png')} />
<Text style={styles.action_grid_text}>{i18n.t('Usebalancepoint')}</Text>
......@@ -483,26 +504,26 @@ class Account extends React.Component {
</View>
{/* Action Transaction History */}
<View style={styles.action_grid_col}>
<View style={styles.action_grid_col}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Transaction History')} >
<Card style={styles.action_grid_card}>
<Image style={styles.action_grid_icon} source={require('../assets/icon/1.png')} />
<Text style={styles.action_grid_text}>{i18n.t('Transactionhistory')}</Text>
</Card>
</TouchableOpacity>
</View>
</View>
{/* Action Renewal */}
<View style={styles.action_grid_col}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Renewal')}>
<Card style={styles.action_grid_card}>
<Card style={styles.action_grid_card}>
<Image style={styles.action_grid_icon} source={require('../assets/icon/3.png')} />
<Text style={styles.action_grid_text}>{i18n.t('Renewal')}</Text>
</Card>
</TouchableOpacity>
</View>
{/* Action Upgrade Premium */}
{/* Action Upgrade Premium */}
{/*
{this.state.premium === false ? (
<View style={styles.action_grid_col}>
......@@ -515,35 +536,35 @@ class Account extends React.Component {
</View>
) : (null)}
*/}
</View>
{/* Actions Grid - end */}
{/* Actions Grid - end */}
{/* Button Logout */}
<View style={{ flex: 1 }}>
<TouchableOpacity onPress={() => this.logout()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginLeft: 20, marginRight: 20, marginBottom: 20, padding: 5, bottom: 5, top: 1 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('logout')}</Text>
</View>
</TouchableOpacity>
</TouchableOpacity>
</View>
</View>
)
}
<View style={{ flex: 1, marginBottom: 20, marginTop: 25 }}>
<Text style={{ color: 'grey', fontSize: 12, textAlign: 'center' }}>Version {Constants.manifest.version} Build {Constants.manifest.extra.buildNumber}</Text>
<Text style={{ color: 'grey', fontSize: 12, textAlign: 'center' }}>{Constants.manifest.extra.remarks}</Text>
</View>
</ScrollView>
</View >
)
)
} catch (error) {
Alert.alert('Error : ' + error)
}
}
}
......@@ -553,38 +574,38 @@ Account.navigationOptions = {
const styles = StyleSheet.create({
action_grid_container: {
flex:1, flexDirection: 'row', flexWrap: 'wrap',
marginLeft: 10,
marginRight: 10
flex: 1, flexDirection: 'row', flexWrap: 'wrap',
marginLeft: 10,
marginRight: 10
},
action_grid_col: {
flexBasis:'50%',
paddingLeft:10,
paddingRight:10,
marginBottom: 20
flexBasis: '50%',
paddingLeft: 10,
paddingRight: 10,
marginBottom: 20
},
action_grid_col_full: {
flexBasis:'100%',
paddingLeft:10,
paddingRight:10,
marginBottom: 20
flexBasis: '100%',
paddingLeft: 10,
paddingRight: 10,
marginBottom: 20
},
action_grid_card:{
action_grid_card: {
height: 120,
width: "100%",
backgroundColor: "#FCFCFC",
alignItems: 'center',
alignItems: 'center',
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
padding: 15,
padding: 15,
},
action_grid_icon:{
height: 50, width: 50,
action_grid_icon: {
height: 50, width: 50,
justifyContent: 'center'
},
action_grid_text:{
action_grid_text: {
fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, color: '#838383'
},
......
......@@ -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