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